From 69347ce034f8966579e72dc969ec808363fdfaeb Mon Sep 17 00:00:00 2001 From: aktersnurra Date: Mon, 19 Apr 2021 21:45:03 +0200 Subject: Add missing files of nvim conf --- .config/nvim/lua/lsp/bash-ls.lua | 6 +++ .config/nvim/lua/lsp/clangd.lua | 13 +++++ .config/nvim/lua/lsp/docker-ls.lua | 6 +++ .config/nvim/lua/lsp/emmet-ls.lua | 19 +++++++ .config/nvim/lua/lsp/init.lua | 103 +++++++++++++++++++++++++++++++++++++ .config/nvim/lua/lsp/json-ls.lua | 16 ++++++ .config/nvim/lua/lsp/lua-ls.lua | 27 ++++++++++ .config/nvim/lua/lsp/python-ls.lua | 14 +++++ .config/nvim/lua/lsp/rust-ls.lua | 4 ++ .config/nvim/lua/lsp/vim-ls.lua | 5 ++ .config/nvim/lua/lsp/yaml-ls.lua | 5 ++ 11 files changed, 218 insertions(+) create mode 100644 .config/nvim/lua/lsp/bash-ls.lua create mode 100644 .config/nvim/lua/lsp/clangd.lua create mode 100644 .config/nvim/lua/lsp/docker-ls.lua create mode 100644 .config/nvim/lua/lsp/emmet-ls.lua create mode 100644 .config/nvim/lua/lsp/init.lua create mode 100644 .config/nvim/lua/lsp/json-ls.lua create mode 100644 .config/nvim/lua/lsp/lua-ls.lua create mode 100644 .config/nvim/lua/lsp/python-ls.lua create mode 100644 .config/nvim/lua/lsp/rust-ls.lua create mode 100644 .config/nvim/lua/lsp/vim-ls.lua create mode 100644 .config/nvim/lua/lsp/yaml-ls.lua (limited to '.config/nvim/lua/lsp') diff --git a/.config/nvim/lua/lsp/bash-ls.lua b/.config/nvim/lua/lsp/bash-ls.lua new file mode 100644 index 0000000..7b430a6 --- /dev/null +++ b/.config/nvim/lua/lsp/bash-ls.lua @@ -0,0 +1,6 @@ +-- npm i -g bash-language-server +require'lspconfig'.bashls.setup { + cmd = {DATA_PATH .. "/lspinstall/bash/node_modules/.bin/bash-language-server", "start"}, + on_attach = require'lsp'.common_on_attach, + filetypes = { "sh", "zsh" } +} diff --git a/.config/nvim/lua/lsp/clangd.lua b/.config/nvim/lua/lsp/clangd.lua new file mode 100644 index 0000000..dbbda08 --- /dev/null +++ b/.config/nvim/lua/lsp/clangd.lua @@ -0,0 +1,13 @@ +require'lspconfig'.clangd.setup { + cmd = {DATA_PATH .. "/lspinstall/cpp/clangd/bin/clangd"}, + on_attach = require'lsp'.common_on_attach, + handlers = { + ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { + virtual_text = O.clang.diagnostics.virtual_text, + signs = O.clang.diagnostics.signs, + underline = O.clang.diagnostics.underline, + update_in_insert = true + + }) + } +} diff --git a/.config/nvim/lua/lsp/docker-ls.lua b/.config/nvim/lua/lsp/docker-ls.lua new file mode 100644 index 0000000..b477a23 --- /dev/null +++ b/.config/nvim/lua/lsp/docker-ls.lua @@ -0,0 +1,6 @@ +-- npm install -g dockerfile-language-server-nodejs +require'lspconfig'.dockerls.setup { + cmd = {DATA_PATH .. "/lspinstall/dockerfile/node_modules/.bin/docker-langserver", "--stdio"}, + on_attach = require'lsp'.common_on_attach, + root_dir = vim.loop.cwd +} diff --git a/.config/nvim/lua/lsp/emmet-ls.lua b/.config/nvim/lua/lsp/emmet-ls.lua new file mode 100644 index 0000000..6531ccf --- /dev/null +++ b/.config/nvim/lua/lsp/emmet-ls.lua @@ -0,0 +1,19 @@ +local nvim_lsp = require'lspconfig' +local configs = require'lspconfig/configs' +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities.textDocument.completion.completionItem.snippetSupport = true + +configs.emmet_ls = { + default_config = { + cmd = {'emmet-ls', '--stdio'}; + filetypes = {'html', 'css'}; + root_dir = function() + return vim.loop.cwd() + end; + settings = {}; + }; +} + +nvim_lsp.emmet_ls.setup{ + -- on_attach = on_attach; +} diff --git a/.config/nvim/lua/lsp/init.lua b/.config/nvim/lua/lsp/init.lua new file mode 100644 index 0000000..4488b52 --- /dev/null +++ b/.config/nvim/lua/lsp/init.lua @@ -0,0 +1,103 @@ +-- TODO figure out why this don't work +vim.fn.sign_define( + "LspDiagnosticsSignError", + {texthl = "LspDiagnosticsSignError", text = "", numhl = "LspDiagnosticsSignError"} +) +vim.fn.sign_define( + "LspDiagnosticsSignWarning", + {texthl = "LspDiagnosticsSignWarning", text = "", numhl = "LspDiagnosticsSignWarning"} +) +vim.fn.sign_define( + "LspDiagnosticsSignHint", + {texthl = "LspDiagnosticsSignHint", text = "", numhl = "LspDiagnosticsSignHint"} +) +vim.fn.sign_define( + "LspDiagnosticsSignInformation", + {texthl = "LspDiagnosticsSignInformation", text = "", numhl = "LspDiagnosticsSignInformation"} +) + +vim.cmd("nnoremap gd lua vim.lsp.buf.definition()") +vim.cmd("nnoremap gD lua vim.lsp.buf.declaration()") +vim.cmd("nnoremap gr lua vim.lsp.buf.references()") +vim.cmd("nnoremap gi lua vim.lsp.buf.implementation()") +vim.cmd("nnoremap ca :Lspsaga code_action") +vim.cmd("nnoremap K :Lspsaga hoer_doc") +-- vim.cmd('nnoremap lua vim.lsp.buf.signature_help()') +vim.cmd("nnoremap :Lspsaga diagnostic_jump_prev") +vim.cmd("nnoremap :Lspsaga diagnostic_jump_next") +-- scroll down hover doc or scroll in definition preview +vim.cmd("nnoremap lua require('lspsaga.action').smart_scroll_with_saga(1)") +-- scroll up hover doc +vim.cmd("nnoremap lua require('lspsaga.action').smart_scroll_with_saga(-1)") +vim.cmd('command! -nargs=0 LspVirtualTextToggle lua require("lsp/virtual_text").toggle()') + +-- symbols for autocomplete +vim.lsp.protocol.CompletionItemKind = { + "  (Text) ", + "  (Method)", + "  (Function)", + "  (Constructor)", + " ﴲ (Field)", + "[] (Variable)", + "  (Class)", + " ﰮ (Interface)", + "  (Module)", + " 襁 (Property)", + "  (Unit)", + "  (Value)", + " 練 (Enum)", + "  (Keyword)", + " ﬌ (Snippet)", + "  (Color)", + "  (File)", + "  (Reference)", + "  (Folder)", + "  (EnumMember)", + " ﲀ (Constant)", + " ﳤ (Struct)", + "  (Event)", + "  (Operator)", + "  (TypeParameter)" +} + +--[[ " autoformat +autocmd BufWritePre *.js lua vim.lsp.buf.formatting_sync(nil, 100) +autocmd BufWritePre *.jsx lua vim.lsp.buf.formatting_sync(nil, 100) +autocmd BufWritePre *.lua lua vim.lsp.buf.formatting_sync(nil, 100) ]] +-- Java +-- autocmd FileType java nnoremap ca lua require('jdtls').code_action() + +local function documentHighlight(client, bufnr) + -- Set autocommands conditional on server_capabilities + if client.resolved_capabilities.document_highlight then + vim.api.nvim_exec( + [[ + hi LspReferenceRead cterm=bold ctermbg=red guibg=#464646 + hi LspReferenceText cterm=bold ctermbg=red guibg=#464646 + hi LspReferenceWrite cterm=bold ctermbg=red guibg=#464646 + augroup lsp_document_highlight + autocmd! * + autocmd CursorHold lua vim.lsp.buf.document_highlight() + autocmd CursorMoved lua vim.lsp.buf.clear_references() + augroup END + ]], + false + ) + end +end +local lsp_config = {} + +function lsp_config.common_on_attach(client, bufnr) + documentHighlight(client, bufnr) +end + +function lsp_config.tsserver_on_attach(client, bufnr) + lsp_config.common_on_attach(client, bufnr) + client.resolved_capabilities.document_formatting = false +end + +-- Use a loop to conveniently both setup defined servers +-- and map buffer local keybindings when the language server attaches +-- local servers = {"pyright", "tsserver"} +-- for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup {on_attach = on_attach} end +return lsp_configv diff --git a/.config/nvim/lua/lsp/json-ls.lua b/.config/nvim/lua/lsp/json-ls.lua new file mode 100644 index 0000000..952673a --- /dev/null +++ b/.config/nvim/lua/lsp/json-ls.lua @@ -0,0 +1,16 @@ +-- npm install -g vscode-json-languageserver +require'lspconfig'.jsonls.setup { + cmd = { + "node", DATA_PATH .. "/lspinstall/json/vscode-json/json-language-features/server/dist/node/jsonServerMain.js", + "--stdio" + }, + on_attach = require'lsp'.common_on_attach, + + commands = { + Format = { + function() + vim.lsp.buf.range_formatting({}, {0, 0}, {vim.fn.line("$"), 0}) + end + } + } +} diff --git a/.config/nvim/lua/lsp/lua-ls.lua b/.config/nvim/lua/lsp/lua-ls.lua new file mode 100644 index 0000000..d640bc4 --- /dev/null +++ b/.config/nvim/lua/lsp/lua-ls.lua @@ -0,0 +1,27 @@ +-- https://github.com/sumneko/lua-language-server/wiki/Build-and-Run-(Standalone) +local sumneko_root_path = DATA_PATH .. "/lspinstall/lua" +local sumneko_binary = sumneko_root_path .. "/sumneko-lua-language-server" + +require'lspconfig'.sumneko_lua.setup { + cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"}, + on_attach = require'lsp'.common_on_attach, + settings = { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT', + -- Setup your lua path + path = vim.split(package.path, ';') + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = {'vim'} + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = {[vim.fn.expand('$VIMRUNTIME/lua')] = true, [vim.fn.expand($VIMRUNTIME/lua/vim/lsp')] = true}, + maxPreload = 10000 + } + } + } +} diff --git a/.config/nvim/lua/lsp/python-ls.lua b/.config/nvim/lua/lsp/python-ls.lua new file mode 100644 index 0000000..8cc8b22 --- /dev/null +++ b/.config/nvim/lua/lsp/python-ls.lua @@ -0,0 +1,14 @@ +-- npm i -g pyright +require'lspconfig'.pyright.setup { + cmd = {DATA_PATH .. "/lspinstall/python/node_modules/.bin/pyright-langserver", "--stdio"}, + on_attach = require'lsp'.common_on_attach, + handlers = { + ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { + virtual_text = O.python.diagnostics.virtual_text, + signs = O.python.diagnostics.signs, + underline = O.python.diagnostics.underline, + update_in_insert = true + + }) + } +} diff --git a/.config/nvim/lua/lsp/rust-ls.lua b/.config/nvim/lua/lsp/rust-ls.lua new file mode 100644 index 0000000..896c693 --- /dev/null +++ b/.config/nvim/lua/lsp/rust-ls.lua @@ -0,0 +1,4 @@ +require'lspconfig'.rust_analyzer.setup{ + cmd = {DATA_PATH .. "/lspinstall/rust/rust-analyzer"}, + on_attach = require'lsp'.common_on_attach +} diff --git a/.config/nvim/lua/lsp/vim-ls.lua b/.config/nvim/lua/lsp/vim-ls.lua new file mode 100644 index 0000000..39beb11 --- /dev/null +++ b/.config/nvim/lua/lsp/vim-ls.lua @@ -0,0 +1,5 @@ +-- npm install -g vim-language-server +require'lspconfig'.vimls.setup { + cmd = {DATA_PATH .. "/lspinstall/vim/node_modules/.bin/vim-language-server", "--stdio"}, + on_attach = require'lsp'.common_on_attach +} diff --git a/.config/nvim/lua/lsp/yaml-ls.lua b/.config/nvim/lua/lsp/yaml-ls.lua new file mode 100644 index 0000000..3fbc41e --- /dev/null +++ b/.config/nvim/lua/lsp/yaml-ls.lua @@ -0,0 +1,5 @@ +-- npm install -g yaml-language-server +require'lspconfig'.yamlls.setup{ + cmd = {DATA_PATH .. "/lspinstall/yaml/node_modules/.bin/yaml-language-server", "--stdio"}, + on_attach = require'lsp'.common_on_attach, +} -- cgit v1.2.3-70-g09d2