fix: update to resolve nvim breaking changes, format + server_capabilities
This commit is contained in:
parent
95568785f4
commit
2bcc3069d6
2 changed files with 8 additions and 6 deletions
|
@ -9,5 +9,5 @@ vim.cmd([[
|
||||||
command! CosmicUpdate lua require('cosmic.utils').update()
|
command! CosmicUpdate lua require('cosmic.utils').update()
|
||||||
command! CosmicReload lua require('cosmic.utils').reload_user_config(true)
|
command! CosmicReload lua require('cosmic.utils').reload_user_config(true)
|
||||||
command! CosmicReloadSync lua require('cosmic.utils').reload_user_config_sync()
|
command! CosmicReloadSync lua require('cosmic.utils').reload_user_config_sync()
|
||||||
command! LspFormat lua vim.lsp.buf.formatting()
|
command! LspFormat lua vim.lsp.buf.format()
|
||||||
]])
|
]])
|
||||||
|
|
|
@ -14,8 +14,8 @@ function M.on_attach(client, bufnr)
|
||||||
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||||
|
|
||||||
if config.lsp.can_client_format(client.name) then
|
if config.lsp.can_client_format(client.name) then
|
||||||
client.resolved_capabilities.document_formatting = true
|
client.server_capabilities.documentFormatting = true
|
||||||
client.resolved_capabilities.document_range_formatting = true
|
client.server_capabilities.documentRangeFormatting = true
|
||||||
-- check user config to see if we can format on save
|
-- check user config to see if we can format on save
|
||||||
if config.lsp.format_on_save and not auto_format_lock then
|
if config.lsp.format_on_save and not auto_format_lock then
|
||||||
auto_format_lock = true -- just run autocommand once
|
auto_format_lock = true -- just run autocommand once
|
||||||
|
@ -30,15 +30,17 @@ function M.on_attach(client, bufnr)
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd(string.format('BufWritePre %s', format_filetypes), {
|
vim.api.nvim_create_autocmd(string.format('BufWritePre %s', format_filetypes), {
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.lsp.buf.formatting_sync(nil, config.lsp.format_timeout)
|
vim.lsp.buf.format({
|
||||||
|
timeout_ms = config.lsp.format_timeout,
|
||||||
|
})
|
||||||
end,
|
end,
|
||||||
group = group,
|
group = group,
|
||||||
nested = true,
|
nested = true,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
client.resolved_capabilities.document_formatting = false
|
client.server_capabilities.documentFormatting = false
|
||||||
client.resolved_capabilities.document_range_formatting = false
|
client.server_capabilities.documentRangeFormatting = false
|
||||||
end
|
end
|
||||||
|
|
||||||
require('cosmic.lsp.mappings').init(client, bufnr)
|
require('cosmic.lsp.mappings').init(client, bufnr)
|
||||||
|
|
Loading…
Add table
Reference in a new issue