🔧 Major overhaul of nvim config
This commit is contained in:
parent
351ce052a7
commit
5e7afd99ec
38 changed files with 1091 additions and 87 deletions
|
|
@ -22,6 +22,7 @@ require("conform").setup({
|
|||
format_on_save = {
|
||||
-- These options will be passed to conform.format()
|
||||
timeout_ms = 500,
|
||||
async = false,
|
||||
lsp_format = "fallback",
|
||||
},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
require("dap-vscode-js").setup({
|
||||
adapaters = { "pwa-node", "pwa-chrome", "pwa-msedge", "node-terminal", "pwa-extensionHost" },
|
||||
})
|
||||
|
||||
local languages = { "typescript", "javascript" }
|
||||
for _, language in ipairs(languages) do
|
||||
require("dap").configurations[language] = {
|
||||
{
|
||||
type = "pwa-node",
|
||||
request = "launch",
|
||||
name = "Launch file",
|
||||
program = "${file}",
|
||||
cwd = "${workspaceFolder}",
|
||||
},
|
||||
{
|
||||
type = "pwa-node",
|
||||
request = "attach",
|
||||
name = "Attach",
|
||||
processId = require("dap.utils").pick_process,
|
||||
cwd = "${workspaceFolder}",
|
||||
},
|
||||
{
|
||||
type = "pwa-chrome",
|
||||
request = "launch",
|
||||
name = 'Start Chrome with "localhost"',
|
||||
url = "http://localhost:3000",
|
||||
webRoot = "${workspaceFolder}",
|
||||
userDataDir = "${workspaceFolder}/.vscode/vscode-chrome-debug-userdatadir",
|
||||
},
|
||||
}
|
||||
end
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
require("dapui").setup()
|
||||
|
||||
local dap, dapui = require("dap"), require("dapui")
|
||||
|
||||
dap.listeners.after.event_initialized["dapui_config"] = function()
|
||||
dapui.open({})
|
||||
end
|
||||
dap.listeners.before.event_terminated["dapui_config"] = function()
|
||||
dapui.close({})
|
||||
end
|
||||
dap.listeners.before.event_exited["dapui_config"] = function()
|
||||
dapui.close({})
|
||||
end
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
local lsp = require("lsp-zero")
|
||||
local lspconfig = require("lspconfig")
|
||||
local cmp = require("cmp")
|
||||
lsp.preset("recommended")
|
||||
require("mason").setup()
|
||||
|
||||
lsp.ensure_installed({
|
||||
-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md
|
||||
local servers = {
|
||||
"bashls",
|
||||
"biome",
|
||||
"clangd",
|
||||
|
|
@ -12,14 +12,24 @@ lsp.ensure_installed({
|
|||
"dockerls",
|
||||
"emmet_ls",
|
||||
"eslint",
|
||||
"html",
|
||||
"gopls",
|
||||
"jqls",
|
||||
"lua_ls",
|
||||
"pyright",
|
||||
"quick_lint_js",
|
||||
"rust_analyzer",
|
||||
"stylelint_lsp",
|
||||
"svelte",
|
||||
"ts_ls",
|
||||
"volar",
|
||||
"zls",
|
||||
}
|
||||
|
||||
for _, server in ipairs(servers) do
|
||||
lspconfig[server].setup({})
|
||||
end
|
||||
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = servers,
|
||||
})
|
||||
|
||||
cmp.setup({
|
||||
|
|
@ -27,16 +37,22 @@ cmp.setup({
|
|||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
})
|
||||
|
||||
lsp.set_preferences({
|
||||
suggest_lsp_servers = false,
|
||||
sign_icons = {
|
||||
error = "E",
|
||||
warn = "W",
|
||||
hint = "H",
|
||||
info = "I",
|
||||
},
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" },
|
||||
{ name = "buffer" },
|
||||
{ name = "path" },
|
||||
{ name = "vsnip" },
|
||||
}),
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<Up>"] = cmp.mapping.select_prev_item(),
|
||||
["<Down>"] = cmp.mapping.select_next_item(),
|
||||
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<C-e>"] = cmp.mapping.abort(),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
}),
|
||||
})
|
||||
|
||||
-- function that is used with keybinding cm to toggle autocompletion
|
||||
|
|
@ -76,42 +92,34 @@ vim.diagnostic.config({
|
|||
vim.keymap.set("n", "<space>e", "<cmd>lua vim.diagnostic.open_float()<CR>")
|
||||
|
||||
-- LSP Specific Settings
|
||||
-- Volar TypeScript Config (turn off for Vue with Vanilla JS)
|
||||
require("mason-lspconfig").setup_handlers({
|
||||
function(server_name)
|
||||
local server_config = {}
|
||||
if server_name == "volar" then
|
||||
server_config.filetypes = { "vue", "ts_ls", "javascript" }
|
||||
lspconfig.volar.setup({
|
||||
settings = {
|
||||
["volar.takeOverMode.enabled"] = true,
|
||||
},
|
||||
})
|
||||
end
|
||||
lspconfig.rust_analyzer.setup({
|
||||
settings = {
|
||||
["rust-analyzer"] = {
|
||||
procMacro = {
|
||||
ignored = {
|
||||
leptos_macro = {
|
||||
"server",
|
||||
},
|
||||
},
|
||||
},
|
||||
rustfmt = {
|
||||
overrideCommand = {
|
||||
"leptosfmt",
|
||||
"--stdin",
|
||||
"--rustfmt",
|
||||
},
|
||||
edition = { "2021" },
|
||||
},
|
||||
cargo = {
|
||||
allFeatures = true,
|
||||
},
|
||||
},
|
||||
-- require("mason-lspconfig").setup_handlers({}
|
||||
|
||||
-- Vue TypeScript Setup
|
||||
-- https://lsp-zero.netlify.app/blog/configure-volar-v2.html
|
||||
-- NOTE: Don't install volar through Mason, this is done manually:
|
||||
-- npm install -g @vue/language-server
|
||||
-- npm install -g @vue/typescript-plugin
|
||||
local vue_typescript_plugin = "/usr/lib/node_modules"
|
||||
.. "/usr/lib/node_modules/@vue/language-server"
|
||||
.. "/usr/lib/node_modules/@vue/typescript-plugin"
|
||||
|
||||
lspconfig.ts_ls.setup({
|
||||
init_options = {
|
||||
plugins = {
|
||||
{
|
||||
name = "@vue/typescript-plugin",
|
||||
location = vue_typescript_plugin,
|
||||
languages = { "javascript", "typescript", "vue" },
|
||||
},
|
||||
})
|
||||
lspconfig[server_name].setup(server_config)
|
||||
end,
|
||||
},
|
||||
},
|
||||
filetypes = {
|
||||
"javascript",
|
||||
"javascriptreact",
|
||||
"javascript.jsx",
|
||||
"typescript",
|
||||
"typescriptreact",
|
||||
"typescript.tsx",
|
||||
"vue",
|
||||
},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
local null_ls = require("null-ls")
|
||||
|
||||
local group = vim.api.nvim_create_augroup("lsp_format_on_save", { clear = false })
|
||||
local event = "BufWritePre" -- or "BufWritePost"
|
||||
local async = event == "BufWritePost"
|
||||
|
||||
null_ls.setup({
|
||||
on_attach = function(client, bufnr)
|
||||
if client.supports_method("textDocument/formatting") then
|
||||
vim.keymap.set("n", "<Leader>f", function()
|
||||
vim.lsp.buf.format({ bufnr = vim.api.nvim_get_current_buf() })
|
||||
end, { buffer = bufnr, desc = "[lsp] format" })
|
||||
|
||||
-- format on save
|
||||
vim.api.nvim_clear_autocmds({ buffer = bufnr, group = group })
|
||||
vim.api.nvim_create_autocmd(event, {
|
||||
buffer = bufnr,
|
||||
group = group,
|
||||
callback = function()
|
||||
vim.lsp.buf.format({ bufnr = bufnr, async = async })
|
||||
end,
|
||||
desc = "[lsp] format on save",
|
||||
})
|
||||
end
|
||||
|
||||
if client.supports_method("textDocument/rangeFormatting") then
|
||||
vim.keymap.set("x", "<Leader>f", function()
|
||||
vim.lsp.buf.format({ bufnr = vim.api.nvim_get_current_buf() })
|
||||
end, { buffer = bufnr, desc = "[lsp] format" })
|
||||
end
|
||||
end,
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue