From 2b6ae8473e1b0fb8cc0bd16aa8c485a77ee5e847 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Tue, 16 Mar 2021 21:54:42 +0100 Subject: renaming, treesitter buggy --- .config/nvim/lua/_lsp/bash-ls.lua | 2 + .config/nvim/lua/_lsp/docker-ls.lua | 2 + .config/nvim/lua/_lsp/general.lua | 15 +++++ .config/nvim/lua/_lsp/init.lua | 19 ++++++ .config/nvim/lua/_lsp/json-ls.lua | 10 +++ .config/nvim/lua/_lsp/lua-ls.lua | 37 +++++++++++ .config/nvim/lua/_lsp/python-ls.lua | 2 + .config/nvim/lua/_lsp/vim.lua | 2 + .config/nvim/lua/_lsp/wrapper.lua | 129 ++++++++++++++++++++++++++++++++++++ .config/nvim/lua/_lsp/yaml-ls.lua | 2 + 10 files changed, 220 insertions(+) create mode 100644 .config/nvim/lua/_lsp/bash-ls.lua create mode 100644 .config/nvim/lua/_lsp/docker-ls.lua create mode 100644 .config/nvim/lua/_lsp/general.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/vim.lua create mode 100644 .config/nvim/lua/_lsp/wrapper.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..8be0383 --- /dev/null +++ b/.config/nvim/lua/_lsp/bash-ls.lua @@ -0,0 +1,2 @@ +-- npm i -g bash-language-server +require'lspconfig'.bashls.setup{} diff --git a/.config/nvim/lua/_lsp/docker-ls.lua b/.config/nvim/lua/_lsp/docker-ls.lua new file mode 100644 index 0000000..ad6e220 --- /dev/null +++ b/.config/nvim/lua/_lsp/docker-ls.lua @@ -0,0 +1,2 @@ +-- npm install -g dockerfile-language-server-nodejs +require'lspconfig'.dockerls.setup{} diff --git a/.config/nvim/lua/_lsp/general.lua b/.config/nvim/lua/_lsp/general.lua new file mode 100644 index 0000000..fa28dbc --- /dev/null +++ b/.config/nvim/lua/_lsp/general.lua @@ -0,0 +1,15 @@ +require"lspconfig".efm.setup { + init_options = {documentFormatting = true}, + filetypes = {"lua"}, + settings = { + rootMarkers = {".git/"}, + languages = { + lua = { + { + formatCommand = "lua-format -i --no-keep-simple-function-one-line --no-break-after-operator --column-limit=150 --break-after-table-lb", + formatStdin = true + } + } + } + } +} diff --git a/.config/nvim/lua/_lsp/init.lua b/.config/nvim/lua/_lsp/init.lua new file mode 100644 index 0000000..4515e7c --- /dev/null +++ b/.config/nvim/lua/_lsp/init.lua @@ -0,0 +1,19 @@ +--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("LspDiagnosticsSignInformation", {texthl = "LspDiagnosticsSignInformation", text = "", numhl = "LspDiagnosticsSignInformation"}) +vim.fn.sign_define("LspDiagnosticsSignHint", {texthl = "LspDiagnosticsSignHint", text = "", numhl = "LspDiagnosticsSignHint"}) + +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 hover_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)') diff --git a/.config/nvim/lua/_lsp/json-ls.lua b/.config/nvim/lua/_lsp/json-ls.lua new file mode 100644 index 0000000..d13fed3 --- /dev/null +++ b/.config/nvim/lua/_lsp/json-ls.lua @@ -0,0 +1,10 @@ +-- npm install -g vscode-json-languageserver +require'lspconfig'.jsonls.setup { + 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..c04219a --- /dev/null +++ b/.config/nvim/lua/_lsp/lua-ls.lua @@ -0,0 +1,37 @@ +-- https://github.com/sumneko/lua-language-server/wiki/Build-and-Run-(Standalone) +USER = vim.fn.expand('$USER') + +local sumneko_root_path = "" +local sumneko_binary = "" + +if vim.fn.has("mac") == 1 then + sumneko_root_path = "/Users/" .. USER .. "/.config/nvim/lua-language-server" + sumneko_binary = "/Users/" .. USER .. "/.config/nvim/lua-language-server/bin/macOS/lua-language-server" +elseif vim.fn.has("unix") == 1 then + sumneko_root_path = "/home/" .. USER .. "/.config/nvim/lua-language-server" + sumneko_binary = "/home/" .. USER .. "/.config/nvim/lua-language-server/bin/Linux/lua-language-server" +else + print("Unsupported system for sumneko") +end + +require'lspconfig'.sumneko_lua.setup { + cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"}, + 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} + } + } + } +} diff --git a/.config/nvim/lua/_lsp/python-ls.lua b/.config/nvim/lua/_lsp/python-ls.lua new file mode 100644 index 0000000..11eeef9 --- /dev/null +++ b/.config/nvim/lua/_lsp/python-ls.lua @@ -0,0 +1,2 @@ +-- npm i -g pyright +require'lspconfig'.pyright.setup{} diff --git a/.config/nvim/lua/_lsp/vim.lua b/.config/nvim/lua/_lsp/vim.lua new file mode 100644 index 0000000..a7555c6 --- /dev/null +++ b/.config/nvim/lua/_lsp/vim.lua @@ -0,0 +1,2 @@ +-- npm install -g vim-language-server +require'lspconfig'.vimls.setup{} diff --git a/.config/nvim/lua/_lsp/wrapper.lua b/.config/nvim/lua/_lsp/wrapper.lua new file mode 100644 index 0000000..7f3647c --- /dev/null +++ b/.config/nvim/lua/_lsp/wrapper.lua @@ -0,0 +1,129 @@ +local lsp_wrapper = {} + +-- buf + +function lsp_wrapper.add_to_workspace_folder() + vim.lsp.buf.add_workspace_folder() +end + +function lsp_wrapper.clear_references() + vim.lsp.buf.clear_references() +end + +function lsp_wrapper.code_action() + vim.lsp.buf.code_action() +end + +function lsp_wrapper.declaration() + vim.lsp.buf.declaration() + vim.lsp.buf.clear_references() +end + +function lsp_wrapper.definition() + vim.lsp.buf.definition() + vim.lsp.buf.clear_references() +end + +function lsp_wrapper.document_highlight() + vim.lsp.buf.document_highlight() +end + +function lsp_wrapper.document_symbol() + vim.lsp.buf.document_symbol() +end + +function lsp_wrapper.formatting() + vim.lsp.buf.formatting() +end + +function lsp_wrapper.formatting_sync() + vim.lsp.buf.formatting_sync() +end + +function lsp_wrapper.hover() + vim.lsp.buf.hover() +end + +function lsp_wrapper.implementation() + vim.lsp.buf.implementation() +end + +function lsp_wrapper.incoming_calls() + vim.lsp.buf.incoming_calls() +end + +function lsp_wrapper.list_workspace_folders() + vim.lsp.buf.list_workspace_folders() +end + +function lsp_wrapper.outgoing_calls() + vim.lsp.buf.outgoing_calls() +end + +function lsp_wrapper.range_code_action() + vim.lsp.buf.range_code_action() +end + +function lsp_wrapper.range_formatting() + vim.lsp.buf.range_formatting() +end + +function lsp_wrapper.references() + vim.lsp.buf.references() + vim.lsp.buf.clear_references() +end + +function lsp_wrapper.remove_workspace_folder() + vim.lsp.buf.remove_workspace_folder() +end + +function lsp_wrapper.rename() + vim.lsp.buf.rename() +end + +function lsp_wrapper.signature_help() + vim.lsp.buf.signature_help() +end + +function lsp_wrapper.type_definition() + vim.lsp.buf.type_definition() +end + +function lsp_wrapper.workspace_symbol() + vim.lsp.buf.workspace_symbol() +end + +-- diagnostic + +function lsp_wrapper.get_all() + vim.lsp.diagnostic.get_all() +end + +function lsp_wrapper.get_next() + vim.lsp.diagnostic.get_next() +end + +function lsp_wrapper.get_prev() + vim.lsp.diagnostic.get_prev() +end + +function lsp_wrapper.goto_next() + vim.lsp.diagnostic.goto_next() +end + +function lsp_wrapper.goto_prev() + vim.lsp.diagnostic.goto_prev() +end + +function lsp_wrapper.show_line_diagnostics() + vim.lsp.diagnostic.show_line_diagnostics() +end + +-- misc + +-- :lua print(vim.inspect(vim.lsp.buf_get_clients())) + +-- autoformat +-- autocmd BufWritePre *.rs lua vim.lsp.buf.formatting_sync(nil, 1000) + +return lsp_wrapper diff --git a/.config/nvim/lua/_lsp/yaml-ls.lua b/.config/nvim/lua/_lsp/yaml-ls.lua new file mode 100644 index 0000000..904f20e --- /dev/null +++ b/.config/nvim/lua/_lsp/yaml-ls.lua @@ -0,0 +1,2 @@ +-- npm install -g yaml-language-server +require'lspconfig'.yamlls.setup{} -- cgit v1.2.3-70-g09d2