diff options
Diffstat (limited to 'lua/lsp')
| -rw-r--r-- | lua/lsp/angular-ls.lua | 6 | ||||
| -rw-r--r-- | lua/lsp/emmet-ls.lua | 16 | ||||
| -rw-r--r-- | lua/lsp/init.lua | 231 | ||||
| -rw-r--r-- | lua/lsp/svelte-ls.lua | 6 | ||||
| -rw-r--r-- | lua/lsp/tailwindcss-ls.lua | 17 | ||||
| -rw-r--r-- | lua/lsp/ts-fmt-lint.lua | 52 | 
6 files changed, 161 insertions, 167 deletions
| diff --git a/lua/lsp/angular-ls.lua b/lua/lsp/angular-ls.lua index 64a66c21..e1363731 100644 --- a/lua/lsp/angular-ls.lua +++ b/lua/lsp/angular-ls.lua @@ -1,6 +1,6 @@  -- TODO find correct root filetype  -- :LspInstall angular -require'lspconfig'.angularls.setup { -    cmd = {DATA_PATH .. "/lspinstall/angular/node_modules/@angular/language-server/bin/ngserver", "--stdio"}, -    on_attach = require'lsp'.common_on_attach, +require("lspconfig").angularls.setup { +  cmd = { DATA_PATH .. "/lspinstall/angular/node_modules/@angular/language-server/bin/ngserver", "--stdio" }, +  on_attach = require("lsp").common_on_attach,  } diff --git a/lua/lsp/emmet-ls.lua b/lua/lsp/emmet-ls.lua index fcb7f62d..a671ff88 100644 --- a/lua/lsp/emmet-ls.lua +++ b/lua/lsp/emmet-ls.lua @@ -2,22 +2,22 @@  --   return  -- end -local nvim_lsp = require'lspconfig' -local configs = require'lspconfig/configs' +local nvim_lsp = require "lspconfig" +local configs = require "lspconfig/configs"  local capabilities = vim.lsp.protocol.make_client_capabilities()  capabilities.textDocument.completion.completionItem.snippetSupport = true  configs.emmet_ls = {    default_config = { -    cmd = {'emmet-ls', '--stdio'}; -    filetypes = {'html', 'css', 'javascript', 'typescript'}; +    cmd = { "emmet-ls", "--stdio" }, +    filetypes = { "html", "css", "javascript", "typescript" },      root_dir = function()        return vim.loop.cwd() -    end; -    settings = {}; -  }; +    end, +    settings = {}, +  },  } -nvim_lsp.emmet_ls.setup{ +nvim_lsp.emmet_ls.setup {    -- on_attach = on_attach;  } diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index 0292064a..096ceabf 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -1,85 +1,79 @@  -- TODO figure out why this don't work  vim.fn.sign_define( -    "LspDiagnosticsSignError", -    {texthl = "LspDiagnosticsSignError", text = "", numhl = "LspDiagnosticsSignError"} +  "LspDiagnosticsSignError", +  { texthl = "LspDiagnosticsSignError", text = "", numhl = "LspDiagnosticsSignError" }  )  vim.fn.sign_define( -    "LspDiagnosticsSignWarning", -    {texthl = "LspDiagnosticsSignWarning", text = "", numhl = "LspDiagnosticsSignWarning"} +  "LspDiagnosticsSignWarning", +  { texthl = "LspDiagnosticsSignWarning", text = "", numhl = "LspDiagnosticsSignWarning" }  )  vim.fn.sign_define( -    "LspDiagnosticsSignHint", -    {texthl = "LspDiagnosticsSignHint", text = "", numhl = "LspDiagnosticsSignHint"} +  "LspDiagnosticsSignHint", +  { texthl = "LspDiagnosticsSignHint", text = "", numhl = "LspDiagnosticsSignHint" }  )  vim.fn.sign_define( -    "LspDiagnosticsSignInformation", -    {texthl = "LspDiagnosticsSignInformation", text = "", numhl = "LspDiagnosticsSignInformation"} +  "LspDiagnosticsSignInformation", +  { texthl = "LspDiagnosticsSignInformation", text = "", numhl = "LspDiagnosticsSignInformation" }  ) -vim.cmd("nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>") -vim.cmd("nnoremap <silent> gD <cmd>lua vim.lsp.buf.declaration()<CR>") -vim.cmd("nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>") -vim.cmd("nnoremap <silent> gi <cmd>lua vim.lsp.buf.implementation()<CR>") -vim.cmd("nnoremap <silent> K :lua vim.lsp.buf.hover()<CR>") +vim.cmd "nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>" +vim.cmd "nnoremap <silent> gD <cmd>lua vim.lsp.buf.declaration()<CR>" +vim.cmd "nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>" +vim.cmd "nnoremap <silent> gi <cmd>lua vim.lsp.buf.implementation()<CR>" +vim.cmd "nnoremap <silent> K :lua vim.lsp.buf.hover()<CR>"  -- vim.cmd('nnoremap <silent> <C-k> <cmd>lua vim.lsp.buf.signature_help()<CR>') -vim.cmd("nnoremap <silent> <C-p> :lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = O.lsp.popup_border}})<CR>") -vim.cmd("nnoremap <silent> <C-n> :lua vim.lsp.diagnostic.goto_next({popup_opts = {border = O.lsp.popup_border}})<CR>") +vim.cmd "nnoremap <silent> <C-p> :lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = O.lsp.popup_border}})<CR>" +vim.cmd "nnoremap <silent> <C-n> :lua vim.lsp.diagnostic.goto_next({popup_opts = {border = O.lsp.popup_border}})<CR>"  -- scroll down hover doc or scroll in definition preview  -- scroll up hover doc -vim.cmd('command! -nargs=0 LspVirtualTextToggle lua require("lsp/virtual_text").toggle()') +vim.cmd 'command! -nargs=0 LspVirtualTextToggle lua require("lsp/virtual_text").toggle()'  -- Set Default Prefix.  -- Note: You can set a prefix per lsp server in the lv-globals.lua file -vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( -  vim.lsp.diagnostic.on_publish_diagnostics, { -    virtual_text = { -      prefix = "", -      spacing = 0, -    }, -    signs = true, -    underline = true, -  } -) +vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { +  virtual_text = { +    prefix = "", +    spacing = 0, +  }, +  signs = true, +  underline = true, +}) -vim.lsp.handlers["textDocument/hover"] = vim.lsp.with( -  vim.lsp.handlers.hover, { -    border = O.lsp.popup_border -  } -) +vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { +  border = O.lsp.popup_border, +}) -vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with( -  vim.lsp.handlers.signature_help, { -    border = O.lsp.popup_border -  } -) +vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { +  border = O.lsp.popup_border, +})  -- symbols for autocomplete  vim.lsp.protocol.CompletionItemKind = { -    "   (Text) ", -    "   (Method)", -    "   (Function)", -    "   (Constructor)", -    " ﴲ  (Field)", -    "[] (Variable)", -    "   (Class)", -    " ﰮ  (Interface)", -    "   (Module)", -    " 襁 (Property)", -    "   (Unit)", -    "   (Value)", -    " 練 (Enum)", -    "   (Keyword)", -    "   (Snippet)", -    "   (Color)", -    "   (File)", -    "   (Reference)", -    "   (Folder)", -    "   (EnumMember)", -    " ﲀ  (Constant)", -    " ﳤ  (Struct)", -    "   (Event)", -    "   (Operator)", -    "   (TypeParameter)" +  "   (Text) ", +  "   (Method)", +  "   (Function)", +  "   (Constructor)", +  " ﴲ  (Field)", +  "[] (Variable)", +  "   (Class)", +  " ﰮ  (Interface)", +  "   (Module)", +  " 襁 (Property)", +  "   (Unit)", +  "   (Value)", +  " 練 (Enum)", +  "   (Keyword)", +  "   (Snippet)", +  "   (Color)", +  "   (File)", +  "   (Reference)", +  "   (Folder)", +  "   (EnumMember)", +  " ﲀ  (Constant)", +  " ﳤ  (Struct)", +  "   (Event)", +  "   (Operator)", +  "   (TypeParameter)",  }  --[[ " autoformat @@ -90,10 +84,10 @@ autocmd BufWritePre *.lua lua vim.lsp.buf.formatting_sync(nil, 100) ]]  -- autocmd FileType java nnoremap ca <Cmd>lua require('jdtls').code_action()<CR>  local function documentHighlight(client, bufnr) -    -- Set autocommands conditional on server_capabilities -    if client.resolved_capabilities.document_highlight then -        vim.api.nvim_exec( -            [[ +  -- Set autocommands conditional on server_capabilities +  if client.resolved_capabilities.document_highlight then +    vim.api.nvim_exec( +      [[        hi LspReferenceRead cterm=bold ctermbg=red guibg=#464646        hi LspReferenceText cterm=bold ctermbg=red guibg=#464646        hi LspReferenceWrite cterm=bold ctermbg=red guibg=#464646 @@ -103,69 +97,68 @@ local function documentHighlight(client, bufnr)          autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()        augroup END      ]], -            false -        ) -    end +      false +    ) +  end  end  local lsp_config = {}  if O.document_highlight then -    function lsp_config.common_on_attach(client, bufnr) -        documentHighlight(client, bufnr) -    end +  function lsp_config.common_on_attach(client, bufnr) +    documentHighlight(client, bufnr) +  end  end  function lsp_config.tsserver_on_attach(client, bufnr) -    -- lsp_config.common_on_attach(client, bufnr) -    client.resolved_capabilities.document_formatting = false - -    local ts_utils = require("nvim-lsp-ts-utils") - -    -- defaults -    ts_utils.setup { -        debug = false, -        disable_commands = false, -        enable_import_on_completion = false, -        import_all_timeout = 5000, -- ms - -        -- eslint -        eslint_enable_code_actions = true, -        eslint_enable_disable_comments = true, -        eslint_bin = O.lang.tsserver.linter, -        eslint_config_fallback = nil, -        eslint_enable_diagnostics = true, - -        -- formatting -        enable_formatting = O.lang.tsserver.autoformat, -        formatter = O.lang.tsserver.formatter, -        formatter_config_fallback = nil, - -        -- parentheses completion -        complete_parens = false, -        signature_help_in_parens = false, - -        -- update imports on file move -        update_imports_on_move = false, -        require_confirmation_on_move = false, -        watch_dir = nil, -    } - -    -- required to fix code action ranges -    ts_utils.setup_client(client) - -    -- TODO: keymap these? -    -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gs", ":TSLspOrganize<CR>", {silent = true}) -    -- vim.api.nvim_buf_set_keymap(bufnr, "n", "qq", ":TSLspFixCurrent<CR>", {silent = true}) -    -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", ":TSLspRenameFile<CR>", {silent = true}) -    -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", ":TSLspImportAll<CR>", {silent = true}) -end +  -- lsp_config.common_on_attach(client, bufnr) +  client.resolved_capabilities.document_formatting = false + +  local ts_utils = require "nvim-lsp-ts-utils" + +  -- defaults +  ts_utils.setup { +    debug = false, +    disable_commands = false, +    enable_import_on_completion = false, +    import_all_timeout = 5000, -- ms + +    -- eslint +    eslint_enable_code_actions = true, +    eslint_enable_disable_comments = true, +    eslint_bin = O.lang.tsserver.linter, +    eslint_config_fallback = nil, +    eslint_enable_diagnostics = true, + +    -- formatting +    enable_formatting = O.lang.tsserver.autoformat, +    formatter = O.lang.tsserver.formatter, +    formatter_config_fallback = nil, + +    -- parentheses completion +    complete_parens = false, +    signature_help_in_parens = false, + +    -- update imports on file move +    update_imports_on_move = false, +    require_confirmation_on_move = false, +    watch_dir = nil, +  } +  -- required to fix code action ranges +  ts_utils.setup_client(client) -require('lv-utils').define_augroups({ -    _general_lsp = { -        {'FileType', 'lspinfo', 'nnoremap <silent> <buffer> q :q<CR>'}, -    } -}) +  -- TODO: keymap these? +  -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gs", ":TSLspOrganize<CR>", {silent = true}) +  -- vim.api.nvim_buf_set_keymap(bufnr, "n", "qq", ":TSLspFixCurrent<CR>", {silent = true}) +  -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", ":TSLspRenameFile<CR>", {silent = true}) +  -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", ":TSLspImportAll<CR>", {silent = true}) +end + +require("lv-utils").define_augroups { +  _general_lsp = { +    { "FileType", "lspinfo", "nnoremap <silent> <buffer> q :q<CR>" }, +  }, +}  -- Use a loop to conveniently both setup defined servers  -- and map buffer local keybindings when the language server attaches diff --git a/lua/lsp/svelte-ls.lua b/lua/lsp/svelte-ls.lua index b9e8a5f8..9d7b8973 100644 --- a/lua/lsp/svelte-ls.lua +++ b/lua/lsp/svelte-ls.lua @@ -1,5 +1,5 @@  -- TODO what is a svelte filetype -require'lspconfig'.svelte.setup { -    cmd = {DATA_PATH .. "/lspinstall/svelte/node_modules/.bin/svelteserver", "--stdio"}, -    on_attach = require'lsp'.common_on_attach +require("lspconfig").svelte.setup { +  cmd = { DATA_PATH .. "/lspinstall/svelte/node_modules/.bin/svelteserver", "--stdio" }, +  on_attach = require("lsp").common_on_attach,  } diff --git a/lua/lsp/tailwindcss-ls.lua b/lua/lsp/tailwindcss-ls.lua index c56a8336..4c90ebd0 100644 --- a/lua/lsp/tailwindcss-ls.lua +++ b/lua/lsp/tailwindcss-ls.lua @@ -1,12 +1,13 @@  -- TODO what is a tailwindcss filetype -local lspconfig = require 'lspconfig' +local lspconfig = require "lspconfig"  lspconfig.tailwindcss.setup { -    cmd = { -        "node", DATA_PATH .. "/lspinstall/tailwindcss/tailwindcss-intellisense/extension/dist/server/tailwindServer.js", -        "--stdio" -    }, -    filetypes = O.lang.tailwindcss.filetypes, -    root_dir = require("lspconfig/util").root_pattern("tailwind.config.js", "postcss.config.ts", ".postcssrc"), -    on_attach = require'lsp'.common_on_attach +  cmd = { +    "node", +    DATA_PATH .. "/lspinstall/tailwindcss/tailwindcss-intellisense/extension/dist/server/tailwindServer.js", +    "--stdio", +  }, +  filetypes = O.lang.tailwindcss.filetypes, +  root_dir = require("lspconfig/util").root_pattern("tailwind.config.js", "postcss.config.ts", ".postcssrc"), +  on_attach = require("lsp").common_on_attach,  } diff --git a/lua/lsp/ts-fmt-lint.lua b/lua/lsp/ts-fmt-lint.lua index 36d4ca8a..8a6c366c 100644 --- a/lua/lsp/ts-fmt-lint.lua +++ b/lua/lsp/ts-fmt-lint.lua @@ -3,35 +3,35 @@  local M = {}  M.setup = function() -    local tsserver_args = {} +  local tsserver_args = {} -    local prettier = { -        formatCommand = "prettier --stdin-filepath ${INPUT}", -        formatStdin = true -    } - -    if vim.fn.glob("node_modules/.bin/prettier") ~= "" then -        prettier = { -            formatCommand = "./node_modules/.bin/prettier --stdin-filepath ${INPUT}", -            formatStdin = true -        } -    end +  local prettier = { +    formatCommand = "prettier --stdin-filepath ${INPUT}", +    formatStdin = true, +  } -    require"lspconfig".efm.setup { -        -- init_options = {initializationOptions}, -        cmd = {DATA_PATH .. "/lspinstall/efm/efm-langserver"}, -        init_options = {documentFormatting = true, codeAction = false}, -        filetypes = {"html", "css", "yaml", "vue", "javascript", "javascriptreact", "typescript", "typescriptreact"}, -        settings = { -            rootMarkers = {".git/", "package.json"}, -            languages = { -                html = {prettier}, -                css = {prettier}, -                json = {prettier}, -                yaml = {prettier} -            } -        } +  if vim.fn.glob "node_modules/.bin/prettier" ~= "" then +    prettier = { +      formatCommand = "./node_modules/.bin/prettier --stdin-filepath ${INPUT}", +      formatStdin = true,      } +  end + +  require("lspconfig").efm.setup { +    -- init_options = {initializationOptions}, +    cmd = { DATA_PATH .. "/lspinstall/efm/efm-langserver" }, +    init_options = { documentFormatting = true, codeAction = false }, +    filetypes = { "html", "css", "yaml", "vue", "javascript", "javascriptreact", "typescript", "typescriptreact" }, +    settings = { +      rootMarkers = { ".git/", "package.json" }, +      languages = { +        html = { prettier }, +        css = { prettier }, +        json = { prettier }, +        yaml = { prettier }, +      }, +    }, +  }  end  return M | 
