154 lines
5.6 KiB
Lua
154 lines
5.6 KiB
Lua
vim.cmd [[
|
|
highlight LspDiagnosticsLineNrError guibg=#51202A guifg=#FF0000 gui=bold
|
|
highlight LspDiagnosticsLineNrWarning guibg=#51412A guifg=#FFA500 gui=bold
|
|
highlight LspDiagnosticsLineNrInformation guibg=#1E535D guifg=#00FFFF gui=bold
|
|
highlight LspDiagnosticsLineNrHint guibg=#1E205D guifg=#008bbd gui=bold
|
|
|
|
sign define LspDiagnosticsSignError text= texthl=LspDiagnosticsSignError linehl= numhl=LspDiagnosticsLineNrError
|
|
sign define LspDiagnosticsSignWarning text= texthl=LspDiagnosticsSignWarning linehl= numhl=LspDiagnosticsLineNrWarning
|
|
sign define LspDiagnosticsSignInformation text= texthl=LspDiagnosticsSignInformation linehl= numhl=LspDiagnosticsLineNrInformation
|
|
sign define LspDiagnosticsSignHint text= texthl=LspDiagnosticsSignHint linehl= numhl=LspDiagnosticsLineNrHint
|
|
]]
|
|
|
|
vim.lsp.handlers['textDocument/publishDiagnostics'] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
|
|
underline = true,
|
|
signs = true,
|
|
update_in_insert = true,
|
|
severity_sort = true,
|
|
virtual_text = {
|
|
spacing = 5,
|
|
severity_limit = 'Hint',
|
|
source = 'always',
|
|
},
|
|
})
|
|
|
|
local nvim_lsp = require'lspconfig'
|
|
local on_attach = function(client, bufnr)
|
|
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
|
local opts = { noremap = true, silent = true }
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '}d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'qq', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
|
vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]]
|
|
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
|
|
border = "single",
|
|
})
|
|
require "lsp_signature".on_attach({
|
|
bind = true,
|
|
hint_prefix = " ",
|
|
hi_parameter = "ModeMsg",
|
|
transparency = 80,
|
|
trigger_on_newline = false,
|
|
toggle_key = '<M-f>',
|
|
})
|
|
end
|
|
|
|
nvim_lsp.jsonls.setup {
|
|
commands = {
|
|
Format = {
|
|
function()
|
|
vim.lsp.buf.range_formatting({},{0,0},{vim.fn.line("$"),0})
|
|
end
|
|
}
|
|
}
|
|
}
|
|
|
|
require'lspconfig/configs'.ls_emmet = {
|
|
default_config = {
|
|
cmd = { 'ls_emmet', '--stdio' };
|
|
filetypes = { 'html', 'css', 'scss', 'javascript', 'javascriptreact', 'typescript', 'typescriptreact', 'haml',
|
|
'xml', 'xsl', 'pug', 'slim', 'sass', 'stylus', 'less', 'sss', 'svelte'};
|
|
root_dir = function(fname)
|
|
return vim.loop.cwd()
|
|
end;
|
|
settings = {};
|
|
};
|
|
}
|
|
|
|
local shellcheck = {
|
|
lintCommand = 'shellcheck -f gcc -x',
|
|
lintSource = "shellcheck",
|
|
lintFormats = {
|
|
'%f:%l:%c: %trror: %m',
|
|
'%f:%l:%c: %tarning: %m',
|
|
'%f:%l:%c: %tote: %m'
|
|
},
|
|
}
|
|
local shfmt = {
|
|
formatCommand = 'shfmt -ci -s -bn',
|
|
formatStdin = true,
|
|
}
|
|
|
|
nvim_lsp.efm.setup{
|
|
init_options = {
|
|
documentFormatting = true,
|
|
hover = true,
|
|
},
|
|
settings = {
|
|
rootMarkers = { "package.json", "go.mod", ".git/", ".zshrc" },
|
|
languages = {
|
|
bash = { shellcheck, shfmt },
|
|
sh = { shellcheck, shfmt },
|
|
},
|
|
filetypes = {'bash', 'sh'}
|
|
}
|
|
}
|
|
|
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
capabilities.textDocument.completion.completionItem.documentationFormat = { 'markdown', 'plaintext' }
|
|
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
|
capabilities.textDocument.completion.completionItem.preselectSupport = true
|
|
capabilities.textDocument.completion.completionItem.insertReplaceSupport = true
|
|
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.textDocument.completion.completionItem.resolveSupport = {
|
|
properties = { 'documentation', 'detail', 'additionalTextEdits', },
|
|
}
|
|
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
|
|
|
|
local servers = { 'html', 'cssls', 'gopls', 'jsonls', 'tailwindcss', 'vimls', 'ls_emmet' }
|
|
for _, lsp in ipairs(servers) do
|
|
nvim_lsp[lsp].setup {
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
flags = { debounce_text_changes = 150, }
|
|
}
|
|
end
|
|
|
|
local sumneko_root_path ='/mnt/wd1tb/catacombs/code/lua-language-server'
|
|
local sumneko_binary = sumneko_root_path .. '/bin/Linux/lua-language-server'
|
|
local runtime_path = vim.split(package.path, ';')
|
|
table.insert(runtime_path, 'lua/?.lua')
|
|
table.insert(runtime_path, 'lua/?/init.lua')
|
|
require('lspconfig').sumneko_lua.setup {
|
|
cmd = { sumneko_binary, '-E', sumneko_root_path .. '/main.lua' },
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
settings = {
|
|
Lua = {
|
|
runtime = {
|
|
version = 'LuaJIT',
|
|
path = runtime_path,
|
|
},
|
|
diagnostics = {
|
|
globals = {'vim'},
|
|
},
|
|
workspace = {
|
|
library = vim.api.nvim_get_runtime_file("", true),
|
|
},
|
|
telemetry = {
|
|
enable = false,
|
|
},
|
|
},
|
|
},
|
|
}
|