From 855f4e4f0f22b35641f13614e46b9ab7f6818188 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Mon, 15 Mar 2021 23:26:50 +0100 Subject: Migration to lua --- .config/nvim/lua/lsp/bash-ls.lua | 2 ++ .config/nvim/lua/lsp/bash.lua | 2 -- .config/nvim/lua/lsp/docker-ls.lua | 2 ++ .config/nvim/lua/lsp/docker.lua | 2 -- .config/nvim/lua/lsp/init.lua | 19 +++++++++++++++++++ .config/nvim/lua/lsp/json-ls.lua | 10 ++++++++++ .config/nvim/lua/lsp/json.lua | 10 ---------- .config/nvim/lua/lsp/lsp-config.lua | 4 ---- .config/nvim/lua/lsp/lsp-kind.lua | 26 -------------------------- .config/nvim/lua/lsp/lua-ls.lua | 37 +++++++++++++++++++++++++++++++++++++ .config/nvim/lua/lsp/lua.lua | 37 ------------------------------------- .config/nvim/lua/lsp/python-ls.lua | 2 ++ .config/nvim/lua/lsp/python.lua | 2 -- .config/nvim/lua/lsp/yaml-ls.lua | 2 ++ .config/nvim/lua/lsp/yaml.lua | 2 -- 15 files changed, 74 insertions(+), 85 deletions(-) create mode 100644 .config/nvim/lua/lsp/bash-ls.lua delete mode 100644 .config/nvim/lua/lsp/bash.lua create mode 100644 .config/nvim/lua/lsp/docker-ls.lua delete mode 100644 .config/nvim/lua/lsp/docker.lua create mode 100644 .config/nvim/lua/lsp/init.lua create mode 100644 .config/nvim/lua/lsp/json-ls.lua delete mode 100644 .config/nvim/lua/lsp/json.lua delete mode 100644 .config/nvim/lua/lsp/lsp-config.lua delete mode 100644 .config/nvim/lua/lsp/lsp-kind.lua create mode 100644 .config/nvim/lua/lsp/lua-ls.lua delete mode 100644 .config/nvim/lua/lsp/lua.lua create mode 100644 .config/nvim/lua/lsp/python-ls.lua delete mode 100644 .config/nvim/lua/lsp/python.lua create mode 100644 .config/nvim/lua/lsp/yaml-ls.lua delete mode 100644 .config/nvim/lua/lsp/yaml.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/bash.lua b/.config/nvim/lua/lsp/bash.lua deleted file mode 100644 index 8be0383..0000000 --- a/.config/nvim/lua/lsp/bash.lua +++ /dev/null @@ -1,2 +0,0 @@ --- 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/docker.lua b/.config/nvim/lua/lsp/docker.lua deleted file mode 100644 index ad6e220..0000000 --- a/.config/nvim/lua/lsp/docker.lua +++ /dev/null @@ -1,2 +0,0 @@ --- npm install -g dockerfile-language-server-nodejs -require'lspconfig'.dockerls.setup{} 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/json.lua b/.config/nvim/lua/lsp/json.lua deleted file mode 100644 index d13fed3..0000000 --- a/.config/nvim/lua/lsp/json.lua +++ /dev/null @@ -1,10 +0,0 @@ --- 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/lsp-config.lua b/.config/nvim/lua/lsp/lsp-config.lua deleted file mode 100644 index fe5dfb7..0000000 --- a/.config/nvim/lua/lsp/lsp-config.lua +++ /dev/null @@ -1,4 +0,0 @@ -vim.fn.sign_define("LspDiagnosticsSignError", {text = "", numhl = "LspDiagnosticsDefaultError"}) -vim.fn.sign_define("LspDiagnosticsSignWarning", {text = "", numhl = "LspDiagnosticsDefaultWarning"}) -vim.fn.sign_define("LspDiagnosticsSignInformation", {text = "", numhl = "LspDiagnosticsDefaultInformation"}) -vim.fn.sign_define("LspDiagnosticsSignHint", {text = "", numhl = "LspDiagnosticsDefaultHint"}) diff --git a/.config/nvim/lua/lsp/lsp-kind.lua b/.config/nvim/lua/lsp/lsp-kind.lua deleted file mode 100644 index de928c2..0000000 --- a/.config/nvim/lua/lsp/lsp-kind.lua +++ /dev/null @@ -1,26 +0,0 @@ --- commented options are defaults -require('lspkind').init({ - with_text = false, - symbol_map = { - Text = '  ', - Method = '  ', - Function = '  ', - Constructor = '  ', - Variable = '[]', - Class = '  ', - Interface = ' 蘒', - Module = '  ', - Property = '  ', - Unit = ' 塞 ', - Value = '  ', - Enum = ' 練', - Keyword = '  ', - Snippet = '  ', - Color = '', - File = '', - Folder = ' ﱮ ', - EnumMember = '  ', - Constant = '  ', - Struct = '  ' - }, -}) 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/lua.lua b/.config/nvim/lua/lsp/lua.lua deleted file mode 100644 index c04219a..0000000 --- a/.config/nvim/lua/lsp/lua.lua +++ /dev/null @@ -1,37 +0,0 @@ --- 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/python.lua b/.config/nvim/lua/lsp/python.lua deleted file mode 100644 index 11eeef9..0000000 --- a/.config/nvim/lua/lsp/python.lua +++ /dev/null @@ -1,2 +0,0 @@ --- npm i -g pyright -require'lspconfig'.pyright.setup{} 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{} diff --git a/.config/nvim/lua/lsp/yaml.lua b/.config/nvim/lua/lsp/yaml.lua deleted file mode 100644 index 904f20e..0000000 --- a/.config/nvim/lua/lsp/yaml.lua +++ /dev/null @@ -1,2 +0,0 @@ --- npm install -g yaml-language-server -require'lspconfig'.yamlls.setup{} -- cgit v1.2.3-70-g09d2