fix: update neovim configs
This commit is contained in:
@@ -9,8 +9,4 @@ local M = {
|
||||
},
|
||||
}
|
||||
|
||||
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
|
||||
command = "FormatWriteLock",
|
||||
})
|
||||
|
||||
return M
|
||||
|
||||
@@ -1,48 +1,50 @@
|
||||
local config = require("plugins.configs.lspconfig")
|
||||
local on_attach = config.on_attach
|
||||
local capabilities = config.capabilities
|
||||
local lspconfig = require("lspconfig")
|
||||
|
||||
local function organize_imports()
|
||||
local params = {
|
||||
command = "_typescript.organizeImports",
|
||||
arguments = { vim.api.nvim_buf_get_name(0) },
|
||||
}
|
||||
vim.lsp.buf.execute_command(params)
|
||||
local custom_on_attach = function(client, bufnr)
|
||||
on_attach(client, bufnr)
|
||||
|
||||
if client.name == "ts_ls" then
|
||||
vim.api.nvim_buf_create_user_command(bufnr, "OrganizeImports", function()
|
||||
local params = {
|
||||
command = "_typescript.organizeImports",
|
||||
arguments = { vim.api.nvim_buf_get_name(0) },
|
||||
}
|
||||
vim.lsp.buf.execute_command(params)
|
||||
end, { desc = "Organize Imports" })
|
||||
end
|
||||
end
|
||||
|
||||
lspconfig.ts_ls.setup {
|
||||
on_attach = on_attach,
|
||||
vim.lsp.config("ts_ls", {
|
||||
on_attach = custom_on_attach,
|
||||
capabilities = capabilities,
|
||||
init_options = {
|
||||
preferences = {
|
||||
disablesuggestions = true,
|
||||
}
|
||||
},
|
||||
commands = {
|
||||
OrganizeImports = {
|
||||
organize_imports,
|
||||
description = "Organize Imports",
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
vim.lsp.enable("ts_ls")
|
||||
|
||||
lspconfig.terraformls.setup {
|
||||
vim.lsp.config("terraformls", {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
})
|
||||
vim.lsp.enable("terraformls")
|
||||
|
||||
lspconfig.tflint.setup {
|
||||
vim.lsp.config("tflint", {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
})
|
||||
vim.lsp.enable("tflint")
|
||||
|
||||
lspconfig.gopls.setup {
|
||||
vim.lsp.config("gopls", {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
cmd = { "gopls" },
|
||||
filetypes = { "go", "gomod", "gowork", "gotempl" },
|
||||
root_dir = lspconfig.util.root_pattern("go.mod", "go.work"),
|
||||
root_markers = { "go.mod", "go.work" },
|
||||
settings = {
|
||||
gopls = {
|
||||
completeUnimported = true,
|
||||
@@ -52,20 +54,19 @@ lspconfig.gopls.setup {
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
})
|
||||
vim.lsp.enable("gopls")
|
||||
|
||||
lspconfig.pyright.setup {
|
||||
vim.lsp.config("pyright", {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
filetypes = { "python" },
|
||||
}
|
||||
})
|
||||
vim.lsp.enable("pyright")
|
||||
|
||||
lspconfig.gleam.setup({})
|
||||
|
||||
lspconfig.nil_ls.setup {
|
||||
vim.lsp.config("nil_ls", {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
autostart = true,
|
||||
cmd = { "nil" },
|
||||
filetypes = { "nix" },
|
||||
settings = {
|
||||
@@ -76,4 +77,5 @@ lspconfig.nil_ls.setup {
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
})
|
||||
vim.lsp.enable("nil_ls")
|
||||
@@ -1,28 +0,0 @@
|
||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
local null_ls = require("null-ls")
|
||||
|
||||
local opts = {
|
||||
sources = {
|
||||
null_ls.builtins.formatting.black,
|
||||
null_ls.builtins.diagnostics.mypy,
|
||||
null_ls.builtins.diagnostics.ruff,
|
||||
},
|
||||
on_attach = function(client, bufnr)
|
||||
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.format({ bufnr = bufnr })
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
return opts
|
||||
@@ -3,7 +3,7 @@ vim.opt.colorcolumn = "80"
|
||||
vim.g.copilot_no_tab_map = true
|
||||
vim.api.nvim_set_keymap("i", "<C-o>", 'copilot#Accept("<CR>")', { silent = true, expr = true, noremap = true, script = true })
|
||||
vim.wo.relativenumber = true
|
||||
vim.g.scrolloff = 8
|
||||
vim.opt.scrolloff = 8
|
||||
|
||||
-- Auto-reload files when changed externally
|
||||
vim.opt.autoread = true
|
||||
|
||||
@@ -27,12 +27,6 @@ M['rust-tools'] = {
|
||||
|
||||
M.dap = {
|
||||
n = {
|
||||
["<leader>dl"] = {
|
||||
function ()
|
||||
require("dap")
|
||||
end,
|
||||
"Load DAP",
|
||||
},
|
||||
["<leader>dt"] = {
|
||||
"<cmd> DapToggleBreakpoint <CR>",
|
||||
"Toggle breakpoint",
|
||||
@@ -61,25 +55,6 @@ M.dap_python = {
|
||||
}
|
||||
}
|
||||
|
||||
M.dap_go = {
|
||||
plugin = true,
|
||||
|
||||
n = {
|
||||
["<leader>gdt"] = {
|
||||
function ()
|
||||
require("dap-go").debug_test()
|
||||
end,
|
||||
"Debug go test",
|
||||
},
|
||||
["<leader>gdl"] = {
|
||||
function ()
|
||||
require("dap-go").debug_last()
|
||||
end,
|
||||
"Toggle breakpoint",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
M.lazygit = {
|
||||
n = {
|
||||
["<leader>gg"] = {
|
||||
@@ -142,19 +117,6 @@ M.worktree = {
|
||||
},
|
||||
}
|
||||
|
||||
M.neorg = {
|
||||
n = {
|
||||
["<leader>ni"] = {
|
||||
"<cmd> Neorg index <CR>",
|
||||
"Neorg index",
|
||||
},
|
||||
["<leader>nr"] = {
|
||||
"<cmd> Neorg return <CR>",
|
||||
"Return from index",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
M.general = {
|
||||
n = {
|
||||
["<C-q>"] = {
|
||||
|
||||
@@ -13,7 +13,7 @@ local plugins = {
|
||||
"rcarriga/nvim-dap-ui",
|
||||
"nvim-neotest/nvim-nio",
|
||||
},
|
||||
config = function (_, opts)
|
||||
config = function (_, _)
|
||||
local path = "~/.local/share/nvim/mason/packages/debugpy/venv/bin/python"
|
||||
require("dap-python").setup(path)
|
||||
end
|
||||
@@ -53,13 +53,6 @@ local plugins = {
|
||||
{
|
||||
"ThePrimeagen/git-worktree.nvim",
|
||||
},
|
||||
{
|
||||
"jose-elias-alvarez/null-ls.nvim",
|
||||
ft = { "python" },
|
||||
config = function ()
|
||||
require "custom.configs.null-ls"
|
||||
end,
|
||||
},
|
||||
{
|
||||
"folke/noice.nvim",
|
||||
event = "VeryLazy",
|
||||
|
||||
@@ -40,11 +40,10 @@ M.capabilities.textDocument.completion.completionItem = {
|
||||
},
|
||||
}
|
||||
|
||||
require("lspconfig").lua_ls.setup {
|
||||
vim.lsp.config("lua_ls", {
|
||||
on_init = M.on_init,
|
||||
on_attach = M.on_attach,
|
||||
capabilities = M.capabilities,
|
||||
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
@@ -62,6 +61,7 @@ require("lspconfig").lua_ls.setup {
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
})
|
||||
vim.lsp.enable("lua_ls")
|
||||
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user