feat(config): move format to better place
This commit is contained in:
parent
aa32ac00b9
commit
cd5cee0342
3 changed files with 11 additions and 12 deletions
|
@ -1,4 +1,3 @@
|
||||||
local config = require('cosmic.config')
|
|
||||||
require('cosmic.lsp.providers')
|
require('cosmic.lsp.providers')
|
||||||
require('cosmic.lsp.diagnostics').init()
|
require('cosmic.lsp.diagnostics').init()
|
||||||
|
|
||||||
|
@ -7,8 +6,3 @@ vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, {
|
||||||
border = 'single',
|
border = 'single',
|
||||||
})
|
})
|
||||||
|
|
||||||
if config.lsp and config.lsp.format_on_save then
|
|
||||||
vim.cmd([[
|
|
||||||
autocmd BufWritePre * lua vim.lsp.buf.formatting()
|
|
||||||
]])
|
|
||||||
end
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
local config = require('cosmic.config')
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
function M.on_attach(client, bufnr)
|
function M.on_attach(client, bufnr)
|
||||||
|
@ -12,6 +13,12 @@ function M.on_attach(client, bufnr)
|
||||||
if vim.tbl_contains(formatting_servers, client.name) then
|
if vim.tbl_contains(formatting_servers, client.name) then
|
||||||
client.resolved_capabilities.document_formatting = true
|
client.resolved_capabilities.document_formatting = true
|
||||||
client.resolved_capabilities.document_range_formatting = true
|
client.resolved_capabilities.document_range_formatting = true
|
||||||
|
if config.lsp and config.lsp.format_on_save then
|
||||||
|
-- todo: don't run more than once
|
||||||
|
vim.cmd([[
|
||||||
|
autocmd BufWritePre * lua vim.lsp.buf.formatting()
|
||||||
|
]])
|
||||||
|
end
|
||||||
else
|
else
|
||||||
client.resolved_capabilities.document_formatting = false
|
client.resolved_capabilities.document_formatting = false
|
||||||
client.resolved_capabilities.document_range_formatting = false
|
client.resolved_capabilities.document_range_formatting = false
|
||||||
|
|
|
@ -44,13 +44,11 @@ end
|
||||||
|
|
||||||
-- go through requested_servers and ensure installation
|
-- go through requested_servers and ensure installation
|
||||||
local lsp_installer_servers = require('nvim-lsp-installer.servers')
|
local lsp_installer_servers = require('nvim-lsp-installer.servers')
|
||||||
for server in pairs(requested_servers) do
|
for _, requested_server in pairs(requested_servers) do
|
||||||
local requested_server = requested_servers[server]
|
local ok, server = lsp_installer_servers.get_server(requested_server)
|
||||||
|
|
||||||
local ok, serv = lsp_installer_servers.get_server(requested_server)
|
|
||||||
if ok then
|
if ok then
|
||||||
if not serv:is_installed() then
|
if not server:is_installed() then
|
||||||
serv:install()
|
server:install()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue