diff options
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/nvim-lsp-installer.lua | 1 | ||||
| -rw-r--r-- | lua/nvim-lsp-installer/installers/shell.lua | 6 | ||||
| -rw-r--r-- | lua/nvim-lsp-installer/server.lua | 9 | ||||
| -rw-r--r-- | lua/nvim-lsp-installer/servers/tflint/README.md | 9 | ||||
| -rw-r--r-- | lua/nvim-lsp-installer/servers/tflint/init.lua | 40 |
5 files changed, 64 insertions, 1 deletions
diff --git a/lua/nvim-lsp-installer.lua b/lua/nvim-lsp-installer.lua index fd14f834..3aad98a2 100644 --- a/lua/nvim-lsp-installer.lua +++ b/lua/nvim-lsp-installer.lua @@ -41,6 +41,7 @@ local _SERVERS = { ["tailwindcss"] = require "nvim-lsp-installer.servers.tailwindcss", ["terraformls"] = require "nvim-lsp-installer.servers.terraformls", ["texlab"] = require "nvim-lsp-installer.servers.texlab", + ["tflint"] = require "nvim-lsp-installer.servers.tflint", ["tsserver"] = require "nvim-lsp-installer.servers.tsserver", ["vimls"] = require "nvim-lsp-installer.servers.vimls", ["vuels"] = require "nvim-lsp-installer.servers.vuels", diff --git a/lua/nvim-lsp-installer/installers/shell.lua b/lua/nvim-lsp-installer/installers/shell.lua index e21d33c3..6cbe26ae 100644 --- a/lua/nvim-lsp-installer/installers/shell.lua +++ b/lua/nvim-lsp-installer/installers/shell.lua @@ -28,8 +28,12 @@ function M.raw(raw_script, opts) vim.cmd [[new]] vim.fn.termopen((opts.prefix or default_opts.prefix) .. raw_script, jobstart_opts) vim.o.shell = shell - vim.cmd [[startinsert]] + vim.cmd [[startinsert]] -- so that we tail the term log nicely ¯\_(ツ)_/¯ end end +function M.remote(url, opts) + return M.raw(("curl -s -f %q | bash"):format(url), opts) +end + return M diff --git a/lua/nvim-lsp-installer/server.lua b/lua/nvim-lsp-installer/server.lua index e4e684b3..8b72ce53 100644 --- a/lua/nvim-lsp-installer/server.lua +++ b/lua/nvim-lsp-installer/server.lua @@ -25,6 +25,11 @@ M.Server.__index = M.Server -- -- @field pre_install_check (function) An optional function to be executed before the installer. This allows ensuring that any prerequisites are fulfilled. -- This could for example be verifying that required build tools are installed. +-- +-- @field post_setup (function) An optional function to be executed after the setup function has been successfully called. +-- Use this to defer setting up server specific things until they're actually +-- needed, like custom commands. +-- function M.Server:new(opts) return setmetatable({ name = opts.name, @@ -32,6 +37,7 @@ function M.Server:new(opts) _root_dir = opts.root_dir, _default_options = opts.default_options, _pre_install_check = opts.pre_install_check, + _post_setup = opts.post_setup, }, M.Server) end @@ -40,6 +46,9 @@ function M.Server:setup(opts) -- The reason for this is because once a lspconfig server has been imported, it's -- automatically registered with lspconfig and causes it to show up in :LspInfo and whatnot. require("lspconfig")[self.name].setup(vim.tbl_deep_extend("force", self._default_options, opts)) + if self._post_setup then + self._post_setup() + end end function M.Server:get_default_options() diff --git a/lua/nvim-lsp-installer/servers/tflint/README.md b/lua/nvim-lsp-installer/servers/tflint/README.md new file mode 100644 index 00000000..359a6165 --- /dev/null +++ b/lua/nvim-lsp-installer/servers/tflint/README.md @@ -0,0 +1,9 @@ +# tflint + +## Installing TFLint plugins + +To install TFLint plugins, using the same installation of TFLint as nvim-lsp-installer, you may run the `:TFLintInit` +command. This command assumes that: + +1. there exists a `.tflint.hcl` file in neovim's current working directory. +1. you've called `server:setup(opts)` for `tflint` diff --git a/lua/nvim-lsp-installer/servers/tflint/init.lua b/lua/nvim-lsp-installer/servers/tflint/init.lua new file mode 100644 index 00000000..396f1cf9 --- /dev/null +++ b/lua/nvim-lsp-installer/servers/tflint/init.lua @@ -0,0 +1,40 @@ +local server = require "nvim-lsp-installer.server" +local notify = require "nvim-lsp-installer.notify" +local path = require "nvim-lsp-installer.path" +local shell = require "nvim-lsp-installer.installers.shell" + +local root_dir = server.get_server_root_path "tflint" + +local bin_path = path.concat { root_dir, "tflint" } + +return server.Server:new { + name = "tflint", + root_dir = root_dir, + installer = shell.remote("https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh", { + env = { + TFLINT_INSTALL_PATH = root_dir, + TFLINT_INSTALL_NO_ROOT = 1, + }, + }), + default_options = { + cmd = { bin_path, "--langserver" }, + }, + post_setup = function() + function _G.lsp_installer_tflint_init() + notify "Installing TFLint plugins…" + vim.fn.termopen(("%q --init"):format(bin_path), { + cwd = path.cwd(), + on_exit = function(_, exit_code) + if exit_code ~= 0 then + notify(("Failed to install TFLint (exit code %)."):format(exit_code)) + else + notify "Successfully installed TFLint plugins." + end + end, + }) + vim.cmd [[startinsert]] -- so that we tail the term log nicely ¯\_(ツ)_/¯ + end + + vim.cmd [[ command! TFLintInit call v:lua.lsp_installer_tflint_init() ]] + end, +} |
