mirror of
https://codeberg.org/Mo8it/dotfiles.git
synced 2024-12-27 01:01:05 +00:00
Upgrade lsp to Nvim 0.7 api and add sqlfluff
This commit is contained in:
parent
006a6cae26
commit
91dacbe386
1 changed files with 24 additions and 9 deletions
|
@ -5,15 +5,22 @@ capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities)
|
|||
local lspconfig = require("lspconfig")
|
||||
|
||||
-- Enable some language servers with the additional completion capabilities offered by nvim-cmp
|
||||
local formatting_augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
|
||||
local function format_on_save(client)
|
||||
if client.resolved_capabilities.document_formatting then
|
||||
vim.cmd([[
|
||||
augroup LspFormatting
|
||||
autocmd! * <buffer>
|
||||
autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync(nil, 60000)
|
||||
augroup END
|
||||
]])
|
||||
local function format_on_save(client, bufnr)
|
||||
if client.supports_method("textDocument/formatting") then
|
||||
vim.api.nvim_clear_autocmds({
|
||||
group = formatting_augroup,
|
||||
buffer = bufnr,
|
||||
})
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = formatting_augroup,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
-- NOTE: On 0.8, use vim.lsp.buf.format({ bufnr = bufnr }) instead
|
||||
vim.lsp.buf.formatting_sync(nil, 60000)
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -41,7 +48,7 @@ lspconfig["pylsp"].setup({
|
|||
|
||||
local function on_attach_with_formatting(client, bufnr)
|
||||
lsp_signature.on_attach(lsp_signature_config)
|
||||
format_on_save(client)
|
||||
format_on_save(client, bufnr)
|
||||
end
|
||||
|
||||
lspconfig["julials"].setup({
|
||||
|
@ -68,6 +75,14 @@ null_ls.setup({
|
|||
null_ls.builtins.formatting.shellharden,
|
||||
null_ls.builtins.formatting.shfmt,
|
||||
null_ls.builtins.formatting.taplo,
|
||||
null_ls.builtins.formatting.sqlfluff.with({
|
||||
extra_args = {
|
||||
"--dialect",
|
||||
"sqlite",
|
||||
"--exclude-rules",
|
||||
"L004,L013,L014,L016,L020,L021,L029,L031,L032,L033,L042,L059",
|
||||
},
|
||||
}),
|
||||
},
|
||||
on_attach = format_on_save,
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue