added keybindings

This commit is contained in:
Rahsheen Porter 2022-11-07 17:33:59 -05:00
parent 0f401d28e1
commit b1a7860fdd
5 changed files with 189 additions and 95 deletions

View file

@ -1,6 +1,6 @@
local setup, null_ls = pcall(require, "null-ls")
if not setup then
return
return
end
local formatting = null_ls.builtins.formatting
@ -8,24 +8,24 @@ local diagnostics = null_ls.builtins.diagnostics
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
null_ls.setup({
sources = {
formatting.prettier,
formatting.stylua,
diagnostics.eslint_d
},
-- format on save
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
vim.lsp.buf.format({ bufnr = bufnr })
end,
})
end
end,
sources = {
formatting.prettier,
formatting.stylua,
diagnostics.eslint_d,
diagnostics.rubocop,
},
-- format on save
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
vim.lsp.buf.format({ bufnr = bufnr })
end,
})
end
end,
})