lua format
This commit is contained in:
@@ -9,7 +9,7 @@ capabilities.textDocument.completion.completionItem.labelDetailsSupport = true
|
||||
capabilities.textDocument.completion.completionItem.deprecatedSupport = true
|
||||
capabilities.textDocument.completion.completionItem.commitCharactersSupport = true
|
||||
capabilities.textDocument.completion.completionItem.tagSupport = { valueSet = { 1 } }
|
||||
capabilities.offsetEncoding = { "utf-16" }
|
||||
capabilities.offsetEncoding = { 'utf-16' }
|
||||
capabilities.textDocument.completion.completionItem.resolveSupport = {
|
||||
properties = {
|
||||
'documentation',
|
||||
@@ -19,14 +19,18 @@ capabilities.textDocument.completion.completionItem.resolveSupport = {
|
||||
}
|
||||
|
||||
local on_attach = function(client, bufnr)
|
||||
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
|
||||
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
||||
local function buf_set_keymap(...)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, ...)
|
||||
end
|
||||
local function buf_set_option(...)
|
||||
vim.api.nvim_buf_set_option(bufnr, ...)
|
||||
end
|
||||
|
||||
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
vim.api.nvim_buf_set_option(0, 'formatexpr', 'v:lua.vim.lsp.formatexpr()')
|
||||
|
||||
-- Mappings.
|
||||
local opts = { noremap=true, silent=true }
|
||||
local opts = { noremap = true, silent = true }
|
||||
buf_set_keymap('n', '<space>,', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>;', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>a', '<cmd>Telescope lsp_code_actions<CR>', opts)
|
||||
@@ -47,7 +51,7 @@ local on_attach = function(client, bufnr)
|
||||
buf_set_keymap('n', '<space>v', '<cmd>Telescope diagnostics bufnr=0<cr>', opts)
|
||||
buf_set_keymap('n', '<A-o>', ':ClangdSwitchSourceHeader<CR>', opts)
|
||||
|
||||
vim.cmd [[autocmd CursorHold <buffer> lua vim.diagnostic.open_float({focusable = false})]]
|
||||
vim.cmd([[autocmd CursorHold <buffer> lua vim.diagnostic.open_float({focusable = false})]])
|
||||
|
||||
-- Set some keybinds conditional on server capabilities
|
||||
if client.resolved_capabilities.document_formatting then
|
||||
@@ -59,7 +63,8 @@ local on_attach = function(client, bufnr)
|
||||
|
||||
-- Set autocommands conditional on server_capabilities
|
||||
if client.resolved_capabilities.document_highlight then
|
||||
vim.api.nvim_exec([[
|
||||
vim.api.nvim_exec(
|
||||
[[
|
||||
hi LspReferenceRead cterm=bold ctermbg=red guibg=DarkGreen
|
||||
hi LspReferenceWrite cterm=bold ctermbg=red guibg=DarkRed
|
||||
augroup lsp_document_highlight
|
||||
@@ -68,34 +73,36 @@ local on_attach = function(client, bufnr)
|
||||
autocmd CursorHoldI <buffer> lua vim.lsp.buf.document_highlight()
|
||||
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
|
||||
augroup END
|
||||
]], false)
|
||||
]],
|
||||
false
|
||||
)
|
||||
end
|
||||
require "lsp_signature".on_attach({
|
||||
bind = true, -- This is mandatory, otherwise border config won't get registered.
|
||||
handler_opts = {
|
||||
border = "single"
|
||||
},
|
||||
hi_parameter = "IncSearch"
|
||||
}, bufnr)
|
||||
require('lsp_signature').on_attach({
|
||||
bind = true, -- This is mandatory, otherwise border config won't get registered.
|
||||
handler_opts = {
|
||||
border = 'single',
|
||||
},
|
||||
hi_parameter = 'IncSearch',
|
||||
}, bufnr)
|
||||
end
|
||||
|
||||
local lsp_installer = require("nvim-lsp-installer")
|
||||
local lsp_installer = require('nvim-lsp-installer')
|
||||
|
||||
local servers = {
|
||||
"pyright",
|
||||
"cmake",
|
||||
"clangd",
|
||||
"jsonls",
|
||||
"groovyls",
|
||||
"sumneko_lua",
|
||||
"dockerls",
|
||||
'pyright',
|
||||
'cmake',
|
||||
'clangd',
|
||||
'jsonls',
|
||||
'groovyls',
|
||||
'sumneko_lua',
|
||||
'dockerls',
|
||||
}
|
||||
|
||||
for _, name in pairs(servers) do
|
||||
local server_is_found, server = lsp_installer.get_server(name)
|
||||
if server_is_found then
|
||||
if not server:is_installed() then
|
||||
print("Installing " .. name)
|
||||
print('Installing ' .. name)
|
||||
server:install()
|
||||
end
|
||||
end
|
||||
@@ -107,18 +114,18 @@ lsp_installer.on_server_ready(function(server)
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
-- (optional) Customize the options passed to the server
|
||||
if server.name == "clangd" then
|
||||
opts.cmd = { "clangd" , "--compile-commands-dir=build_nvim"}
|
||||
end
|
||||
-- (optional) Customize the options passed to the server
|
||||
if server.name == 'clangd' then
|
||||
opts.cmd = { 'clangd', '--compile-commands-dir=build_nvim' }
|
||||
end
|
||||
|
||||
-- This setup() function is exactly the same as lspconfig's setup function (:help lspconfig-quickstart)
|
||||
server:setup(opts)
|
||||
vim.cmd [[ do User LspAttachBuffers ]]
|
||||
-- This setup() function is exactly the same as lspconfig's setup function (:help lspconfig-quickstart)
|
||||
server:setup(opts)
|
||||
vim.cmd([[ do User LspAttachBuffers ]])
|
||||
end)
|
||||
|
||||
local null_ls = require("null-ls")
|
||||
null_ls.setup {
|
||||
local null_ls = require('null-ls')
|
||||
null_ls.setup({
|
||||
sources = {
|
||||
null_ls.builtins.code_actions.gitsigns,
|
||||
null_ls.builtins.formatting.autopep8,
|
||||
@@ -126,9 +133,9 @@ null_ls.setup {
|
||||
null_ls.builtins.formatting.stylua,
|
||||
null_ls.builtins.diagnostics.flake8,
|
||||
null_ls.builtins.formatting.isort,
|
||||
null_ls.builtins.formatting.cmake_format
|
||||
null_ls.builtins.formatting.cmake_format,
|
||||
},
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities
|
||||
}
|
||||
vim.diagnostic.config({virtual_text = false})
|
||||
capabilities = capabilities,
|
||||
})
|
||||
vim.diagnostic.config({ virtual_text = false })
|
||||
|
||||
Reference in New Issue
Block a user