Migrate LSP setup for mason-lspconfig v2 and add claudecode.nvim.
Replace deprecated setup_handlers with vim.lsp.config(), add the claudecode plugin spec under lua/custom/plugins/, and include nginx and yaml treesitter parsers. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
a6191baef5
commit
a4853b28f6
31
init.lua
31
init.lua
|
|
@ -309,7 +309,7 @@ vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { de
|
||||||
-- See `:help nvim-treesitter`
|
-- See `:help nvim-treesitter`
|
||||||
require('nvim-treesitter.configs').setup {
|
require('nvim-treesitter.configs').setup {
|
||||||
-- Add languages to be installed here that you want installed for treesitter
|
-- Add languages to be installed here that you want installed for treesitter
|
||||||
ensure_installed = { 'c', 'cpp', 'go', 'hcl', 'lua', 'python', 'rust', 'terraform', 'tsx', 'typescript', 'vim', 'vimdoc' },
|
ensure_installed = { 'c', 'cpp', 'go', 'hcl', 'lua', 'nginx', 'python', 'rust', 'terraform', 'tsx', 'typescript', 'vim', 'vimdoc', 'yaml' },
|
||||||
|
|
||||||
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
|
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
|
||||||
auto_install = true,
|
auto_install = true,
|
||||||
|
|
@ -446,26 +446,25 @@ local servers = {
|
||||||
require('neodev').setup()
|
require('neodev').setup()
|
||||||
|
|
||||||
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
|
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||||
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
|
|
||||||
|
|
||||||
-- Ensure the servers above are installed
|
-- mason-lspconfig v2+ uses Neovim's native vim.lsp.config / vim.lsp.enable APIs
|
||||||
local mason_lspconfig = require 'mason-lspconfig'
|
vim.lsp.config('*', {
|
||||||
|
capabilities = capabilities,
|
||||||
|
on_attach = on_attach,
|
||||||
|
})
|
||||||
|
|
||||||
mason_lspconfig.setup {
|
for server_name, settings in pairs(servers) do
|
||||||
|
vim.lsp.config(server_name, {
|
||||||
|
settings = settings,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Ensure the servers above are installed (and auto-enabled when installed)
|
||||||
|
require('mason-lspconfig').setup {
|
||||||
ensure_installed = vim.tbl_keys(servers),
|
ensure_installed = vim.tbl_keys(servers),
|
||||||
}
|
}
|
||||||
|
|
||||||
mason_lspconfig.setup_handlers {
|
|
||||||
function(server_name)
|
|
||||||
require('lspconfig')[server_name].setup {
|
|
||||||
capabilities = capabilities,
|
|
||||||
on_attach = on_attach,
|
|
||||||
settings = servers[server_name],
|
|
||||||
}
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|
||||||
-- [[ Configure nvim-cmp ]]
|
-- [[ Configure nvim-cmp ]]
|
||||||
-- See `:help cmp`
|
-- See `:help cmp`
|
||||||
local cmp = require 'cmp'
|
local cmp = require 'cmp'
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
return {
|
||||||
|
"coder/claudecode.nvim",
|
||||||
|
dependencies = { "folke/snacks.nvim" },
|
||||||
|
config = true,
|
||||||
|
-- `cmd` lets lazy.nvim create command stubs that load the plugin on first use,
|
||||||
|
-- so `:ClaudeCode` and friends work on a fresh start. Without it, a keys-only
|
||||||
|
-- spec defers loading until a <leader>a* mapping is pressed and the commands
|
||||||
|
-- would not exist yet.
|
||||||
|
cmd = {
|
||||||
|
"ClaudeCode",
|
||||||
|
"ClaudeCodeFocus",
|
||||||
|
"ClaudeCodeSelectModel",
|
||||||
|
"ClaudeCodeAdd",
|
||||||
|
"ClaudeCodeSend",
|
||||||
|
"ClaudeCodeTreeAdd",
|
||||||
|
"ClaudeCodeStatus",
|
||||||
|
"ClaudeCodeStart",
|
||||||
|
"ClaudeCodeStop",
|
||||||
|
"ClaudeCodeOpen",
|
||||||
|
"ClaudeCodeClose",
|
||||||
|
"ClaudeCodeDiffAccept",
|
||||||
|
"ClaudeCodeDiffDeny",
|
||||||
|
"ClaudeCodeCloseAllDiffs",
|
||||||
|
},
|
||||||
|
keys = {
|
||||||
|
{ "<leader>a", nil, desc = "AI/Claude Code" },
|
||||||
|
{ "<leader>ac", "<cmd>ClaudeCode<cr>", desc = "Toggle Claude" },
|
||||||
|
{ "<leader>af", "<cmd>ClaudeCodeFocus<cr>", desc = "Focus Claude" },
|
||||||
|
{ "<leader>ar", "<cmd>ClaudeCode --resume<cr>", desc = "Resume Claude" },
|
||||||
|
{ "<leader>aC", "<cmd>ClaudeCode --continue<cr>", desc = "Continue Claude" },
|
||||||
|
{ "<leader>am", "<cmd>ClaudeCodeSelectModel<cr>", desc = "Select Claude model" },
|
||||||
|
{ "<leader>ab", "<cmd>ClaudeCodeAdd %<cr>", desc = "Add current buffer" },
|
||||||
|
{ "<leader>as", "<cmd>ClaudeCodeSend<cr>", mode = "v", desc = "Send to Claude" },
|
||||||
|
{
|
||||||
|
"<leader>as",
|
||||||
|
"<cmd>ClaudeCodeTreeAdd<cr>",
|
||||||
|
desc = "Add file",
|
||||||
|
ft = { "NvimTree", "neo-tree", "oil", "minifiles", "netrw", "snacks_picker_list" },
|
||||||
|
},
|
||||||
|
-- Diff management
|
||||||
|
{ "<leader>aa", "<cmd>ClaudeCodeDiffAccept<cr>", desc = "Accept diff" },
|
||||||
|
{ "<leader>ad", "<cmd>ClaudeCodeDiffDeny<cr>", desc = "Deny diff" },
|
||||||
|
},
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue