1
0
Fork 0
dotfiles/config/nvim/lua/nifoc/utils/diagnostic.lua

26 lines
751 B
Lua
Raw Normal View History

2021-12-18 22:55:56 +00:00
local M = {}
local keymap = require('nifoc.keymap')
function M.maybe_enable_lsp(client, bufnr)
2021-12-20 20:43:35 +00:00
if vim.b.nifoc_lsp_enabled == nil then
2021-12-18 22:55:56 +00:00
vim.api.nvim_buf_set_var(bufnr, 'nifoc_lsp_enabled', 1)
keymap.lsp_attach(client, bufnr)
end
end
function M.maybe_enable_fixer(client, bufnr)
2021-12-20 20:43:35 +00:00
if client.resolved_capabilities.document_formatting and vim.b.nifoc_fixer_enabled == nil then
2021-12-18 22:55:56 +00:00
vim.api.nvim_buf_set_var(bufnr, 'nifoc_fixer_enabled', 1)
2022-03-12 19:46:27 +00:00
local augroup_nifoc_diagnostic = vim.api.nvim_create_augroup("NifocDiagnostic", { clear = true })
vim.api.nvim_create_autocmd("BufWritePre", { callback = function()
vim.lsp.buf.formatting_sync(nil, 1000)
end, group = augroup_nifoc_diagnostic, buffer = bufnr })
2021-12-18 22:55:56 +00:00
end
end
return M