1
0
Fork 0
mirror of https://codeberg.org/Mo8it/dotfiles.git synced 2024-12-30 19:03:44 +00:00

Upgrade lsp to Nvim 0.7 api and add sqlfluff

This commit is contained in:
Mo 2022-05-12 13:33:59 +02:00
parent 006a6cae26
commit 91dacbe386

View file

@ -5,15 +5,22 @@ capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities)
local lspconfig = require("lspconfig") local lspconfig = require("lspconfig")
-- Enable some language servers with the additional completion capabilities offered by nvim-cmp -- 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) local function format_on_save(client, bufnr)
if client.resolved_capabilities.document_formatting then if client.supports_method("textDocument/formatting") then
vim.cmd([[ vim.api.nvim_clear_autocmds({
augroup LspFormatting group = formatting_augroup,
autocmd! * <buffer> buffer = bufnr,
autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync(nil, 60000) })
augroup END 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
end end
@ -41,7 +48,7 @@ lspconfig["pylsp"].setup({
local function on_attach_with_formatting(client, bufnr) local function on_attach_with_formatting(client, bufnr)
lsp_signature.on_attach(lsp_signature_config) lsp_signature.on_attach(lsp_signature_config)
format_on_save(client) format_on_save(client, bufnr)
end end
lspconfig["julials"].setup({ lspconfig["julials"].setup({
@ -68,6 +75,14 @@ null_ls.setup({
null_ls.builtins.formatting.shellharden, null_ls.builtins.formatting.shellharden,
null_ls.builtins.formatting.shfmt, null_ls.builtins.formatting.shfmt,
null_ls.builtins.formatting.taplo, 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, on_attach = format_on_save,
}) })