From 5773f66d14612f5dfdd38d34df4b16fdb2808723 Mon Sep 17 00:00:00 2001 From: ray-x Date: Fri, 4 Mar 2022 17:20:03 +1100 Subject: [PATCH] terraform updates --- README.md | 5 ++ lua/navigator/lspclient/clients.lua | 8 ++- playground/init_lsp_installer.lua | 86 +++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 playground/init_lsp_installer.lua diff --git a/README.md b/README.md index 76b4767..5d02957 100644 --- a/README.md +++ b/README.md @@ -544,6 +544,11 @@ require'navigator'.setup({ ``` +Use lsp_installer configs +You can delegate the lsp server setup to lsp_installer with `server:setup{opts}` +Here is an example [init_lsp_installer.lua](https://github.com/ray-x/navigator.lua/blob/master/playground/init_lsp_installer.lua) + + ## Usage Please refer to lua/navigator/lspclient/mapping.lua on key mappings. Should be able to work out-of-box. diff --git a/lua/navigator/lspclient/clients.lua b/lua/navigator/lspclient/clients.lua index 714675b..1f7eace 100644 --- a/lua/navigator/lspclient/clients.lua +++ b/lua/navigator/lspclient/clients.lua @@ -293,6 +293,9 @@ local setups = { omnisharp = { cmd = { 'omnisharp', '--languageserver', '--hostPID', tostring(vim.fn.getpid()) }, }, + terraformls = { + filetypes = { 'terraform', 'tf'}, + }, } setups.sumneko_lua = vim.tbl_deep_extend('force', luadev, setups.sumneko_lua) @@ -379,7 +382,9 @@ local function load_cfg(ft, client, cfg, loaded) end local lspft = lspconfig[client].document_config.default_config.filetypes + local additional_ft = setups[client] and setups[client].filetypes or {} local cmd = cfg.cmd + vim.list_extend(lspft, additional_ft) local should_load = false if lspft ~= nil and #lspft > 0 then @@ -703,6 +708,7 @@ local function setup(user_opts) 'defx', 'packer', 'gitcommit', + 'windline', } for i = 1, #disable_ft do if ft == disable_ft[i] or _LoadedFiletypes[ft] then @@ -721,7 +727,7 @@ local function setup(user_opts) local clients = vim.lsp.buf_get_clients(bufnr) for key, client in pairs(clients) do if client.name ~= "null_ls" and client.name ~= "efm" then - if vim.tbl_contains(client.filetypes, vim.o.ft) then + if vim.tbl_contains(client.filetypes or {}, vim.o.ft) then log('client already loaded', client.name) end end diff --git a/playground/init_lsp_installer.lua b/playground/init_lsp_installer.lua new file mode 100644 index 0000000..c8ffc04 --- /dev/null +++ b/playground/init_lsp_installer.lua @@ -0,0 +1,86 @@ +vim.cmd([[set runtimepath=$VIMRUNTIME]]) +vim.cmd([[set packpath=/tmp/nvim/site]]) + +local package_root = '/tmp/nvim/site/pack' +local install_path = package_root .. '/packer/start/packer.nvim' +vim.g.coq_settings = { + ['auto_start'] = 'shut-up', +} + +local function load_plugins() + require('packer').startup({ + function(use) + use('wbthomason/packer.nvim') + use('neovim/nvim-lspconfig') + use({ + 'williamboman/nvim-lsp-installer', + config = function() + local lsp_installer = require('nvim-lsp-installer') + local coq = require('coq') + + local enhance_server_opts = { + ['sumneko_lua'] = function(options) + options.settings = { + Lua = { + diagnostics = { + globals = { 'vim' }, + }, + }, + } + end, + ['tsserver'] = function(options) + options.on_attach = function(client) + client.resolved_capabilities.document_formatting = false + end + end, + } + + lsp_installer.on_server_ready(function(server) + local options = {} + + if enhance_server_opts[server.name] then + enhance_server_opts[server.name](options) + end + + server:setup(coq.lsp_ensure_capabilities(options)) + end) + end, + }) + use({ + 'ray-x/navigator.lua', + config = function() + require('navigator').setup({ + lsp_installer = true, + }) + end, + }) + use('ray-x/guihua.lua') + -- -- COQ (Autocompletion) + use('ms-jpq/coq_nvim') + use('ms-jpq/coq.artifacts') + use('ms-jpq/coq.thirdparty') + use('ray-x/aurora') + end, + config = { + package_root = package_root, + compile_path = install_path .. '/plugin/packer_compiled.lua', + }, + }) + -- navigator/LSP setup +end + +if vim.fn.isdirectory(install_path) == 0 then + print('install packer') + vim.fn.system({ + 'git', + 'clone', + 'https://github.com/wbthomason/packer.nvim', + install_path, + }) + load_plugins() + require('packer').sync() + vim.cmd('colorscheme aurora') +else + load_plugins() + vim.cmd('colorscheme aurora') +end