home: vim: move LSP-related 'on_attach' to 'utils'
As it will be shared between `null-ls` and `lspconfig`, it makes sense to put it there.
This commit is contained in:
parent
9dc910eae3
commit
53d84b884d
|
@ -14,4 +14,19 @@ M.is_executable_condition = function(cmd)
|
|||
return function() return M.is_executable(cmd) end
|
||||
end
|
||||
|
||||
-- shared LSP configuration callback
|
||||
-- @param client native client configuration
|
||||
-- @param bufnr int? buffer number of the attched client
|
||||
M.on_attach = function(client, bufnr)
|
||||
-- Format on save
|
||||
if client.resolved_capabilities.document_formatting then
|
||||
vim.cmd([[
|
||||
augroup LspFormatting
|
||||
autocmd! * <buffer>
|
||||
autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()
|
||||
augroup END
|
||||
]])
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
@ -3,17 +3,7 @@ local null_ls = require("null-ls")
|
|||
local utils = require("ambroisie.utils")
|
||||
|
||||
null_ls.setup({
|
||||
on_attach = function(client)
|
||||
-- Format on save
|
||||
if client.resolved_capabilities.document_formatting then
|
||||
vim.cmd([[
|
||||
augroup LspFormatting
|
||||
autocmd! * <buffer>
|
||||
autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()
|
||||
augroup END
|
||||
]])
|
||||
end
|
||||
end,
|
||||
on_attach = utils.on_attach,
|
||||
})
|
||||
|
||||
-- C, C++
|
||||
|
|
Loading…
Reference in a new issue