feat(wip): port nvim config to nix
This commit is contained in:
parent
a9abe9c5bf
commit
8d1dea31b2
9 changed files with 173 additions and 209 deletions
|
@ -0,0 +1,69 @@
|
|||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
|
||||
local on_attach = function(client, bufnr)
|
||||
local function nnoremap(key, command)
|
||||
vim.keymap.set("n", key, command, { noremap = true, silent = true, buffer = bufnr })
|
||||
end
|
||||
|
||||
local telescope = require("telescope.builtin")
|
||||
|
||||
nnoremap("gD", vim.lsp.buf.declaration)
|
||||
nnoremap("gd", telescope.lsp_definitions)
|
||||
nnoremap("gt", telescope.lsp_type_definitions)
|
||||
nnoremap("gi", telescope.lsp_implementations)
|
||||
nnoremap("gr", telescope.lsp_references)
|
||||
nnoremap("K", vim.lsp.buf.hover)
|
||||
nnoremap("<C-k>", vim.lsp.buf.signature_help)
|
||||
nnoremap("<leader>rn", vim.lsp.buf.rename)
|
||||
nnoremap("<leader>ca", vim.lsp.buf.code_action)
|
||||
nnoremap("<leader>f", vim.lsp.buf.formatting)
|
||||
nnoremap("<leader>d", telescope.diagnostics)
|
||||
nnoremap("<C-p>", vim.diagnostic.goto_prev)
|
||||
nnoremap("<C-n>", vim.diagnostic.goto_next)
|
||||
|
||||
if client.supports_method("textDocument/formatting") then
|
||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
vim.lsp.buf.formatting_sync()
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
local lsp_status = require("lsp-status")
|
||||
lsp_status.config({
|
||||
current_function = false,
|
||||
show_filename = false,
|
||||
diagnostics = true,
|
||||
})
|
||||
lsp_status.register_progress()
|
||||
|
||||
local capabilities = vim.tbl_extend("keep", vim.lsp.protocol.make_client_capabilities(), lsp_status.capabilities)
|
||||
capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities)
|
||||
|
||||
local servers = {
|
||||
["sumneko_lua"] = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { "vim" },
|
||||
},
|
||||
telemetry = {
|
||||
enable = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
["rnix"] = {},
|
||||
}
|
||||
|
||||
local lspconfig = require("lspconfig")
|
||||
|
||||
for lsp, config in pairs(servers) do
|
||||
lspconfig[lsp].setup({
|
||||
settings = config or {},
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
})
|
||||
end
|
|
@ -16,9 +16,7 @@ cmp.setup({
|
|||
},
|
||||
sources = require("cmp").config.sources({
|
||||
{ name = "nvim_lsp" }, { name = "luasnip" }, { name = "path" },
|
||||
{ name = "buffer" }, { name = "git" },
|
||||
{ name = 'nvim_lsp_signature_help' },
|
||||
{ name = "conventionalcommits" }, { name = "nvim-lua" },
|
||||
{ name = "buffer" }, { name = "git" }, { name = "nvim-lua" },
|
||||
{ name = "calc" }
|
||||
}),
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
|
|
|
@ -39,6 +39,7 @@ require("nvim-lsp-setup").setup({
|
|||
eslint = {},
|
||||
jsonls = {},
|
||||
pylsp = {},
|
||||
rnix = {},
|
||||
rust_analyzer = require("nvim-lsp-setup.rust-tools").setup({
|
||||
server = {
|
||||
settings = {
|
||||
|
|
|
@ -3,7 +3,7 @@ require('nvim-treesitter.configs').setup({
|
|||
indent = {enable = true},
|
||||
ensure_installed = {
|
||||
"bash", "c", "cpp", "css", "dockerfile", "hcl", "html", "javascript",
|
||||
"json", "latex", "lua", "markdown", "python", "rust", "svelte", "toml",
|
||||
"tsx", "typescript", "vim", "vue", "yaml"
|
||||
"json", "latex", "lua", "markdown", "nix", "python", "rust", "svelte",
|
||||
"toml", "tsx", "typescript", "vim", "vue", "yaml"
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue