feat: <leader>q exit
parent
fd9b13e5e7
commit
6efcb93d3d
|
@ -19,6 +19,7 @@ This is a modern Neovim configuration built around the lazy.nvim plugin manager.
|
||||||
- LSP servers are defined in `commons.servers` array
|
- LSP servers are defined in `commons.servers` array
|
||||||
- Server-specific settings live in `lua/lsp/{server}.lua` files
|
- Server-specific settings live in `lua/lsp/{server}.lua` files
|
||||||
- Uses blink.cmp for completion capabilities
|
- Uses blink.cmp for completion capabilities
|
||||||
|
- LSP servers supported: lua_ls, gopls, clangd, bashls, pyright, yamlls, ts_ls, rust_analyzer
|
||||||
- Mason.nvim auto-installs: stylua, lua-language-server, gopls, pyright
|
- Mason.nvim auto-installs: stylua, lua-language-server, gopls, pyright
|
||||||
|
|
||||||
### Plugin Architecture
|
### Plugin Architecture
|
||||||
|
@ -28,8 +29,9 @@ This is a modern Neovim configuration built around the lazy.nvim plugin manager.
|
||||||
|
|
||||||
### Formatting
|
### Formatting
|
||||||
- Conform.nvim handles formatting with `<leader>ff` keybind
|
- Conform.nvim handles formatting with `<leader>ff` keybind
|
||||||
- Format-on-save enabled with 500ms timeout
|
- Format-on-save enabled with 500ms timeout, format command uses 3000ms timeout
|
||||||
- Configured formatters: stylua (Lua), black (Python), rustfmt (Rust), prettier (JS), shfmt (shell)
|
- Configured formatters: stylua (Lua), black (Python), rustfmt (Rust), prettier (JS), shfmt (shell)
|
||||||
|
- Stylua configured with `--collapse-simple-statement Always`
|
||||||
|
|
||||||
## Common Development Tasks
|
## Common Development Tasks
|
||||||
|
|
||||||
|
@ -46,10 +48,11 @@ This is a modern Neovim configuration built around the lazy.nvim plugin manager.
|
||||||
### Key Mappings
|
### Key Mappings
|
||||||
- Leader key: `<Space>`
|
- Leader key: `<Space>`
|
||||||
- Save: `<leader>s`
|
- Save: `<leader>s`
|
||||||
- Buffer delete: `<leader>q`
|
- Smart buffer delete: `<leader>q` (switches to next buffer, or opens explorer if last buffer)
|
||||||
- Quit: `<leader>qq` (force quit: `<leader>qqq`)
|
- Quit: `<leader>qq` (force quit: `<leader>qqq`)
|
||||||
- Format code: `<leader>ff`
|
- Format code: `<leader>ff`
|
||||||
- Toggle comment: `mm` (normal/visual mode)
|
- Toggle comment: `mm` (normal/visual mode)
|
||||||
|
- Show diagnostics: `<leader>d` (uses Snacks picker)
|
||||||
|
|
||||||
### File Structure Conventions
|
### File Structure Conventions
|
||||||
- Plugin configs: `lua/plugins/{plugin-name}.lua`
|
- Plugin configs: `lua/plugins/{plugin-name}.lua`
|
||||||
|
|
|
@ -1,9 +1,37 @@
|
||||||
local map = vim.keymap.set
|
local map = vim.keymap.set
|
||||||
map("n", "<leader>s", ":w<CR>", {})
|
map("n", "<leader>s", ":w<CR>", {})
|
||||||
map("n", "<leader>q", ":bdelete<CR>", {})
|
map("n", "<leader>q", function()
|
||||||
|
local buffers = vim.fn.getbufinfo({ buflisted = 1 })
|
||||||
|
if #buffers <= 1 then
|
||||||
|
-- Check if explorer is already open
|
||||||
|
local explorer_win = nil
|
||||||
|
for _, win in ipairs(vim.api.nvim_list_wins()) do
|
||||||
|
local buf = vim.api.nvim_win_get_buf(win)
|
||||||
|
local ft = vim.api.nvim_get_option_value("filetype", { buf = buf })
|
||||||
|
if ft == "snacks_picker_list" then
|
||||||
|
explorer_win = win
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
vim.cmd("bdelete")
|
||||||
|
if explorer_win then
|
||||||
|
-- Explorer is already open, just focus it
|
||||||
|
vim.api.nvim_set_current_win(explorer_win)
|
||||||
|
else
|
||||||
|
-- Explorer not open, open it
|
||||||
|
Snacks.explorer()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
vim.cmd("bnext")
|
||||||
|
vim.cmd("bdelete #")
|
||||||
|
end
|
||||||
|
end, { desc = "Smart buffer delete" })
|
||||||
map("n", "<leader>qq", ":q<CR>'", {})
|
map("n", "<leader>qq", ":q<CR>'", {})
|
||||||
map("n", "<leader>qqq", ":qa!<CR>", {})
|
map("n", "<leader>qqq", ":qa!<CR>", {})
|
||||||
map("n", "<leader>s", ":w<CR>", {})
|
map("n", "<leader>s", ":w<CR>", {})
|
||||||
|
|
||||||
map("n", "mm", "gcc", { desc = "Toggle comment", remap = true })
|
map("n", "mm", "gcc", { desc = "Toggle comment", remap = true })
|
||||||
map("v", "mm", "gc", { desc = "Toggle comment", remap = true })
|
map("v", "mm", "gc", { desc = "Toggle comment", remap = true })
|
||||||
|
|
||||||
|
-- Diagnostics
|
||||||
|
map("n", "<leader>d", function() Snacks.picker.diagnostics() end, { desc = "Show Diagnostics" })
|
||||||
|
|
Loading…
Reference in New Issue