✨ feat(nvim): lsp changes
inlay hints for lua and rust, as well as an autocmd for entering insert mode and disabling inlay hints. also made a new group on code to lsp keymaps
This commit is contained in:
parent
4ba77eeb53
commit
95523207af
1 changed files with 66 additions and 0 deletions
|
@ -3,11 +3,57 @@ return {
|
|||
"neovim/nvim-lspconfig",
|
||||
init = function()
|
||||
local keys = require("lazyvim.plugins.lsp.keymaps").get()
|
||||
keys[#keys + 1] = { "<leader>cl", false }
|
||||
keys[#keys + 1] = { "<leader>cli", "<cmd>LspInfo<cr>", desc = "LspInfo" }
|
||||
|
||||
-- add more lsp keymaps
|
||||
-- keys[#keys + 1] = { "<leader>cla", vim.lsp.buf.add_workspace_folder, desc = "Add Folder" }
|
||||
-- keys[#keys + 1] = { "<leader>clr", vim.lsp.buf.remove_workspace_folder, desc = "Remove Folder" }
|
||||
keys[#keys + 1] = {
|
||||
"<leader>cll",
|
||||
"<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<cr>",
|
||||
desc = "List Folders",
|
||||
}
|
||||
keys[#keys + 1] = { "<leader>clh", vim.lsp.codelens.run, desc = "Run Code Lens" }
|
||||
keys[#keys + 1] = { "<leader>cld", vim.lsp.codelens.refresh, desc = "Refresh Code Lens" }
|
||||
keys[#keys + 1] = { "<leader>clr", "<cmd>LspRestart<cr>", desc = "Restart Lsp" }
|
||||
keys[#keys + 1] = { "<leader>cls", "<cmd>LspStart<cr>", desc = "Start Lsp" }
|
||||
keys[#keys + 1] = { "<leader>clS", "<cmd>LspStop<cr>", desc = "Stop Lsp" }
|
||||
require("which-key").register({
|
||||
["<leader>cl"] = { name = "+lsp" },
|
||||
})
|
||||
-- keys[#keys + 1] = { "gd", "<CMD>Glance definitions<CR>", desc = "Goto definition" }
|
||||
keys[#keys + 1] = { "gr", "<CMD>Glance references<CR>", desc = "References" }
|
||||
keys[#keys + 1] = { "gy", "<CMD>Glance type_definitions<CR>", desc = "Goto t[y]pe definitions" }
|
||||
keys[#keys + 1] = { "gI", "<CMD>Glance implementations<CR>", desc = "Goto implementations" }
|
||||
keys[#keys + 1] = { "<leader>ca", require("actions-preview").code_actions, desc = "Code Action Preview" }
|
||||
require("lazyvim.util").lsp.on_attach(function(client, buffer)
|
||||
if client.supports_method("textDocument/documentSymbol") then
|
||||
-- Enable inlay hints if the client supports it.
|
||||
if client.server_capabilities.inlayHintProvider then
|
||||
local inlay_hints_group = vim.api.nvim_create_augroup("InlayHints", { clear = true })
|
||||
|
||||
-- Initial inlay hint display.
|
||||
local mode = vim.api.nvim_get_mode().mode
|
||||
vim.lsp.inlay_hint(buffer, mode == "n" or mode == "v")
|
||||
|
||||
vim.api.nvim_create_autocmd("InsertEnter", {
|
||||
group = inlay_hints_group,
|
||||
buffer = buffer,
|
||||
callback = function()
|
||||
vim.lsp.inlay_hint(buffer, false)
|
||||
end,
|
||||
})
|
||||
vim.api.nvim_create_autocmd("InsertLeave", {
|
||||
group = inlay_hints_group,
|
||||
buffer = buffer,
|
||||
callback = function()
|
||||
vim.lsp.inlay_hint(buffer, true)
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
end)
|
||||
end,
|
||||
opts = {
|
||||
-- options for vim.diagnostic.config()
|
||||
|
@ -31,6 +77,15 @@ return {
|
|||
enabled = true,
|
||||
},
|
||||
servers = {
|
||||
lua_ls = {
|
||||
settings = {
|
||||
Lua = {
|
||||
hint = {
|
||||
enable = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
tsserver = {
|
||||
init_options = {
|
||||
preferences = {
|
||||
|
@ -80,4 +135,15 @@ return {
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"simrat39/rust-tools.nvim",
|
||||
lazy = true,
|
||||
opts = function(_, opts)
|
||||
opts.tools = {
|
||||
inlay_hints = {
|
||||
auto = false,
|
||||
},
|
||||
}
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue