Skip to content

Commit dbe3565

Browse files
committed
feat: added commando to force save or discard on exit
1 parent 0d5505c commit dbe3565

File tree

5 files changed

+215
-203
lines changed

5 files changed

+215
-203
lines changed

lazy-lock.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,31 @@
1212
"flash.nvim": { "branch": "main", "commit": "34c7be146a91fec3555c33fe89c7d643f6ef5cf1" },
1313
"friendly-snippets": { "branch": "main", "commit": "00ba9dd3df89509f95437b8d595553707c46d5ea" },
1414
"indent-blankline.nvim": { "branch": "master", "commit": "18603eb949eba08300799f64027af11ef922283f" },
15-
"lazy.nvim": { "branch": "main", "commit": "460e1cd8f24e364d54543a4b0e83f6f4ec1f65fb" },
15+
"lazy.nvim": { "branch": "main", "commit": "1159bdccd8910a0fd0914b24d6c3d186689023d9" },
1616
"lspkind.nvim": { "branch": "master", "commit": "59c3f419af48a2ffb2320cea85e44e5a95f71664" },
1717
"lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" },
1818
"mason-lspconfig.nvim": { "branch": "main", "commit": "25c11854aa25558ee6c03432edfa0df0217324be" },
1919
"mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" },
2020
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
2121
"mini.icons": { "branch": "main", "commit": "a2742459f0ee32806c2438ca06b4d8b331f3f4d4" },
2222
"neodev.nvim": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" },
23-
"nvim-autopairs": { "branch": "master", "commit": "f158dcb865c36f72c92358f87787dab2c272eaf3" },
23+
"nvim-autopairs": { "branch": "master", "commit": "ee297f215e95a60b01fde33275cc3c820eddeebe" },
2424
"nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" },
2525
"nvim-lsp-file-operations": { "branch": "master", "commit": "92a673de7ecaa157dd230d0128def10beb56d103" },
26-
"nvim-lspconfig": { "branch": "master", "commit": "76e7c8b029e6517f3689390d6599e9b446551704" },
26+
"nvim-lspconfig": { "branch": "master", "commit": "fb453a1a443b6ea6b54a1e4c101b1160c9d37950" },
2727
"nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" },
28-
"nvim-tree.lua": { "branch": "master", "commit": "9650e735baad0d39505f4cb4867a60f02858536a" },
29-
"nvim-treesitter": { "branch": "master", "commit": "36b78d112bddd69a05e24679241962e29e494d9e" },
28+
"nvim-tree.lua": { "branch": "master", "commit": "c9104a5d079db5a158c9562c54689df27d52dccc" },
29+
"nvim-treesitter": { "branch": "master", "commit": "cc2c11c403a9143827501223b4ee64432dcaf246" },
3030
"nvim-ts-autotag": { "branch": "main", "commit": "e239a560f338be31337e7abc3ee42515daf23f5e" },
31-
"nvim-ts-context-commentstring": { "branch": "main", "commit": "375c2d86cee6674afd75b4f727ce3a80065552f7" },
31+
"nvim-ts-context-commentstring": { "branch": "main", "commit": "44fd461b879d80a21d5041f312f070f22551c0bc" },
3232
"nvim-web-devicons": { "branch": "master", "commit": "9793801f974bba70e4ac5d7eae6c4f5659993d8e" },
3333
"plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" },
3434
"telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" },
3535
"telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
3636
"todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" },
37-
"tokyonight.nvim": { "branch": "main", "commit": "817bb6ffff1b9ce72cdd45d9fcfa8c9cd1ad3839" },
38-
"trouble.nvim": { "branch": "main", "commit": "6efc446226679fda0547c0fd6a7892fd5f5b15d8" },
37+
"tokyonight.nvim": { "branch": "main", "commit": "efd1417aa01af618426fe1cf507c5458090458f2" },
38+
"trouble.nvim": { "branch": "main", "commit": "254145ffd528b98eb20be894338e2d5c93fa02c2" },
3939
"vim-maximizer": { "branch": "master", "commit": "2e54952fe91e140a2e69f35f22131219fcd9c5f1" },
4040
"vim-tmux-navigator": { "branch": "master", "commit": "a9b52e7d36114d40350099f254b5f299a35df978" },
41-
"which-key.nvim": { "branch": "main", "commit": "fb070344402cfc662299d9914f5546d840a22126" }
41+
"which-key.nvim": { "branch": "main", "commit": "8badb359f7ab8711e2575ef75dfe6fbbd87e4821" }
4242
}

lua/nivi/plugins/lsp/lspconfig.lua

Lines changed: 148 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -1,142 +1,150 @@
11
return {
2-
"neovim/nvim-lspconfig",
3-
event = { "BufReadPre", "BufNewFile" },
4-
dependencies = {
5-
"hrsh7th/cmp-nvim-lsp",
6-
{ "antosha417/nvim-lsp-file-operations", config = true },
7-
{ "folke/neodev.nvim", opts = {} },
8-
},
9-
config = function()
10-
-- import lspconfig plugin
11-
local lspconfig = require("lspconfig")
12-
13-
-- import mason_lspconfig plugin
14-
local mason_lspconfig = require("mason-lspconfig")
15-
16-
-- import cmp-nvim-lsp plugin
17-
local cmp_nvim_lsp = require("cmp_nvim_lsp")
18-
19-
local keymap = vim.keymap -- for conciseness
20-
21-
vim.api.nvim_create_autocmd("LspAttach", {
22-
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
23-
callback = function(ev)
24-
-- Buffer local mappings.
25-
-- See `:help vim.lsp.*` for documentation on any of the below functions
26-
local opts = { buffer = ev.buf, silent = true }
27-
28-
-- set keybinds
29-
opts.desc = "Show LSP references"
30-
keymap.set("n", "gR", "<cmd>Telescope lsp_references<CR>", opts) -- show definition, references
31-
32-
opts.desc = "Go to declaration"
33-
keymap.set("n", "gD", vim.lsp.buf.declaration, opts) -- go to declaration
34-
35-
opts.desc = "Show LSP definitions"
36-
keymap.set("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts) -- show lsp definitions
37-
38-
opts.desc = "Show LSP implementations"
39-
keymap.set("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts) -- show lsp implementations
40-
41-
opts.desc = "Show LSP type definitions"
42-
keymap.set("n", "gt", "<cmd>Telescope lsp_type_definitions<CR>", opts) -- show lsp type definitions
43-
44-
opts.desc = "See available code actions"
45-
keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection
46-
47-
opts.desc = "Smart rename"
48-
keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts) -- smart rename
49-
50-
opts.desc = "Show buffer diagnostics"
51-
keymap.set("n", "<leader>D", "<cmd>Telescope diagnostics bufnr=0<CR>", opts) -- show diagnostics for file
52-
53-
opts.desc = "Show line diagnostics"
54-
keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts) -- show diagnostics for line
55-
56-
opts.desc = "Go to previous diagnostic"
57-
keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) -- jump to previous diagnostic in buffer
58-
59-
opts.desc = "Go to next diagnostic"
60-
keymap.set("n", "]d", vim.diagnostic.goto_next, opts) -- jump to next diagnostic in buffer
61-
62-
opts.desc = "Show documentation for what is under cursor"
63-
keymap.set("n", "K", vim.lsp.buf.hover, opts) -- show documentation for what is under cursor
64-
65-
opts.desc = "Restart LSP"
66-
keymap.set("n", "<leader>rs", ":LspRestart<CR>", opts) -- mapping to restart lsp if necessary
67-
end,
68-
})
69-
70-
-- used to enable autocompletion (assign to every lsp server config)
71-
local capabilities = cmp_nvim_lsp.default_capabilities()
72-
73-
-- Change the Diagnostic symbols in the sign column (gutter)
74-
-- (not in youtube nvim video)
75-
local signs = { Error = "", Warn = "", Hint = "󰠠 ", Info = "" }
76-
for type, icon in pairs(signs) do
77-
local hl = "DiagnosticSign" .. type
78-
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
79-
end
80-
81-
mason_lspconfig.setup_handlers({
82-
-- default handler for installed servers
83-
function(server_name)
84-
lspconfig[server_name].setup({
85-
capabilities = capabilities,
86-
})
87-
end,
88-
["graphql"] = function()
89-
-- configure graphql language server
90-
lspconfig["graphql"].setup({
91-
capabilities = capabilities,
92-
filetypes = { "graphql", "gql", "svelte", "typescriptreact", "javascriptreact" },
93-
})
94-
end,
95-
["emmet_ls"] = function()
96-
-- configure emmet language server
97-
lspconfig["emmet_ls"].setup({
98-
capabilities = capabilities,
99-
filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" },
100-
})
101-
end,
102-
["lua_ls"] = function()
103-
-- configure lua server (with special settings)
104-
lspconfig["lua_ls"].setup({
105-
capabilities = capabilities,
106-
settings = {
107-
Lua = {
108-
-- make the language server recognize "vim" global
109-
diagnostics = {
110-
globals = { "vim" },
111-
},
112-
completion = {
113-
callSnippet = "Replace",
114-
},
115-
},
116-
},
117-
})
118-
end,
119-
["gopls"] = function()
120-
-- configure gopls for Go development
121-
lspconfig["gopls"].setup({
122-
capabilities = capabilities,
123-
cmd = { "gopls", "serve" },
124-
filetypes = { "go", "gomod", "gowork", "gotmpl" },
125-
root_dir = lspconfig.util.root_pattern("go.mod", ".git"),
126-
settings = {
127-
gopls = {
128-
experimentalPostfixCompletions = true,
129-
analyses = {
130-
unusedparams = true,
131-
shadow = true,
132-
},
133-
staticcheck = true,
134-
gofumpt = true,
135-
},
136-
},
137-
})
138-
end,
139-
})
140-
end,
2+
"neovim/nvim-lspconfig",
3+
event = { "BufReadPre", "BufNewFile" },
4+
dependencies = {
5+
"hrsh7th/cmp-nvim-lsp",
6+
{ "antosha417/nvim-lsp-file-operations", config = true },
7+
{ "folke/neodev.nvim", opts = {} },
8+
},
9+
config = function()
10+
-- import lspconfig plugin
11+
local lspconfig = require("lspconfig")
12+
13+
-- import mason_lspconfig plugin
14+
local mason_lspconfig = require("mason-lspconfig")
15+
16+
-- import cmp-nvim-lsp plugin
17+
local cmp_nvim_lsp = require("cmp_nvim_lsp")
18+
19+
local keymap = vim.keymap -- for conciseness
20+
21+
vim.api.nvim_create_autocmd("LspAttach", {
22+
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
23+
callback = function(ev)
24+
-- Buffer local mappings.
25+
-- See `:help vim.lsp.*` for documentation on any of the below functions
26+
local opts = { buffer = ev.buf, silent = true }
27+
28+
-- set keybinds
29+
opts.desc = "Show LSP references"
30+
keymap.set("n", "gR", "<cmd>Telescope lsp_references<CR>", opts) -- show definition, references
31+
32+
opts.desc = "Go to declaration"
33+
keymap.set("n", "gD", vim.lsp.buf.declaration, opts) -- go to declaration
34+
35+
opts.desc = "Show LSP definitions"
36+
keymap.set("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts) -- show lsp definitions
37+
38+
opts.desc = "Show LSP implementations"
39+
keymap.set("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts) -- show lsp implementations
40+
41+
opts.desc = "Show LSP type definitions"
42+
keymap.set("n", "gt", "<cmd>Telescope lsp_type_definitions<CR>", opts) -- show lsp type definitions
43+
44+
opts.desc = "See available code actions"
45+
keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection
46+
47+
opts.desc = "Smart rename"
48+
keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts) -- smart rename
49+
50+
opts.desc = "Show buffer diagnostics"
51+
keymap.set("n", "<leader>D", "<cmd>Telescope diagnostics bufnr=0<CR>", opts) -- show diagnostics for file
52+
53+
opts.desc = "Show line diagnostics"
54+
keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts) -- show diagnostics for line
55+
56+
opts.desc = "Go to previous diagnostic"
57+
keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) -- jump to previous diagnostic in buffer
58+
59+
opts.desc = "Go to next diagnostic"
60+
keymap.set("n", "]d", vim.diagnostic.goto_next, opts) -- jump to next diagnostic in buffer
61+
62+
opts.desc = "Show documentation for what is under cursor"
63+
keymap.set("n", "K", vim.lsp.buf.hover, opts) -- show documentation for what is under cursor
64+
65+
opts.desc = "Restart LSP"
66+
keymap.set("n", "<leader>rs", ":LspRestart<CR>", opts) -- mapping to restart lsp if necessary
67+
end,
68+
})
69+
70+
-- used to enable autocompletion (assign to every lsp server config)
71+
local capabilities = cmp_nvim_lsp.default_capabilities()
72+
73+
-- Change the Diagnostic symbols in the sign column (gutter)
74+
-- (not in youtube nvim video)
75+
local signs = { Error = "", Warn = "", Hint = "󰠠 ", Info = "" }
76+
for type, icon in pairs(signs) do
77+
local hl = "DiagnosticSign" .. type
78+
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
79+
end
80+
81+
mason_lspconfig.setup_handlers({
82+
-- default handler for installed servers
83+
function(server_name)
84+
lspconfig[server_name].setup({
85+
capabilities = capabilities,
86+
})
87+
end,
88+
["graphql"] = function()
89+
-- configure graphql language server
90+
lspconfig["graphql"].setup({
91+
capabilities = capabilities,
92+
filetypes = { "graphql", "gql", "svelte", "typescriptreact", "javascriptreact" },
93+
})
94+
end,
95+
["emmet_ls"] = function()
96+
-- configure emmet language server
97+
lspconfig["emmet_ls"].setup({
98+
capabilities = capabilities,
99+
filetypes = {
100+
"html",
101+
"typescriptreact",
102+
"javascriptreact",
103+
"css",
104+
"sass",
105+
"scss",
106+
"less",
107+
"svelte",
108+
},
109+
})
110+
end,
111+
["lua_ls"] = function()
112+
-- configure lua server (with special settings)
113+
lspconfig["lua_ls"].setup({
114+
capabilities = capabilities,
115+
settings = {
116+
Lua = {
117+
-- make the language server recognize "vim" global
118+
diagnostics = {
119+
globals = { "vim" },
120+
},
121+
completion = {
122+
callSnippet = "Replace",
123+
},
124+
},
125+
},
126+
})
127+
end,
128+
["gopls"] = function()
129+
-- configure gopls for Go development
130+
lspconfig["gopls"].setup({
131+
capabilities = capabilities,
132+
cmd = { "gopls", "serve" },
133+
filetypes = { "go", "gomod", "gowork", "gotmpl" },
134+
root_dir = lspconfig.util.root_pattern("go.mod", ".git"),
135+
settings = {
136+
gopls = {
137+
experimentalPostfixCompletions = true,
138+
analyses = {
139+
unusedparams = true,
140+
shadow = true,
141+
},
142+
staticcheck = true,
143+
gofumpt = true,
144+
},
145+
},
146+
})
147+
end,
148+
})
149+
end,
141150
}
142-

lua/nivi/plugins/lsp/mason.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ return {
3737
"pyright",
3838
"gopls",
3939
"clangd",
40+
"nextls",
4041
},
4142
})
4243

0 commit comments

Comments
 (0)