Remove lsp-zero (replaced with native Neovim 0.11 LSP support), vim-fugitive, and pyright. Add basedpyright, gitsigns, which-key, trouble, todo-comments, indent-blankline, and telescope-fzf-native. Clean up duplicate keybinds and organize under which-key groups. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
328 lines
7.1 KiB
Lua
328 lines
7.1 KiB
Lua
-- Plugins
|
|
|
|
-- Format on save for nix, lua, ts/js
|
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
|
pattern = { "*.nix", "*.lua", "*.ts", "*.tsx", "*.js" },
|
|
callback = function()
|
|
vim.lsp.buf.format({ async = false, timeout_ms = 10000 })
|
|
end,
|
|
})
|
|
|
|
-- LSP: go
|
|
vim.lsp.config("gopls", {
|
|
settings = {
|
|
gopls = {
|
|
analyses = {
|
|
unusedparams = true,
|
|
},
|
|
staticcheck = true,
|
|
gofumpt = true,
|
|
}
|
|
}
|
|
})
|
|
vim.lsp.enable({ "gopls" })
|
|
|
|
-- GO: Automatically organize imports on save
|
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
|
pattern = "*.go",
|
|
callback = function()
|
|
local params = vim.lsp.util.make_range_params()
|
|
params.context = { only = { "source.organizeImports" } }
|
|
-- buf_request_sync defaults to a 1000ms timeout. Depending on your
|
|
-- machine and codebase, you may want longer. Add an additional
|
|
-- argument after params if you find that you have to write the file
|
|
-- twice for changes to be saved.
|
|
-- E.g., vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, 3000)
|
|
local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params)
|
|
for cid, res in pairs(result or {}) do
|
|
for _, r in pairs(res.result or {}) do
|
|
if r.edit then
|
|
local enc = (vim.lsp.get_client_by_id(cid) or {}).offset_encoding or "utf-16"
|
|
vim.lsp.util.apply_workspace_edit(r.edit, enc)
|
|
end
|
|
end
|
|
end
|
|
vim.lsp.buf.format({ async = false })
|
|
end
|
|
})
|
|
|
|
-- LSP: nix
|
|
vim.lsp.config("nil_ls", {
|
|
autostart = true,
|
|
settings = {
|
|
['nil'] = {
|
|
formatting = {
|
|
command = { "nixfmt" },
|
|
},
|
|
},
|
|
},
|
|
})
|
|
vim.lsp.enable({ "nil_ls" })
|
|
|
|
-- LSP: lua
|
|
vim.lsp.config("lua_ls", {
|
|
on_init = function(client)
|
|
local path = client.workspace_folders[1].name
|
|
if vim.loop.fs_stat(path .. '/.luarc.json') or vim.loop.fs_stat(path .. '/.luarc.jsonc') then
|
|
return
|
|
end
|
|
|
|
client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
|
|
runtime = {
|
|
-- Tell the language server which version of Lua you're using
|
|
-- (most likely LuaJIT in the case of Neovim)
|
|
version = 'LuaJIT'
|
|
},
|
|
-- Make the server aware of Neovim runtime files
|
|
workspace = {
|
|
checkThirdParty = false,
|
|
library = {
|
|
vim.env.VIMRUNTIME
|
|
-- Depending on the usage, you might want to add additional paths here.
|
|
-- "${3rd}/luv/library"
|
|
-- "${3rd}/busted/library",
|
|
}
|
|
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower
|
|
-- library = vim.api.nvim_get_runtime_file("", true)
|
|
}
|
|
})
|
|
end,
|
|
settings = {
|
|
Lua = {
|
|
format = {
|
|
enable = true,
|
|
defaultConfig = {
|
|
indent_style = "space",
|
|
indent_size = "2",
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
vim.lsp.enable({ "lua_ls" })
|
|
|
|
|
|
-- LSP: ts/js
|
|
vim.lsp.config("ts_ls", {
|
|
init_options = {
|
|
plugins = {
|
|
},
|
|
},
|
|
filetypes = {
|
|
"typescript",
|
|
"javascript",
|
|
"typescriptreact",
|
|
},
|
|
})
|
|
vim.lsp.enable({ "ts_ls" })
|
|
|
|
-- LSP: python
|
|
-- Ruff server
|
|
vim.lsp.config("ruff", {
|
|
})
|
|
vim.lsp.enable({ "ruff" })
|
|
|
|
-- Ruff: automatically format on save
|
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
|
pattern = "*.py",
|
|
callback = function()
|
|
vim.lsp.buf.format { async = false }
|
|
end,
|
|
})
|
|
|
|
-- Ruff: Disable hover capability
|
|
vim.api.nvim_create_autocmd("LspAttach", {
|
|
group = vim.api.nvim_create_augroup('lsp_attach_disable_ruff_hover', { clear = true }),
|
|
callback = function(args)
|
|
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
|
if client == nil then
|
|
return
|
|
end
|
|
if client.name == 'ruff' then
|
|
-- Disable hover in favor of Pyright
|
|
client.server_capabilities.hoverProvider = false
|
|
end
|
|
end,
|
|
desc = 'LSP: Disable hover capability from Ruff',
|
|
})
|
|
|
|
-- Basedpyright
|
|
vim.lsp.config("basedpyright", {
|
|
settings = {
|
|
basedpyright = {
|
|
-- Using Ruff's import organizer
|
|
disableOrganizeImports = true,
|
|
analysis = {
|
|
-- Ignore all files for analysis to exclusively use Ruff for linting
|
|
ignore = { '*' },
|
|
},
|
|
},
|
|
},
|
|
})
|
|
vim.lsp.enable({ "basedpyright" })
|
|
|
|
-- Gitsigns
|
|
require('gitsigns').setup()
|
|
|
|
-- Telescope
|
|
require('telescope').setup({
|
|
extensions = {
|
|
fzf = {
|
|
fuzzy = true,
|
|
override_generic_sorter = true,
|
|
override_file_sorter = true,
|
|
case_mode = "smart_case",
|
|
}
|
|
},
|
|
})
|
|
require('telescope').load_extension('fzf')
|
|
|
|
-- Treesitter
|
|
require('nvim-treesitter').setup {
|
|
ensure_installed = {},
|
|
auto_install = false,
|
|
highlight = { enable = true },
|
|
indent = { enable = true },
|
|
|
|
incremental_selection = {
|
|
enable = true,
|
|
keymaps = {
|
|
init_selection = '<c-space>',
|
|
node_incremental = '<c-space>',
|
|
scope_incremental = '<c-s>',
|
|
node_decremental = '<M-space>',
|
|
},
|
|
},
|
|
textobjects = {
|
|
select = {
|
|
enable = true,
|
|
lookahead = true,
|
|
|
|
keymaps = {
|
|
['aa'] = '@parameter.outer',
|
|
['ia'] = '@parameter.inner',
|
|
['af'] = '@function.outer',
|
|
['if'] = '@function.inner',
|
|
['ac'] = '@class.outer',
|
|
['ic'] = '@class.inner',
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
-- Lualine
|
|
require('lualine').setup({
|
|
options = {
|
|
icons_enabled = false,
|
|
component_separators = '|',
|
|
disabled_filetypes = {},
|
|
always_divide_middle = true,
|
|
globalstatus = true,
|
|
},
|
|
sections = {
|
|
lualine_a = { 'mode' },
|
|
lualine_b = { 'branch', 'diff', 'diagnostics' },
|
|
lualine_c = {
|
|
{
|
|
'filename',
|
|
file_status = true,
|
|
newfile_status = true,
|
|
path = 3,
|
|
shorting_target = 30,
|
|
symbols = {
|
|
modified = '[+]',
|
|
readonly = '[-]',
|
|
unnamed = '[No name]',
|
|
newfile = '[New]'
|
|
}
|
|
}
|
|
},
|
|
lualine_x = { 'encoding', 'fileformat', 'filetype' },
|
|
lualine_y = { 'progress' },
|
|
lualine_z = { 'location' }
|
|
}
|
|
})
|
|
|
|
-- Copilot
|
|
require('copilot').setup({
|
|
suggestions = { enabled = false },
|
|
panel = { enabled = false },
|
|
})
|
|
require('copilot_cmp').setup()
|
|
|
|
-- Cmp
|
|
local cmp = require('cmp')
|
|
local luasnip = require('luasnip')
|
|
|
|
cmp.setup({
|
|
snippet = {
|
|
expand = function(args)
|
|
luasnip.lsp_expand(args.body)
|
|
end,
|
|
},
|
|
mapping = cmp.mapping.preset.insert({
|
|
-- Enter to confirm completion
|
|
['<CR>'] = cmp.mapping.confirm({ select = false }),
|
|
-- Ctrl+Space to open completion menu
|
|
['<C-Space>'] = cmp.mapping.complete(),
|
|
-- Tab to select next item or jump in snippet
|
|
['<Tab>'] = cmp.mapping(function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_next_item()
|
|
elseif luasnip.expand_or_jumpable() then
|
|
luasnip.expand_or_jump()
|
|
else
|
|
fallback()
|
|
end
|
|
end, { 'i', 's' }),
|
|
['<S-Tab>'] = cmp.mapping(function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_prev_item()
|
|
elseif luasnip.jumpable(-1) then
|
|
luasnip.jump(-1)
|
|
else
|
|
fallback()
|
|
end
|
|
end, { 'i', 's' }),
|
|
-- Scroll in completion docs
|
|
['<C-k>'] = cmp.mapping.scroll_docs(-4),
|
|
['<C-j>'] = cmp.mapping.scroll_docs(4),
|
|
}),
|
|
sources = cmp.config.sources({
|
|
}, {
|
|
{ name = "copilot", group_index = 2 },
|
|
{ name = "nvim_lsp", group_index = 2 },
|
|
-- { name = "luasnip" },
|
|
-- { name = "buffer" },
|
|
})
|
|
})
|
|
|
|
|
|
-- Indent blankline
|
|
require('ibl').setup()
|
|
|
|
-- Trouble
|
|
require('trouble').setup({
|
|
icons = false,
|
|
})
|
|
|
|
-- Todo comments
|
|
require('todo-comments').setup({
|
|
signs = false,
|
|
})
|
|
|
|
-- Which-key
|
|
require('which-key').setup()
|
|
require('which-key').add({
|
|
{ "<leader>d", group = "Diagnostics" },
|
|
{ "<leader>f", group = "Find" },
|
|
{ "<leader>g", group = "Git" },
|
|
{ "<leader>l", group = "LSP" },
|
|
{ "<leader>t", group = "Tabs" },
|
|
})
|
|
|
|
-- Colorscheme
|
|
require('catppuccin').setup {
|
|
}
|
|
vim.cmd.colorscheme "catppuccin"
|