Something went wrong. Try again.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091vim.pack.add { "https://github.com/neovim/nvim-lspconfig" }
vim.lsp.enable { "lua_ls" }vim.lsp.enable { "typos_lsp" }vim.lsp.enable { "ty" }vim.lsp.enable { "clangd" }vim.lsp.enable { "tinymist" }vim.lsp.enable { "wgsl_analyzer" }vim.lsp.enable { "nil_ls" }
vim.api.nvim_create_autocmd("LspAttach", { group = vim.api.nvim_create_augroup("custom_lsp_attach", { clear = true }), callback = function(args) local client = vim.lsp.get_client_by_id(args.data.client_id)
vim.keymap.set({ "n", "v" }, "gra", vim.lsp.buf.code_action, { desc = "Code action" }) vim.keymap.set("n", "gri", vim.lsp.buf.implementation, { desc = "Implementation" }) vim.keymap.set("n", "grn", vim.lsp.buf.rename, { desc = "Rename" }) vim.keymap.set("n", "grr", vim.lsp.buf.references, { desc = "References" }) vim.keymap.set("n", "grt", vim.lsp.buf.type_definition, { desc = "Type definition" }) vim.keymap.set("n", "gO", vim.lsp.buf.document_symbol, { desc = "Document symbol" }) vim.keymap.set("n", "gd", vim.lsp.buf.definition, { desc = "Go to definition" }) vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { desc = "Go to declaration" }) -- local builtin = require("telescope.builtin") -- -- Fuzzy find all the symbols in your current document. Symbols are things like variables, functions, types, etc. -- vim.keymap.set( -- "n", -- "<leader>ld", -- builtin.lsp_document_symbols, -- { desc = "[L]SP [D]ocument Symbols" } -- ) -- -- Fuzzy find all the symbols in your current workspace Similar to document symbols, except searches over your whole project. -- vim.keymap.set( -- "n", -- "<leader>lw", -- builtin.lsp_dynamic_workspace_symbols, -- { desc = "[L]SP [W]orkspace Symbols" } -- ) -- Execute a code action, usually your cursor needs to be on top of an error or a suggestion from your LSP for this to activate. vim.keymap.set( { "n" }, "[d", function() vim.diagnostic.jump { count = -1 } end, { desc = "Prev Diagnostic" } ) vim.keymap.set( { "n" }, "]d", function() vim.diagnostic.jump { count = 1 } end, { desc = "Next Diagnostic" } )
-- The following two autocommands are used to highlight references of the -- word under your cursor when your cursor rests there for a little while. -- See `:help CursorHold` for information about when this is executed -- -- When you move your cursor, the highlights will be cleared (the second autocommand). if client and client.server_capabilities.documentHighlightProvider then local highlight_augroup = vim.api.nvim_create_augroup("lsp-highlight", { clear = false }) vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { buffer = args.buf, group = highlight_augroup, callback = vim.lsp.buf.document_highlight, })
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, { buffer = args.buf, group = highlight_augroup, callback = vim.lsp.buf.clear_references, })
vim.api.nvim_create_autocmd("LspDetach", { group = vim.api.nvim_create_augroup("lsp-detach", { clear = true }), callback = function(event) vim.lsp.buf.clear_references() vim.api.nvim_clear_autocmds { group = highlight_augroup, buffer = event.buf } end, }) end if client and client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then vim.keymap.set( "n", "grh", function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) end, { desc = "Toggle inlay hints" } ) end end,})