diff options
| author | Chris <[email protected]> | 2021-03-27 17:21:52 -0400 | 
|---|---|---|
| committer | Chris <[email protected]> | 2021-03-27 17:21:52 -0400 | 
| commit | 56798ec142a34fdcf090612de9ecbd07052f29b3 (patch) | |
| tree | ab1af4799a9401f450dc4c07e2cca01362153c53 /lua/lsp | |
| parent | 2c5d18ebbcb86c84fc864ef5b4dce31483ddf761 (diff) | |
added more user options
Diffstat (limited to 'lua/lsp')
| -rw-r--r-- | lua/lsp/efm-general-ls.lua | 99 | ||||
| -rw-r--r-- | lua/lsp/js-ts-ls.lua | 11 | 
2 files changed, 83 insertions, 27 deletions
| diff --git a/lua/lsp/efm-general-ls.lua b/lua/lsp/efm-general-ls.lua index 23df2c74..db9ffbcb 100644 --- a/lua/lsp/efm-general-ls.lua +++ b/lua/lsp/efm-general-ls.lua @@ -1,21 +1,64 @@  -- Example configuations here: https://github.com/mattn/efm-langserver +-- TODO this file needs to be refactored eache lang should be it's own file  -- python +local python_arguments = {} + +-- TODO replace with path argument  local flake8 = {      LintCommand = "flake8 --ignore=E501 --stdin-display-name ${INPUT} -",      lintStdin = true,      lintFormats = {"%f:%l:%c: %m"}  } +  local isort = {formatCommand = "isort --quiet -", formatStdin = true} +  local yapf = {formatCommand = "yapf --quiet", formatStdin = true} + +if O.python.linter == 'flake8' then +	table.insert(python_arguments, flake8) +end + +if O.python.formatter == 'yapf' then +	table.insert(python_arguments, yapf) +end + +if O.python.isort then +	table.insert(python_arguments, isort) +end +  -- lua +local lua_arguments = {}  local luaFormat = {      formatCommand = "lua-format -i --no-keep-simple-function-one-line --column-limit=120",      formatStdin = true  } --- JavaScript/React/TypeScript -local prettier = {formatCommand = "./node_modules/.bin/prettier --stdin-filepath ${INPUT}", formatStdin = true} -local prettier_global = {formatCommand = "prettier --stdin-filepath ${INPUT}", formatStdin = true} +if O.lua.formatter == 'lua-format' then +	table.insert(lua_arguments, luaFormat) +end + +-- sh +local sh_arguments = {} + +local shfmt = {formatCommand = 'shfmt -ci -s -bn', formatStdin = true} + +local shellcheck = { +    LintCommand = 'shellcheck -f gcc -x', +    lintFormats = {'%f:%l:%c: %trror: %m', '%f:%l:%c: %tarning: %m', '%f:%l:%c: %tote: %m'} +} + +if O.sh.formatter == 'shfmt' then +	table.insert(sh_arguments, shfmt) +end + +if O.sh.linter == 'shellcheck' then +	table.insert(sh_arguments, shellcheck) +end + +-- tsserver/web javascript react, vue, json, html, css, yaml +local prettier = {formatCommand = "prettier --stdin-filepath ${INPUT}", formatStdin = true} +-- You can look for project scope Prettier and Eslint with e.g. vim.fn.glob("node_modules/.bin/prettier") etc. If it is not found revert to global Prettier where needed. +-- local prettier = {formatCommand = "./node_modules/.bin/prettier --stdin-filepath ${INPUT}", formatStdin = true}  local eslint = {      lintCommand = "./node_modules/.bin/eslint -f unix --stdin --stdin-filename ${INPUT}", @@ -26,44 +69,48 @@ local eslint = {      formatStdin = true  } -local shellcheck = { -    LintCommand = 'shellcheck -f gcc -x', -    lintFormats = {'%f:%l:%c: %trror: %m', '%f:%l:%c: %tarning: %m', '%f:%l:%c: %tote: %m'} -} +local tsserver_args = {} -local shfmt = {formatCommand = 'shfmt -ci -s -bn', formatStdin = true} +if O.tsserver.formatter == 'prettier' then +	table.insert(tsserver_args, prettier) +end + +if O.tsserver.linter == 'eslint' then +	table.insert(tsserver_args, eslint) +end -local markdownlint = { -    -- TODO default to global lintrc -    -- lintcommand = 'markdownlint -s -c ./markdownlintrc', -    lintCommand = 'markdownlint -s', -    lintStdin = true, -    lintFormats = {'%f:%l %m', '%f:%l:%c %m', '%f: %l: %m'} -} + +-- local markdownlint = { +--     -- TODO default to global lintrc +--     -- lintcommand = 'markdownlint -s -c ./markdownlintrc', +--     lintCommand = 'markdownlint -s', +--     lintStdin = true, +--     lintFormats = {'%f:%l %m', '%f:%l:%c %m', '%f: %l: %m'} +-- }  local markdownPandocFormat = {formatCommand = 'pandoc -f markdown -t gfm -sp --tab-stop=2', formatStdin = true}  require"lspconfig".efm.setup {      -- init_options = {initializationOptions}, -	cmd = { DATA_PATH .. "/lspinstall/efm/efm-langserver" }, +    cmd = {DATA_PATH .. "/lspinstall/efm/efm-langserver"},      init_options = {documentFormatting = true, codeAction = false},      filetypes = {"lua", "python", "javascriptreact", "javascript", "sh", "html", "css", "json", "yaml", "markdown"},      settings = {          rootMarkers = {".git/"},          languages = { -            lua = {luaFormat}, -            python = {isort, yapf}, +            python = python_arguments, +            lua = lua_arguments, +			sh = sh_arguments, +            javascript = tsserver_args, +            javascriptreact = tsserver_args, +            html = {prettier}, +            css = {prettier}, +            json = {prettier}, +            yaml = {prettier}, +            markdown = {markdownPandocFormat}              -- javascriptreact = {prettier, eslint},              -- javascript = {prettier, eslint}, -            javascriptreact = {prettier}, -            javascript = {prettier_global}, -            sh = {shellcheck, shfmt}, -            html = {prettier_global}, -            css = {prettier_global}, -            json = {prettier_global}, -            yaml = {prettier_global},              -- markdown = {markdownPandocFormat, markdownlint}, -            markdown = {markdownPandocFormat}          }      }  } diff --git a/lua/lsp/js-ts-ls.lua b/lua/lsp/js-ts-ls.lua index c10039bd..4eca1e57 100644 --- a/lua/lsp/js-ts-ls.lua +++ b/lua/lsp/js-ts-ls.lua @@ -15,5 +15,14 @@ require'lspconfig'.tsserver.setup {      -- This makes sure tsserver is not used for formatting (I prefer prettier)      -- on_attach = require'lsp'.common_on_attach,      root_dir = require('lspconfig/util').root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git"), -    settings = {documentFormatting = false} +    settings = {documentFormatting = false}, +    handlers = { +        ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { +            virtual_text = O.tsserver.diagnostics.virtual_text, +            signs = O.tsserver.diagnostics.signs, +            underline = O.tsserver.diagnostics.underline, +            update_in_insert = true + +        }) +    }  } | 
