diff options
| author | William Boman <william@redwill.se> | 2021-08-23 06:53:11 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-23 06:53:11 +0200 |
| commit | 564f03e39b02254919868850dd8089d018bd0e4e (patch) | |
| tree | 319e88bebd4028549df9b22078768ed61b4be0cc /lua | |
| parent | export proper location of haskell language servers (#60) (diff) | |
| download | mason-564f03e39b02254919868850dd8089d018bd0e4e.tar mason-564f03e39b02254919868850dd8089d018bd0e4e.tar.gz mason-564f03e39b02254919868850dd8089d018bd0e4e.tar.bz2 mason-564f03e39b02254919868850dd8089d018bd0e4e.tar.lz mason-564f03e39b02254919868850dd8089d018bd0e4e.tar.xz mason-564f03e39b02254919868850dd8089d018bd0e4e.tar.zst mason-564f03e39b02254919868850dd8089d018bd0e4e.zip | |
eslintls: defer registering server definition with lspconfig (#62)
Resolves #61.
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/nvim-lsp-installer/server.lua | 7 | ||||
| -rw-r--r-- | lua/nvim-lsp-installer/servers/eslintls/init.lua | 87 |
2 files changed, 51 insertions, 43 deletions
diff --git a/lua/nvim-lsp-installer/server.lua b/lua/nvim-lsp-installer/server.lua index edc80253..5aa75825 100644 --- a/lua/nvim-lsp-installer/server.lua +++ b/lua/nvim-lsp-installer/server.lua @@ -31,6 +31,9 @@ M.Server.__index = M.Server -- Use this to defer setting up server specific things until they're actually -- needed, like custom commands. -- +-- @field pre_setup (function) An optional function to be executed prior to calling lspconfig's setup(). +-- Use this to defer setting up server specific things until they're actually needed. +-- function M.Server:new(opts) return setmetatable({ name = opts.name, @@ -39,10 +42,14 @@ function M.Server:new(opts) _default_options = opts.default_options, _pre_install_check = opts.pre_install_check, _post_setup = opts.post_setup, + _pre_setup = opts.pre_setup, }, M.Server) end function M.Server:setup(opts) + if self._pre_setup then + self._pre_setup() + end -- We require the lspconfig server here in order to do it as late as possible. -- 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. diff --git a/lua/nvim-lsp-installer/servers/eslintls/init.lua b/lua/nvim-lsp-installer/servers/eslintls/init.lua index 35bd1968..91f91012 100644 --- a/lua/nvim-lsp-installer/servers/eslintls/init.lua +++ b/lua/nvim-lsp-installer/servers/eslintls/init.lua @@ -1,51 +1,8 @@ -local lspconfig = require "lspconfig" -local configs = require "lspconfig/configs" - local notify = require "nvim-lsp-installer.notify" local server = require "nvim-lsp-installer.server" local path = require "nvim-lsp-installer.path" local shell = require "nvim-lsp-installer.installers.shell" -configs.eslintls = { - default_config = { - filetypes = { "javascript", "javascriptreact", "typescript", "typescriptreact" }, - root_dir = lspconfig.util.root_pattern(".eslintrc*", "package.json", ".git"), - -- Refer to https://github.com/Microsoft/vscode-eslint#settings-options for documentation. - settings = { - validate = "on", - run = "onType", - codeAction = { - disableRuleComment = { - enable = true, - -- "sameLine" might not work as expected, see https://github.com/williamboman/nvim-lsp-installer/issues/4 - location = "separateLine", - }, - showDocumentation = { - enable = true, - }, - }, - rulesCustomizations = {}, - -- Automatically determine working directory by locating .eslintrc config files. - -- - -- It's recommended not to change this. - workingDirectory = { mode = "auto" }, - -- If nodePath is a non-null/undefined value the eslint LSP runs into runtime exceptions. - -- - -- It's recommended not to change this. - nodePath = "", - -- The "workspaceFolder" is a VSCode concept. We set it to the root - -- directory to not restrict the LPS server when it traverses the - -- file tree when locating a .eslintrc config file. - -- - -- It's recommended not to change this. - workspaceFolder = { - uri = "/", - name = "root", - }, - }, - }, -} - local ConfirmExecutionResult = { deny = 1, confirmationPending = 2, @@ -66,6 +23,50 @@ return server.Server:new { name = "eslintls", root_dir = root_dir, installer = shell.raw(install_cmd), + pre_setup = function() + local lspconfig = require "lspconfig" + local configs = require "lspconfig/configs" + + configs.eslintls = { + default_config = { + filetypes = { "javascript", "javascriptreact", "typescript", "typescriptreact" }, + root_dir = lspconfig.util.root_pattern(".eslintrc*", "package.json", ".git"), + -- Refer to https://github.com/Microsoft/vscode-eslint#settings-options for documentation. + settings = { + validate = "on", + run = "onType", + codeAction = { + disableRuleComment = { + enable = true, + -- "sameLine" might not work as expected, see https://github.com/williamboman/nvim-lsp-installer/issues/4 + location = "separateLine", + }, + showDocumentation = { + enable = true, + }, + }, + rulesCustomizations = {}, + -- Automatically determine working directory by locating .eslintrc config files. + -- + -- It's recommended not to change this. + workingDirectory = { mode = "auto" }, + -- If nodePath is a non-null/undefined value the eslint LSP runs into runtime exceptions. + -- + -- It's recommended not to change this. + nodePath = "", + -- The "workspaceFolder" is a VSCode concept. We set it to the root + -- directory to not restrict the LPS server when it traverses the + -- file tree when locating a .eslintrc config file. + -- + -- It's recommended not to change this. + workspaceFolder = { + uri = "/", + name = "root", + }, + }, + }, + } + end, default_options = { cmd = { "node", path.concat { root_dir, "server", "out", "eslintServer.js" }, "--stdio" }, handlers = { |
