|
|
@ -1,6 +1,10 @@ |
|
|
|
local augroup = vim.api.nvim_create_augroup("Lspformatting", {}) |
|
|
|
local fmt_group = vim.api.nvim_create_augroup("Lspformatting", { clear = true }) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local on_attach = function(event) |
|
|
|
|
|
|
|
local id = vim.tbl_get(event, 'data', 'client_id') |
|
|
|
|
|
|
|
local client = id and vim.lsp.get_client_by_id(id) |
|
|
|
|
|
|
|
local bufnr = event.buf |
|
|
|
|
|
|
|
|
|
|
|
local on_attach = function(client, bufnr) |
|
|
|
|
|
|
|
if (not bufnr) then |
|
|
|
if (not bufnr) then |
|
|
|
return |
|
|
|
return |
|
|
|
end |
|
|
|
end |
|
|
@ -30,26 +34,43 @@ local on_attach = function(client, bufnr) |
|
|
|
|
|
|
|
|
|
|
|
-- format on save does not work for python for some reason |
|
|
|
-- format on save does not work for python for some reason |
|
|
|
if client.supports_method("textDocument/formatting") then |
|
|
|
if client.supports_method("textDocument/formatting") then |
|
|
|
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) |
|
|
|
vim.api.nvim_clear_autocmds({ group = fmt_group, buffer = bufnr }) |
|
|
|
vim.api.nvim_create_autocmd("BufWritePre", { |
|
|
|
vim.api.nvim_create_autocmd("BufWritePre", { |
|
|
|
group = augroup, |
|
|
|
group = fmt_group, |
|
|
|
buffer = bufnr, |
|
|
|
buffer = bufnr, |
|
|
|
callback = function() |
|
|
|
callback = function() |
|
|
|
vim.lsp.buf.format({ |
|
|
|
vim.lsp.buf.format({ |
|
|
|
async = false, |
|
|
|
async = false, |
|
|
|
bufnr = bufnr, |
|
|
|
bufnr = bufnr, |
|
|
|
|
|
|
|
timeout_ms = 10000, |
|
|
|
}) |
|
|
|
}) |
|
|
|
end |
|
|
|
end |
|
|
|
}) |
|
|
|
}) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vim.api.nvim_create_autocmd('LspAttach', { |
|
|
|
|
|
|
|
group = vim.api.nvim_create_augroup('LspAttachGroup', { clear = true }), |
|
|
|
|
|
|
|
callback = on_attach, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
local on_leave_group = vim.api.nvim_create_augroup("OnLeaveGroup", {}) |
|
|
|
local on_leave_group = vim.api.nvim_create_augroup("OnLeaveGroup", {}) |
|
|
|
vim.api.nvim_create_autocmd("VimLeave", { |
|
|
|
vim.api.nvim_create_autocmd("VimLeave", { |
|
|
|
group = on_leave_group, |
|
|
|
group = on_leave_group, |
|
|
|
command = "silent !killall -q eslint_d", |
|
|
|
command = "silent !killall -q eslint_d", |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vim.diagnostic.config({ |
|
|
|
|
|
|
|
signs = { |
|
|
|
|
|
|
|
text = { |
|
|
|
|
|
|
|
[vim.diagnostic.severity.ERROR] = '✘', |
|
|
|
|
|
|
|
[vim.diagnostic.severity.WARN] = '▲', |
|
|
|
|
|
|
|
[vim.diagnostic.severity.HINT] = '⚑', |
|
|
|
|
|
|
|
[vim.diagnostic.severity.INFO] = '»', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
-- virtual_text = true, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
{ |
|
|
|
{ |
|
|
@ -61,17 +82,18 @@ return { |
|
|
|
'j-hui/fidget.nvim', |
|
|
|
'j-hui/fidget.nvim', |
|
|
|
}, |
|
|
|
}, |
|
|
|
config = function() |
|
|
|
config = function() |
|
|
|
local lsp = require("lspconfig") |
|
|
|
local lspconfig_defaults = require('lspconfig').util.default_config |
|
|
|
local lspconfig_defaults = lsp.util.default_config |
|
|
|
local capabilities = vim.tbl_deep_extend( |
|
|
|
lspconfig_defaults.capabilities = vim.tbl_deep_extend( |
|
|
|
|
|
|
|
'force', |
|
|
|
'force', |
|
|
|
lspconfig_defaults.capabilities, |
|
|
|
lspconfig_defaults.capabilities, |
|
|
|
require('cmp_nvim_lsp').default_capabilities() |
|
|
|
require('cmp_nvim_lsp').default_capabilities() |
|
|
|
) |
|
|
|
) |
|
|
|
--local capabilities = require('cmp_nvim_lsp').default_capabilities() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lsp.lua_ls.setup({ |
|
|
|
vim.lsp.config('*', { |
|
|
|
on_attach = on_attach, |
|
|
|
capabilities = capabilities |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vim.lsp.config("lua_ls", { |
|
|
|
settings = { |
|
|
|
settings = { |
|
|
|
Lua = { |
|
|
|
Lua = { |
|
|
|
diagnostics = { |
|
|
|
diagnostics = { |
|
|
@ -81,25 +103,7 @@ return { |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
lsp.clangd.setup { on_attach = on_attach } |
|
|
|
vim.lsp.config("rust_analyzer", { |
|
|
|
lsp.ts_ls.setup { on_attach = on_attach } -- typescript |
|
|
|
|
|
|
|
lsp.hls.setup { on_attach = on_attach } -- haskell |
|
|
|
|
|
|
|
lsp.pyright.setup { on_attach = on_attach, |
|
|
|
|
|
|
|
settings = { |
|
|
|
|
|
|
|
pyright = { |
|
|
|
|
|
|
|
disableOrganizeImports = true, -- Using Ruff |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
python = { |
|
|
|
|
|
|
|
analysis = { |
|
|
|
|
|
|
|
ignore = { '*' }, -- Using Ruff |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
lsp.ruff.setup { on_attach = on_attach } |
|
|
|
|
|
|
|
lsp.svelte.setup { on_attach = on_attach } |
|
|
|
|
|
|
|
lsp.marksman.setup { on_attach = on_attach } |
|
|
|
|
|
|
|
lsp.rust_analyzer.setup { on_attach = on_attach, |
|
|
|
|
|
|
|
settings = { |
|
|
|
settings = { |
|
|
|
["rust-analyzer"] = { |
|
|
|
["rust-analyzer"] = { |
|
|
|
checkOnSave = true, |
|
|
|
checkOnSave = true, |
|
|
@ -110,24 +114,47 @@ return { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
lsp.tailwindcss.setup { on_attach = on_attach } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lsp.julials.setup { |
|
|
|
vim.lsp.config("julials", { |
|
|
|
on_new_config = function(new_config, _) |
|
|
|
on_new_config = function(new_config, _) |
|
|
|
local julia = vim.fn.expand("~/.julia/environments/nvim-lspconfig/bin/julia") |
|
|
|
local julia = vim.fn.expand("~/.julia/environments/nvim-lspconfig/bin/julia") |
|
|
|
if lsp.util.path.is_file(julia) then |
|
|
|
if require('lspconfig').util.path.is_file(julia) then |
|
|
|
vim.notify("running julials") |
|
|
|
vim.notify("running julials") |
|
|
|
new_config.cmd[1] = julia |
|
|
|
new_config.cmd[1] = julia |
|
|
|
end |
|
|
|
end |
|
|
|
end, |
|
|
|
end |
|
|
|
on_attach = on_attach |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
vim.lsp.config("pyright", { |
|
|
|
|
|
|
|
settings = { |
|
|
|
|
|
|
|
pyright = { |
|
|
|
|
|
|
|
disableOrganizeImports = true, -- Using Ruff |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
python = { |
|
|
|
|
|
|
|
analysis = { |
|
|
|
|
|
|
|
ignore = { '*' }, -- Using Ruff |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vim.lsp.enable({ "lua_ls", |
|
|
|
|
|
|
|
"clangd", |
|
|
|
|
|
|
|
"ts_ls", |
|
|
|
|
|
|
|
"hls", |
|
|
|
|
|
|
|
"ruff", |
|
|
|
|
|
|
|
"svelte", |
|
|
|
|
|
|
|
"marksman", |
|
|
|
|
|
|
|
"tailwindcss", |
|
|
|
|
|
|
|
"rust_analyzer", |
|
|
|
|
|
|
|
"julials", |
|
|
|
|
|
|
|
"pyright" |
|
|
|
|
|
|
|
}) |
|
|
|
end, |
|
|
|
end, |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
'nvimtools/none-ls.nvim', |
|
|
|
'nvimtools/none-ls.nvim', |
|
|
|
|
|
|
|
|
|
|
|
event = { "BufReadPre", "BufNewFile" }, |
|
|
|
event = { "BufReadPre", "BufNewFile" }, |
|
|
|
config = function() |
|
|
|
config = function() |
|
|
|
local null_ls = require("null-ls") |
|
|
|
local null_ls = require("null-ls") |
|
|
@ -147,7 +174,6 @@ return { |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
null_ls.setup { |
|
|
|
null_ls.setup { |
|
|
|
on_attach = on_attach, |
|
|
|
|
|
|
|
capabilities = capabilities, |
|
|
|
capabilities = capabilities, |
|
|
|
sources = { |
|
|
|
sources = { |
|
|
|
eslint_format, |
|
|
|
eslint_format, |
|
|
|