summaryrefslogtreecommitdiff
path: root/dot_config/nvim/lua/plugins/lsp.lua
diff options
context:
space:
mode:
authorSakamoto <me@sakamoto.network>2026-05-12 18:31:15 -0500
committerSakamoto <me@sakamoto.network>2026-05-12 18:31:15 -0500
commita623fed63460d6d810605ce1ce858a58a5b222f7 (patch)
tree2129e72acc82deaf624630ec271942000eae0aeb /dot_config/nvim/lua/plugins/lsp.lua
downloaddotfiles-a623fed63460d6d810605ce1ce858a58a5b222f7.tar.xz
dotfiles-a623fed63460d6d810605ce1ce858a58a5b222f7.zip
init
Diffstat (limited to 'dot_config/nvim/lua/plugins/lsp.lua')
-rw-r--r--dot_config/nvim/lua/plugins/lsp.lua61
1 files changed, 61 insertions, 0 deletions
diff --git a/dot_config/nvim/lua/plugins/lsp.lua b/dot_config/nvim/lua/plugins/lsp.lua
new file mode 100644
index 0000000..cd9ff77
--- /dev/null
+++ b/dot_config/nvim/lua/plugins/lsp.lua
@@ -0,0 +1,61 @@
+return {
+ "neovim/nvim-lspconfig",
+ config = function()
+ -- auto format
+ vim.cmd([[autocmd BufWritePre * lua vim.lsp.buf.format()]])
+
+ -- Global mappings.
+ -- See `:help vim.diagnostic.*` for documentation on any of the below functions
+ vim.keymap.set("n", "<leader>gm", vim.diagnostic.open_float)
+ vim.keymap.set("n", "[d", vim.diagnostic.goto_prev)
+ vim.keymap.set("n", "]d", vim.diagnostic.goto_next)
+ vim.keymap.set("n", "<leader>q", vim.diagnostic.setqflist)
+ vim.lsp.enable('clangd')
+
+ -- Use LspAttach autocommand to only map the following keys
+ -- after the language server attaches to the current buffer
+ vim.api.nvim_create_autocmd("LspAttach", {
+ group = vim.api.nvim_create_augroup("UserLspConfig", {}),
+ callback = function(ev)
+ -- Enable completion triggered by <c-x><c-o>
+ -- vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
+ -- Buffer local mappings.
+ -- See `:help vim.lsp.*` for documentation on any of the below functions
+ local opts = { buffer = ev.buf }
+ vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
+ vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
+ vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
+ vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
+ vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
+ vim.keymap.set("n", "<leader>wa", vim.lsp.buf.add_workspace_folder, opts)
+ vim.keymap.set("n", "<leader>wr", vim.lsp.buf.remove_workspace_folder, opts)
+ vim.keymap.set("n", "<leader>wl", function()
+ print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
+ end, opts)
+ vim.keymap.set("n", "<leader>D", vim.lsp.buf.type_definition, opts)
+ vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
+ vim.keymap.set("n", "<A-CR>", vim.lsp.buf.code_action, opts)
+ vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
+ vim.keymap.set("n", "<leader>f", function()
+ vim.lsp.buf.format({ async = true })
+ end, opts)
+ end,
+ vim.keymap.set("n", "<leader>i", function()
+ vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ 0 }), { 0 })
+ end, opts),
+ })
+
+ vim.diagnostic.config({
+ -- Use the default configuration
+ virtual_lines = true,
+
+ -- Alternatively, customize specific options
+ virtual_lines = {
+ -- Only show virtual line diagnostics for the current cursor line
+ current_line = true,
+ },
+ })
+ end,
+
+ vim.lsp.enable('tinymist'),
+}