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

27 lines
661 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)
if vim.b.nifoc_lsp_enabled == nil then
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)
if client.resolved_capabilities.document_formatting and vim.b.nifoc_fixer_enabled == nil then
vim.api.nvim_buf_set_var(bufnr, 'nifoc_fixer_enabled', 1)
vim.cmd [[
augroup nifoc_diagnostic_formatting
autocmd! * <buffer>
autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync(nil, 1000)
augroup end
]]
end
end
return M