update
This commit is contained in:
2
plugin-confs/lsp-format.lua
Normal file
2
plugin-confs/lsp-format.lua
Normal file
@@ -0,0 +1,2 @@
|
||||
require("lsp-format").setup {}
|
||||
require("lspconfig").gopls.setup { on_attach = require("lsp-format").on_attach }
|
||||
@@ -1,27 +1,46 @@
|
||||
local null_ls = require("null-ls")
|
||||
local helpers = require("null-ls.helpers")
|
||||
-- syncronous formatting
|
||||
-- local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
-- require("null-ls").setup({
|
||||
-- -- you can reuse a shared lspconfig on_attach callback here
|
||||
-- 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()
|
||||
-- -- on 0.8, you should use vim.lsp.buf.format({ bufnr = bufnr }) instead
|
||||
-- -- on later neovim version, you should use vim.lsp.buf.format({ async = false }) instead
|
||||
-- vim.lsp.buf.formatting_sync()
|
||||
-- end,
|
||||
-- })
|
||||
-- end
|
||||
-- end,
|
||||
-- })
|
||||
|
||||
require("null-ls").setup({
|
||||
on_attach = function(client)
|
||||
if client.supports_method "textDocument/formatting" then
|
||||
vim.cmd([[
|
||||
augroup LspFormatting
|
||||
autocmd! * <buffer>
|
||||
autocmd BufWritePre <buffer> lua vim.lsp.buf.format()
|
||||
augroup END
|
||||
]])
|
||||
end
|
||||
end,
|
||||
null_ls.setup({
|
||||
-- on_attach = function(client)
|
||||
-- if client.supports_method "textDocument/formatting" then
|
||||
-- vim.cmd([[
|
||||
-- augroup LspFormatting
|
||||
-- autocmd! * <buffer>
|
||||
-- autocmd BufWritePre <buffer> lua vim.lsp.buf.format()
|
||||
-- augroup END
|
||||
-- ]])
|
||||
-- end
|
||||
-- end,
|
||||
sources = {
|
||||
-- null_ls.builtins.completion.spell,
|
||||
null_ls.builtins.completion.luasnip,
|
||||
-- null_ls.builtins.code_actions.gitsigns,
|
||||
null_ls.builtins.code_actions.shellcheck,
|
||||
null_ls.builtins.code_actions.eslint, null_ls.builtins.diagnostics.tsc,
|
||||
-- null_ls.builtins.code_actions.eslint,
|
||||
null_ls.builtins.diagnostics.tsc,
|
||||
null_ls.builtins.diagnostics.cppcheck,
|
||||
null_ls.builtins.diagnostics.gitlint,
|
||||
null_ls.builtins.diagnostics.eslint
|
||||
.with({ cmd = "eslint-language-server" }),
|
||||
-- null_ls.builtins.diagnostics.eslint
|
||||
-- .with({ cmd = "/usr/bin/eslint-language-server" }),
|
||||
null_ls.builtins.diagnostics.jsonlint,
|
||||
require("null-ls").builtins.diagnostics.luacheck,
|
||||
null_ls.builtins.diagnostics.markdownlint,
|
||||
@@ -30,20 +49,30 @@ require("null-ls").setup({
|
||||
-- "--dialect", "oracle"
|
||||
-- }
|
||||
-- }),
|
||||
null_ls.builtins.formatting.sql_formatter,
|
||||
null_ls.builtins.diagnostics.pylint, null_ls.builtins.diagnostics.mypy,
|
||||
-- null_ls.builtins.formatting.sql_formatter,
|
||||
null_ls.builtins.diagnostics.pylint,
|
||||
-- null_ls.builtins.diagnostics.pylint.with({
|
||||
-- diagnostics_postprocess = function(diagnostic)
|
||||
-- diagnostic.code = diagnostic.message_id
|
||||
-- end,
|
||||
-- }),
|
||||
null_ls.builtins.diagnostics.mypy,
|
||||
null_ls.builtins.diagnostics.pycodestyle,
|
||||
null_ls.builtins.diagnostics.pydocstyle.with({
|
||||
extra_args = { "--config=$ROOT/setup.cfg" }
|
||||
}), null_ls.builtins.diagnostics.vint,
|
||||
null_ls.builtins.diagnostics.shellcheck.with({
|
||||
extra_args = {
|
||||
"-s", "bash", "-o",
|
||||
"add-default-case, check-set-e-suppressed, check-unassigned-uppercase, deprecate-which, quote-safe-variables"
|
||||
}
|
||||
}), null_ls.builtins.diagnostics.ansiblelint,
|
||||
-- null_ls.builtins.diagnostics.pydocstyle.with({
|
||||
-- extra_args = { "--config=$ROOT/setup.cfg" }
|
||||
-- }),
|
||||
null_ls.builtins.diagnostics.vint,
|
||||
-- null_ls.builtins.code_actions.shellcheck,
|
||||
-- null_ls.builtins.diagnostics.shellcheck.with({
|
||||
-- extra_args = {
|
||||
-- "-s", "bash", "-o",
|
||||
-- "add-default-case, check-set-e-suppressed, check-unassigned-uppercase, deprecate-which, quote-safe-variables"
|
||||
-- }
|
||||
-- }),
|
||||
null_ls.builtins.diagnostics.ansiblelint,
|
||||
null_ls.builtins.formatting.json_tool,
|
||||
require("null-ls").builtins.formatting.lua_format,
|
||||
null_ls.builtins.formatting.stylua,
|
||||
null_ls.builtins.formatting.markdownlint,
|
||||
null_ls.builtins.formatting.prettier, -- handled by lsp server
|
||||
-- require("null-ls").builtins.formatting.rustfmt,
|
||||
@@ -51,7 +80,8 @@ require("null-ls").setup({
|
||||
filetypes = { "sh", "bash" },
|
||||
extra_args = { "-i", "0", "-ci", "-sr" }
|
||||
}), null_ls.builtins.formatting.black,
|
||||
null_ls.builtins.formatting.isort, null_ls.builtins.formatting.djlint
|
||||
null_ls.builtins.formatting.isort, null_ls.builtins.formatting.djlint,
|
||||
null_ls.builtins.diagnostics.actionlint,
|
||||
-- null_ls.builtins.hover.printenv
|
||||
-- null_ls.builtins.formatting.tidy
|
||||
}
|
||||
|
||||
@@ -221,40 +221,46 @@ local servers = {
|
||||
for _, lsp in ipairs(servers) do
|
||||
if lsp == 'lua_ls' then
|
||||
lspconfig[lsp].setup {
|
||||
-- on_attach = my_custom_on_attach,
|
||||
-- on_attach = highlight_symbol_under_cursor(),
|
||||
capabilities = capabilities,
|
||||
callSnippet = "Replace",
|
||||
settings = {
|
||||
Lua = {
|
||||
on_attach = require("lsp-format").on_attach,
|
||||
on_init = function(client)
|
||||
if client.workspace_folders then
|
||||
local path = client.workspace_folders[1].name
|
||||
if path ~= vim.fn.stdpath('config') and (vim.loop.fs_stat(path..'/.luarc.json') or vim.loop.fs_stat(path..'/.luarc.jsonc')) then
|
||||
return
|
||||
end
|
||||
end
|
||||
client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
|
||||
runtime = {
|
||||
version = 'Lua 5.4',
|
||||
path = {
|
||||
'?.lua', '?/init.lua',
|
||||
-- vim.fn.expand '~/.luarocks/share/lua/5.4/?.lua',
|
||||
-- vim.fn.expand '~/.luarocks/share/lua/5.4/?/init.lua',
|
||||
'/usr/share/5.3/?.lua',
|
||||
'/usr/share/lua/5.3/?/init.lua',
|
||||
'/usr/share/5.4/?.lua',
|
||||
'/usr/share/lua/5.4/?/init.lua'
|
||||
}
|
||||
-- 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 = {
|
||||
library = {
|
||||
-- vim.fn.expand '~/.luarocks/share/lua/5.3',
|
||||
'/usr/share/lua/5.1', '/usr/share/lua/5.3',
|
||||
'/usr/share/lua/5.4'
|
||||
}
|
||||
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 and will cause issues when working on your own configuration (see https://github.com/neovim/nvim-lspconfig/issues/3189)
|
||||
-- library = vim.api.nvim_get_runtime_file("", true)
|
||||
}
|
||||
})
|
||||
end,
|
||||
capabilities = capabilities,
|
||||
callSnippet = "Replace",
|
||||
settings = {
|
||||
Lua = {}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
lspconfig[lsp].setup { capabilities = capabilities }
|
||||
lspconfig[lsp].setup { on_attach = require("lsp-format").on_attach, capabilities = capabilities }
|
||||
end
|
||||
end
|
||||
|
||||
cmp.event:on("menu_opened",
|
||||
function() vim.b.copilot_suggestion_hidden = true end)
|
||||
cmp.event:on("menu_closed",
|
||||
function() vim.b.copilot_suggestion_hidden = false end)
|
||||
-- cmp.event:on("menu_opened",
|
||||
-- function() vim.b.copilot_suggestion_hidden = true end)
|
||||
-- cmp.event:on("menu_closed",
|
||||
-- function() vim.b.copilot_suggestion_hidden = false end)
|
||||
|
||||
Reference in New Issue
Block a user