summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2021-07-08 20:17:26 +0200
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2021-07-08 20:17:26 +0200
commit88616bde7c7b5b25f505997aa2171245f7341453 (patch)
tree7232fff70899952e2f91cb8b5d39c496840105db
parent8c0ace95e67f76b900cacd8daa38faa1444cb3b9 (diff)
Updates to lang stuff
-rw-r--r--.config/nvim/ftplugin/c.lua4
-rw-r--r--.config/nvim/ftplugin/dart.lua6
-rw-r--r--.config/nvim/ftplugin/dockerfile.lua6
-rw-r--r--.config/nvim/ftplugin/elixir.lua4
-rw-r--r--.config/nvim/ftplugin/go.lua16
-rw-r--r--.config/nvim/ftplugin/graphql.lua5
-rw-r--r--.config/nvim/ftplugin/html.lua27
-rw-r--r--.config/nvim/ftplugin/javascript.lua77
-rw-r--r--.config/nvim/ftplugin/javascriptreact.lua77
-rw-r--r--.config/nvim/ftplugin/json.lua6
-rw-r--r--.config/nvim/ftplugin/kotlin.lua6
-rw-r--r--.config/nvim/ftplugin/lua.lua58
-rw-r--r--.config/nvim/ftplugin/python.lua74
-rw-r--r--.config/nvim/ftplugin/rust.lua10
-rw-r--r--.config/nvim/ftplugin/sh.lua38
-rw-r--r--.config/nvim/ftplugin/tex.lua4
-rw-r--r--.config/nvim/ftplugin/vim.lua4
-rw-r--r--.config/nvim/ftplugin/yaml.lua4
-rw-r--r--.config/nvim/ftplugin/zig.lua47
-rw-r--r--.config/nvim/ftplugin/zsh.lua45
-rw-r--r--.config/nvim/lua/cfg/utils/init.lua10
-rw-r--r--.config/nvim/lua/default-config.lua113
22 files changed, 378 insertions, 263 deletions
diff --git a/.config/nvim/ftplugin/c.lua b/.config/nvim/ftplugin/c.lua
index 7443cab..43db5ec 100644
--- a/.config/nvim/ftplugin/c.lua
+++ b/.config/nvim/ftplugin/c.lua
@@ -1,3 +1,7 @@
+if require("cfg.utils").check_lsp_client_active "clangd" then
+ return
+end
+
local clangd_flags = { "--background-index" }
if O.lang.clang.cross_file_rename then
diff --git a/.config/nvim/ftplugin/dart.lua b/.config/nvim/ftplugin/dart.lua
index 419d040..3076d7d 100644
--- a/.config/nvim/ftplugin/dart.lua
+++ b/.config/nvim/ftplugin/dart.lua
@@ -1,6 +1,10 @@
+if require("cfg.utils").check_lsp_client_active "dartls" then
+ return
+end
+
require("lspconfig").dartls.setup {
cmd = { "dart", O.lang.dart.sdk_path, "--lsp" },
- on_attach = require("lsp").common_on_attach,
+ on_attach = require("cfg.lsp").common_on_attach,
init_options = {
closingLabels = false,
flutterOutline = false,
diff --git a/.config/nvim/ftplugin/dockerfile.lua b/.config/nvim/ftplugin/dockerfile.lua
index 37b4317..cbf3572 100644
--- a/.config/nvim/ftplugin/dockerfile.lua
+++ b/.config/nvim/ftplugin/dockerfile.lua
@@ -1,6 +1,10 @@
+if require("cfg.utils").check_lsp_client_active "dockerls" then
+ return
+end
+
-- npm install -g dockerfile-language-server-nodejs
require("lspconfig").dockerls.setup {
cmd = { DATA_PATH .. "/lspinstall/dockerfile/node_modules/.bin/docker-langserver", "--stdio" },
- on_attach = require("lsp").common_on_attach,
+ on_attach = require("cfg.lsp").common_on_attach,
root_dir = vim.loop.cwd,
}
diff --git a/.config/nvim/ftplugin/elixir.lua b/.config/nvim/ftplugin/elixir.lua
index fbb5b29..5788347 100644
--- a/.config/nvim/ftplugin/elixir.lua
+++ b/.config/nvim/ftplugin/elixir.lua
@@ -1,3 +1,7 @@
+if require("cfg.utils").check_lsp_client_active "elixirls" then
+ return
+end
+
require("lspconfig").elixirls.setup {
cmd = { DATA_PATH .. "/lspinstall/elixir/elixir-ls/language_server.sh" },
}
diff --git a/.config/nvim/ftplugin/go.lua b/.config/nvim/ftplugin/go.lua
index 56b9cac..5cc600b 100644
--- a/.config/nvim/ftplugin/go.lua
+++ b/.config/nvim/ftplugin/go.lua
@@ -1,10 +1,12 @@
-require("lspconfig").gopls.setup {
- cmd = { DATA_PATH .. "/lspinstall/go/gopls" },
- settings = { gopls = { analyses = { unusedparams = true }, staticcheck = true } },
- root_dir = require("lspconfig").util.root_pattern(".git", "go.mod"),
- init_options = { usePlaceholders = true, completeUnimported = true },
- on_attach = require("lsp").common_on_attach,
-}
+if not require("cfg.utils").check_lsp_client_active "gopls" then
+ require("lspconfig").gopls.setup {
+ cmd = { DATA_PATH .. "/lspinstall/go/gopls" },
+ settings = { gopls = { analyses = { unusedparams = true }, staticcheck = true } },
+ root_dir = require("lspconfig").util.root_pattern(".git", "go.mod"),
+ init_options = { usePlaceholders = true, completeUnimported = true },
+ on_attach = require("cfg.lsp").common_on_attach,
+ }
+end
vim.opt_local.tabstop = 4
vim.opt_local.shiftwidth = 4
diff --git a/.config/nvim/ftplugin/graphql.lua b/.config/nvim/ftplugin/graphql.lua
index df3dce9..863bfa0 100644
--- a/.config/nvim/ftplugin/graphql.lua
+++ b/.config/nvim/ftplugin/graphql.lua
@@ -1,2 +1,5 @@
+if require("cfg.utils").check_lsp_client_active "graphql" then
+ return
+end
-- npm install -g graphql-language-service-cli
-require("lspconfig").graphql.setup { on_attach = require("lsp").common_on_attach }
+require("lspconfig").graphql.setup { on_attach = require("cfg.lsp").common_on_attach }
diff --git a/.config/nvim/ftplugin/html.lua b/.config/nvim/ftplugin/html.lua
index 312301b..d673a26 100644
--- a/.config/nvim/ftplugin/html.lua
+++ b/.config/nvim/ftplugin/html.lua
@@ -1,14 +1,17 @@
--- npm install -g vscode-html-languageserver-bin
-local capabilities = vim.lsp.protocol.make_client_capabilities()
-capabilities.textDocument.completion.completionItem.snippetSupport = true
+if not require("cfg.utils").check_lsp_client_active "html" then
+ -- npm install -g vscode-html-languageserver-bin
+ local capabilities = vim.lsp.protocol.make_client_capabilities()
+ capabilities.textDocument.completion.completionItem.snippetSupport = true
+
+ require("lspconfig").html.setup {
+ cmd = {
+ "node",
+ DATA_PATH .. "/lspinstall/html/vscode-html/html-language-features/server/dist/node/htmlServerMain.js",
+ "--stdio",
+ },
+ on_attach = require("cfg.lsp").common_on_attach,
+ capabilities = capabilities,
+ }
+end
-require("lspconfig").html.setup {
- cmd = {
- "node",
- DATA_PATH .. "/lspinstall/html/vscode-html/html-language-features/server/dist/node/htmlServerMain.js",
- "--stdio",
- },
- on_attach = require("lsp").common_on_attach,
- capabilities = capabilities,
-}
vim.cmd "setl ts=2 sw=2"
diff --git a/.config/nvim/ftplugin/javascript.lua b/.config/nvim/ftplugin/javascript.lua
index ab37036..ff7cef2 100644
--- a/.config/nvim/ftplugin/javascript.lua
+++ b/.config/nvim/ftplugin/javascript.lua
@@ -1,38 +1,41 @@
--- npm install -g typescript typescript-language-server
--- require'snippets'.use_suggested_mappings()
--- local capabilities = vim.lsp.protocol.make_client_capabilities()
--- capabilities.textDocument.completion.completionItem.snippetSupport = true;
--- local on_attach_common = function(client)
--- print("LSP Initialized")
--- require'completion'.on_attach(client)
--- require'illuminate'.on_attach(client)
--- end
-require("lspconfig").tsserver.setup {
- cmd = {
- DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server",
- "--stdio",
- },
- filetypes = {
- "javascript",
- "javascriptreact",
- "javascript.jsx",
- "typescript",
- "typescriptreact",
- "typescript.tsx",
- },
- on_attach = require("lsp").tsserver_on_attach,
- -- 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 },
- handlers = {
- ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
- virtual_text = O.lang.tsserver.diagnostics.virtual_text,
- signs = O.lang.tsserver.diagnostics.signs,
- underline = O.lang.tsserver.diagnostics.underline,
- update_in_insert = true,
- }),
- },
-}
-require("lsp.ts-fmt-lint").setup()
+if not require("cfg.utils").check_lsp_client_active "tsserver" then
+ -- npm install -g typescript typescript-language-server
+ -- require'snippets'.use_suggested_mappings()
+ -- local capabilities = vim.lsp.protocol.make_client_capabilities()
+ -- capabilities.textDocument.completion.completionItem.snippetSupport = true;
+ -- local on_attach_common = function(client)
+ -- print("LSP Initialized")
+ -- require'completion'.on_attach(client)
+ -- require'illuminate'.on_attach(client)
+ -- end
+ require("lspconfig").tsserver.setup {
+ cmd = {
+ DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server",
+ "--stdio",
+ },
+ filetypes = {
+ "javascript",
+ "javascriptreact",
+ "javascript.jsx",
+ "typescript",
+ "typescriptreact",
+ "typescript.tsx",
+ },
+ on_attach = require("cfg.lsp").tsserver_on_attach,
+ -- 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 },
+ handlers = {
+ ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
+ virtual_text = O.lang.tsserver.diagnostics.virtual_text,
+ signs = O.lang.tsserver.diagnostics.signs,
+ underline = O.lang.tsserver.diagnostics.underline,
+ update_in_insert = true,
+ }),
+ },
+ }
+ require("lsp.ts-fmt-lint").setup()
+end
+
vim.cmd "setl ts=2 sw=2"
diff --git a/.config/nvim/ftplugin/javascriptreact.lua b/.config/nvim/ftplugin/javascriptreact.lua
index ab37036..ff7cef2 100644
--- a/.config/nvim/ftplugin/javascriptreact.lua
+++ b/.config/nvim/ftplugin/javascriptreact.lua
@@ -1,38 +1,41 @@
--- npm install -g typescript typescript-language-server
--- require'snippets'.use_suggested_mappings()
--- local capabilities = vim.lsp.protocol.make_client_capabilities()
--- capabilities.textDocument.completion.completionItem.snippetSupport = true;
--- local on_attach_common = function(client)
--- print("LSP Initialized")
--- require'completion'.on_attach(client)
--- require'illuminate'.on_attach(client)
--- end
-require("lspconfig").tsserver.setup {
- cmd = {
- DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server",
- "--stdio",
- },
- filetypes = {
- "javascript",
- "javascriptreact",
- "javascript.jsx",
- "typescript",
- "typescriptreact",
- "typescript.tsx",
- },
- on_attach = require("lsp").tsserver_on_attach,
- -- 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 },
- handlers = {
- ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
- virtual_text = O.lang.tsserver.diagnostics.virtual_text,
- signs = O.lang.tsserver.diagnostics.signs,
- underline = O.lang.tsserver.diagnostics.underline,
- update_in_insert = true,
- }),
- },
-}
-require("lsp.ts-fmt-lint").setup()
+if not require("cfg.utils").check_lsp_client_active "tsserver" then
+ -- npm install -g typescript typescript-language-server
+ -- require'snippets'.use_suggested_mappings()
+ -- local capabilities = vim.lsp.protocol.make_client_capabilities()
+ -- capabilities.textDocument.completion.completionItem.snippetSupport = true;
+ -- local on_attach_common = function(client)
+ -- print("LSP Initialized")
+ -- require'completion'.on_attach(client)
+ -- require'illuminate'.on_attach(client)
+ -- end
+ require("lspconfig").tsserver.setup {
+ cmd = {
+ DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server",
+ "--stdio",
+ },
+ filetypes = {
+ "javascript",
+ "javascriptreact",
+ "javascript.jsx",
+ "typescript",
+ "typescriptreact",
+ "typescript.tsx",
+ },
+ on_attach = require("cfg.lsp").tsserver_on_attach,
+ -- 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 },
+ handlers = {
+ ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
+ virtual_text = O.lang.tsserver.diagnostics.virtual_text,
+ signs = O.lang.tsserver.diagnostics.signs,
+ underline = O.lang.tsserver.diagnostics.underline,
+ update_in_insert = true,
+ }),
+ },
+ }
+ require("lsp.ts-fmt-lint").setup()
+end
+
vim.cmd "setl ts=2 sw=2"
diff --git a/.config/nvim/ftplugin/json.lua b/.config/nvim/ftplugin/json.lua
index 29a3096..e96ab45 100644
--- a/.config/nvim/ftplugin/json.lua
+++ b/.config/nvim/ftplugin/json.lua
@@ -1,3 +1,7 @@
+if require("cfg.utils").check_lsp_client_active "jsonls" then
+ return
+end
+
-- npm install -g vscode-json-languageserver
require("lspconfig").jsonls.setup {
cmd = {
@@ -5,7 +9,7 @@ require("lspconfig").jsonls.setup {
DATA_PATH .. "/lspinstall/json/vscode-json/json-language-features/server/dist/node/jsonServerMain.js",
"--stdio",
},
- on_attach = require("lsp").common_on_attach,
+ on_attach = require("cfg.lsp").common_on_attach,
commands = {
Format = {
diff --git a/.config/nvim/ftplugin/kotlin.lua b/.config/nvim/ftplugin/kotlin.lua
index dbd800b..eb5f5f5 100644
--- a/.config/nvim/ftplugin/kotlin.lua
+++ b/.config/nvim/ftplugin/kotlin.lua
@@ -1,3 +1,7 @@
+if require("cfg.utils").check_lsp_client_active "kotlin_language_server" then
+ return
+end
+
--- default config for gradle-projects of the
--- kotlin-language-server: https://github.com/fwcd/kotlin-language-server
---
@@ -27,7 +31,7 @@ local fallback_root_files = {
require("lspconfig").kotlin_language_server.setup {
cmd = { bin_name },
- on_attach = require("lsp").common_on_attach,
+ on_attach = require("cfg.lsp").common_on_attach,
root_dir = function(fname)
return util.root_pattern(unpack(root_files))(fname) or util.root_pattern(unpack(fallback_root_files))(fname)
end,
diff --git a/.config/nvim/ftplugin/lua.lua b/.config/nvim/ftplugin/lua.lua
index 3eec445..4462815 100644
--- a/.config/nvim/ftplugin/lua.lua
+++ b/.config/nvim/ftplugin/lua.lua
@@ -1,34 +1,37 @@
--- https://github.com/sumneko/lua-language-server/wiki/Build-and-Run-(Standalone)
-local sumneko_root_path = DATA_PATH .. "/lspinstall/lua"
-local sumneko_binary = sumneko_root_path .. "/sumneko-lua-language-server"
+if not require("cfg.utils").check_lsp_client_active "sumneko_lua" then
+ -- https://github.com/sumneko/lua-language-server/wiki/Build-and-Run-(Standalone)
+ local sumneko_root_path = DATA_PATH .. "/lspinstall/lua"
+ local sumneko_binary = sumneko_root_path .. "/sumneko-lua-language-server"
-require("lspconfig").sumneko_lua.setup {
- cmd = { sumneko_binary, "-E", sumneko_root_path .. "/main.lua" },
- on_attach = require("cfg.lsp").common_on_attach,
- settings = {
- Lua = {
- runtime = {
- -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
- version = "LuaJIT",
- -- Setup your lua path
- path = vim.split(package.path, ";"),
- },
- diagnostics = {
- -- Get the language server to recognize the `vim` global
- globals = { "vim" },
- },
- workspace = {
- -- Make the server aware of Neovim runtime files
- library = {
- [vim.fn.expand "$VIMRUNTIME/lua"] = true,
- [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true,
+ require("lspconfig").sumneko_lua.setup {
+ cmd = { sumneko_binary, "-E", sumneko_root_path .. "/main.lua" },
+ on_attach = require("cfg.lsp").common_on_attach,
+ settings = {
+ Lua = {
+ runtime = {
+ -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
+ version = "LuaJIT",
+ -- Setup your lua path
+ path = vim.split(package.path, ";"),
+ },
+ diagnostics = {
+ -- Get the language server to recognize the `vim` global
+ globals = { "vim" },
+ },
+ workspace = {
+ -- Make the server aware of Neovim runtime files
+ library = {
+ [vim.fn.expand "$VIMRUNTIME/lua"] = true,
+ [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true,
+ },
+ maxPreload = 100000,
+ preloadFileSize = 1000,
},
- maxPreload = 100000,
- preloadFileSize = 1000,
},
},
- },
-}
+ }
+end
+
if O.lang.lua.autoformat then
require("cfg.utils").define_augroups {
_lua_autoformat = {
@@ -42,3 +45,4 @@ if O.lang.lua.autoformat then
end
vim.cmd "setl ts=2 sw=2"
+
diff --git a/.config/nvim/ftplugin/python.lua b/.config/nvim/ftplugin/python.lua
index 09eb8d7..fe8d857 100644
--- a/.config/nvim/ftplugin/python.lua
+++ b/.config/nvim/ftplugin/python.lua
@@ -20,46 +20,50 @@ if O.lang.python.isort then
table.insert(python_arguments, isort)
end
-require("lspconfig").efm.setup {
- -- init_options = {initializationOptions},
- cmd = { DATA_PATH .. "/lspinstall/efm/efm-langserver" },
- init_options = { documentFormatting = true, codeAction = false },
- filetypes = { "python" },
- settings = {
- rootMarkers = { ".git/", "requirements.txt" },
- languages = {
- python = python_arguments,
+if not require("cfg.utils").check_lsp_client_active "efm" then
+ require("lspconfig").efm.setup {
+ -- init_options = {initializationOptions},
+ cmd = { DATA_PATH .. "/lspinstall/efm/efm-langserver" },
+ init_options = { documentFormatting = true, codeAction = false },
+ filetypes = { "python" },
+ settings = {
+ rootMarkers = { ".git/", "requirements.txt" },
+ languages = {
+ python = python_arguments,
+ },
},
- },
-}
+ }
+end
--- npm i -g pyright
-require("lspconfig").pyright.setup {
- cmd = {
- DATA_PATH .. "/lspinstall/python/node_modules/.bin/pyright-langserver",
- "--stdio",
- },
- on_attach = require("cfg.lsp").common_on_attach,
- handlers = {
- ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
- virtual_text = O.lang.python.diagnostics.virtual_text,
- signs = O.lang.python.diagnostics.signs,
- underline = O.lang.python.diagnostics.underline,
- update_in_insert = true,
- }),
- },
- settings = {
- python = {
- analysis = {
- typeCheckingMode = O.lang.python.analysis.type_checking,
- autoSearchPaths = O.lang.python.analysis.auto_search_paths,
- useLibraryCodeForTypes = O.lang.python.analysis.use_library_code_types,
+if not require("cfg.utils").check_lsp_client_active "pyright" then
+ -- npm i -g pyright
+ require("lspconfig").pyright.setup {
+ cmd = {
+ DATA_PATH .. "/lspinstall/python/node_modules/.bin/pyright-langserver",
+ "--stdio",
+ },
+ on_attach = require("cfg.lsp").common_on_attach,
+ handlers = {
+ ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
+ virtual_text = O.lang.python.diagnostics.virtual_text,
+ signs = O.lang.python.diagnostics.signs,
+ underline = O.lang.python.diagnostics.underline,
+ update_in_insert = true,
+ }),
+ },
+ settings = {
+ python = {
+ analysis = {
+ typeCheckingMode = O.lang.python.analysis.type_checking,
+ autoSearchPaths = O.lang.python.analysis.auto_search_paths,
+ useLibraryCodeForTypes = O.lang.python.analysis.use_library_code_types,
+ },
},
},
- },
-}
+ }
+end
if O.plugin.debug.active and O.plugin.dap_install.active then
- local dap_install = require("dap-install")
+ local dap_install = require "dap-install"
dap_install.config("python_dbg", {})
end
diff --git a/.config/nvim/ftplugin/rust.lua b/.config/nvim/ftplugin/rust.lua
index 349e7ce..9a6e8a3 100644
--- a/.config/nvim/ftplugin/rust.lua
+++ b/.config/nvim/ftplugin/rust.lua
@@ -1,3 +1,7 @@
+if require("cfg.utils").check_lsp_client_active "rust_analyzer" then
+ return
+end
+
if O.lang.rust.rust_tools.active then
local opts = {
tools = { -- rust-tools options
@@ -28,11 +32,11 @@ if O.lang.rust.rust_tools.active then
-- prefix for parameter hints
-- default: "<-"
- parameter_hints_prefix = "<-",
+ parameter_hints_prefix = O.lang.rust.rust_tools.parameter_hints_prefix,
-- prefix for all the other hints (type, chaining)
-- default: "=>"
- other_hints_prefix = "=>",
+ other_hints_prefix = O.lang.rust.rust_tools.other_hints_prefix,
-- whether to align to the lenght of the longest line in the file
max_len_align = false,
@@ -75,7 +79,7 @@ if O.lang.rust.rust_tools.active then
else
require("lspconfig").rust_analyzer.setup {
cmd = { DATA_PATH .. "/lspinstall/rust/rust-analyzer" },
- on_attach = require("lsp").common_on_attach,
+ on_attach = require("cfg.lsp").common_on_attach,
filetypes = { "rust" },
root_dir = require("lspconfig.util").root_pattern("Cargo.toml", "rust-project.json"),
}
diff --git a/.config/nvim/ftplugin/sh.lua b/.config/nvim/ftplugin/sh.lua
index e5f0a06..5110f6c 100644
--- a/.config/nvim/ftplugin/sh.lua
+++ b/.config/nvim/ftplugin/sh.lua
@@ -1,9 +1,11 @@
--- npm i -g bash-language-server
-require("lspconfig").bashls.setup {
- cmd = { DATA_PATH .. "/lspinstall/bash/node_modules/.bin/bash-language-server", "start" },
- on_attach = require("cfg.lsp").common_on_attach,
- filetypes = { "sh", "zsh" },
-}
+if not require("cfg.utils").check_lsp_client_active "bashls" then
+ -- npm i -g bash-language-server
+ require("lspconfig").bashls.setup {
+ cmd = { DATA_PATH .. "/lspinstall/bash/node_modules/.bin/bash-language-server", "start" },
+ on_attach = require("cfg.lsp").common_on_attach,
+ filetypes = { "sh", "zsh" },
+ }
+end
-- sh
local sh_arguments = {}
@@ -19,15 +21,17 @@ if O.lang.sh.linter == "shellcheck" then
table.insert(sh_arguments, shellcheck)
end
-require("lspconfig").efm.setup {
- -- init_options = {initializationOptions},
- cmd = { DATA_PATH .. "/lspinstall/efm/efm-langserver" },
- init_options = { documentFormatting = true, codeAction = false },
- filetypes = { "sh" },
- settings = {
- rootMarkers = { ".git/" },
- languages = {
- sh = sh_arguments,
+if not require("cfg.utils").check_lsp_client_active "efm" then
+ require("lspconfig").efm.setup {
+ -- init_options = {initializationOptions},
+ cmd = { DATA_PATH .. "/lspinstall/efm/efm-langserver" },
+ init_options = { documentFormatting = true, codeAction = false },
+ filetypes = { "sh" },
+ settings = {
+ rootMarkers = { ".git/" },
+ languages = {
+ sh = sh_arguments,
+ },
},
- },
-}
+ }
+end
diff --git a/.config/nvim/ftplugin/tex.lua b/.config/nvim/ftplugin/tex.lua
index b15cb06..f8e1cb5 100644
--- a/.config/nvim/ftplugin/tex.lua
+++ b/.config/nvim/ftplugin/tex.lua
@@ -1,3 +1,7 @@
+if require("cfg.utils").check_lsp_client_active "texlab" then
+ return
+end
+
require("lspconfig").texlab.setup {
cmd = { DATA_PATH .. "/lspinstall/latex/texlab" },
on_attach = require("cfg.lsp").common_on_attach,
diff --git a/.config/nvim/ftplugin/vim.lua b/.config/nvim/ftplugin/vim.lua
index 9dbbe3a..0468381 100644
--- a/.config/nvim/ftplugin/vim.lua
+++ b/.config/nvim/ftplugin/vim.lua
@@ -1,3 +1,7 @@
+if require("cfg.utils").check_lsp_client_active "vimls" then
+ return
+end
+
-- npm install -g vim-language-server
require("lspconfig").vimls.setup {
cmd = { DATA_PATH .. "/lspinstall/vim/node_modules/.bin/vim-language-server", "--stdio" },
diff --git a/.config/nvim/ftplugin/yaml.lua b/.config/nvim/ftplugin/yaml.lua
index afb82fe..fa5ec54 100644
--- a/.config/nvim/ftplugin/yaml.lua
+++ b/.config/nvim/ftplugin/yaml.lua
@@ -1,3 +1,7 @@
+if require("cfg.utils").check_lsp_client_active "yamlls" then
+ return
+end
+
-- npm install -g yaml-language-server
require("lspconfig").yamlls.setup {
cmd = { DATA_PATH .. "/lspinstall/yaml/node_modules/.bin/yaml-language-server", "--stdio" },
diff --git a/.config/nvim/ftplugin/zig.lua b/.config/nvim/ftplugin/zig.lua
index 72ce8cb..6ece5ae 100644
--- a/.config/nvim/ftplugin/zig.lua
+++ b/.config/nvim/ftplugin/zig.lua
@@ -1,14 +1,35 @@
--- Because lspinstall don't support zig yet,
--- So we need zls preset in global lib
--- Further custom install zls in
--- https://github.com/zigtools/zls/wiki/Downloading-and-Building-ZLS
-require("lspconfig").zls.setup {
- root_dir = require("lspconfig").util.root_pattern(".git", "build.zig", "zls.json"),
- on_attach = require("cfg.lsp").common_on_attach,
+if not require("cfg.utils").check_lsp_client_active "bashls" then
+ -- npm i -g bash-language-server
+ require("lspconfig").bashls.setup {
+ cmd = { DATA_PATH .. "/lspinstall/bash/node_modules/.bin/bash-language-server", "start" },
+ on_attach = require("cfg.lsp").common_on_attach,
+ filetypes = { "sh", "zsh" },
+ }
+end
+
+-- sh
+local sh_arguments = {}
+
+local shellcheck = {
+ LintCommand = "shellcheck -f gcc -x",
+ lintFormats = { "%f:%l:%c: %trror: %m", "%f:%l:%c: %tarning: %m", "%f:%l:%c: %tote: %m" },
}
-require("cfg.utils").define_augroups {
- _zig_autoformat = {
- { "BufEnter", "*.zig", ':lua vim.api.nvim_buf_set_option(0, "commentstring", "// %s")' },
- },
-}
-vim.cmd "setl expandtab tabstop=8 softtabstop=4 shiftwidth=4"
+
+if O.lang.sh.linter == "shellcheck" then
+ table.insert(sh_arguments, shellcheck)
+end
+
+if not require("cfg.utils").check_lsp_client_active "efm" then
+ require("lspconfig").efm.setup {
+ -- init_options = {initializationOptions},
+ cmd = { DATA_PATH .. "/lspinstall/efm/efm-langserver" },
+ init_options = { documentFormatting = true, codeAction = false },
+ filetypes = { "zsh" },
+ settings = {
+ rootMarkers = { ".git/" },
+ languages = {
+ sh = sh_arguments,
+ },
+ },
+ }
+end
diff --git a/.config/nvim/ftplugin/zsh.lua b/.config/nvim/ftplugin/zsh.lua
index a00309a..6ece5ae 100644
--- a/.config/nvim/ftplugin/zsh.lua
+++ b/.config/nvim/ftplugin/zsh.lua
@@ -1,16 +1,11 @@
--- npm i -g bash-language-server
-require("lspconfig").bashls.setup {
- cmd = { DATA_PATH .. "/lspinstall/bash/node_modules/.bin/bash-language-server", "start" },
- on_attach = require("cfg.lsp").common_on_attach,
- filetypes = { "sh", "zsh" },
-}
-
--- npm i -g bash-language-server
-require("lspconfig").bashls.setup {
- cmd = { DATA_PATH .. "/lspinstall/bash/node_modules/.bin/bash-language-server", "start" },
- on_attach = require("cfg.lsp").common_on_attach,
- filetypes = { "sh", "zsh" },
-}
+if not require("cfg.utils").check_lsp_client_active "bashls" then
+ -- npm i -g bash-language-server
+ require("lspconfig").bashls.setup {
+ cmd = { DATA_PATH .. "/lspinstall/bash/node_modules/.bin/bash-language-server", "start" },
+ on_attach = require("cfg.lsp").common_on_attach,
+ filetypes = { "sh", "zsh" },
+ }
+end
-- sh
local sh_arguments = {}
@@ -24,15 +19,17 @@ if O.lang.sh.linter == "shellcheck" then
table.insert(sh_arguments, shellcheck)
end
-require("lspconfig").efm.setup {
- -- init_options = {initializationOptions},
- cmd = { DATA_PATH .. "/lspinstall/efm/efm-langserver" },
- init_options = { documentFormatting = true, codeAction = false },
- filetypes = { "zsh" },
- settings = {
- rootMarkers = { ".git/" },
- languages = {
- sh = sh_arguments,
+if not require("cfg.utils").check_lsp_client_active "efm" then
+ require("lspconfig").efm.setup {
+ -- init_options = {initializationOptions},
+ cmd = { DATA_PATH .. "/lspinstall/efm/efm-langserver" },
+ init_options = { documentFormatting = true, codeAction = false },
+ filetypes = { "zsh" },
+ settings = {
+ rootMarkers = { ".git/" },
+ languages = {
+ sh = sh_arguments,
+ },
},
- },
-}
+ }
+end
diff --git a/.config/nvim/lua/cfg/utils/init.lua b/.config/nvim/lua/cfg/utils/init.lua
index 2fe3331..4c5dfd2 100644
--- a/.config/nvim/lua/cfg/utils/init.lua
+++ b/.config/nvim/lua/cfg/utils/init.lua
@@ -8,6 +8,16 @@ function utils.reload_config()
vim.cmd ":PackerInstall"
end
+function utils.check_lsp_client_active(name)
+ local clients = vim.lsp.get_active_clients()
+ for _, client in pairs(clients) do
+ if client.name == name then
+ return true
+ end
+ end
+ return false
+end
+
function utils.define_augroups(definitions) -- {{{1
-- Create autocommand groups based on the passed definitions
--
diff --git a/.config/nvim/lua/default-config.lua b/.config/nvim/lua/default-config.lua
index 2f5a674..1121f28 100644
--- a/.config/nvim/lua/default-config.lua
+++ b/.config/nvim/lua/default-config.lua
@@ -101,23 +101,40 @@ O = {
},
lang = {
- python = {
- linter = "",
- isort = false,
+ cmake = {},
+ clang = {
diagnostics = {
virtual_text = { spacing = 0, prefix = "" },
signs = true,
underline = true,
},
- analysis = {
- type_checking = "basic",
- auto_search_paths = true,
- use_library_code_types = true,
- },
+ cross_file_rename = true,
+ header_insertion = "never",
+ },
+ css = {
+ virtual_text = true,
},
dart = {
sdk_path = "/usr/lib/dart/bin/snapshots/analysis_server.dart.snapshot",
},
+ docker = {},
+ efm = {},
+ elm = {},
+ emmet = { active = true },
+ elixir = {},
+ graphql = {},
+ go = {},
+ html = {},
+ java = {},
+ json = {
+ diagnostics = {
+ virtual_text = { spacing = 0, prefix = "" },
+ signs = true,
+ underline = true,
+ },
+ },
+ kotlin = {},
+ latex = {},
lua = {
diagnostics = {
virtual_text = { spacing = 0, prefix = "" },
@@ -125,18 +142,42 @@ O = {
underline = true,
},
},
- sh = {
- -- @usage can be 'shellcheck'
+ php = {
+ format = {
+ format = {
+ default = "psr12",
+ },
+ },
+ environment = {
+ php_version = "7.4",
+ },
+ diagnostics = {
+ virtual_text = { spacing = 0, prefix = "" },
+ signs = true,
+ underline = true,
+ },
+ filetypes = { "php", "phtml" },
+ },
+ python = {
linter = "",
- -- @usage can be 'shfmt'
+ isort = false,
diagnostics = {
virtual_text = { spacing = 0, prefix = "" },
signs = true,
underline = true,
},
+ analysis = {
+ type_checking = "basic",
+ auto_search_paths = true,
+ use_library_code_types = true,
+ },
},
- tsserver = {
- -- @usage can be 'eslint'
+ rust = {
+ rust_tools = {
+ active = false,
+ parameter_hints_prefix = "<-",
+ other_hints_prefix = "=>", -- prefix for all the other hints (type, chaining)
+ },
linter = "",
diagnostics = {
virtual_text = { spacing = 0, prefix = "" },
@@ -144,14 +185,19 @@ O = {
underline = true,
},
},
- json = {
+ sh = {
+ -- @usage can be 'shellcheck'
+ linter = "",
+ -- @usage can be 'shfmt'
diagnostics = {
virtual_text = { spacing = 0, prefix = "" },
signs = true,
underline = true,
},
},
+ svelte = {},
tailwindcss = {
+ active = false,
filetypes = {
"html",
"css",
@@ -162,24 +208,9 @@ O = {
"typescriptreact",
},
},
- clang = {
- diagnostics = {
- virtual_text = { spacing = 0, prefix = "" },
- signs = true,
- underline = true,
- },
- cross_file_rename = true,
- header_insertion = "never",
- },
- go = {},
- elixir = {},
- vim = {},
- yaml = {},
terraform = {},
- rust = {
- rust_tools = {
- active = false,
- },
+ tsserver = {
+ -- @usage can be 'eslint'
linter = "",
diagnostics = {
virtual_text = { spacing = 0, prefix = "" },
@@ -187,24 +218,14 @@ O = {
underline = true,
},
},
- latex = {},
- kotlin = {},
- html = {},
- elm = {},
- emmet = { active = true },
- graphql = {},
- efm = {},
- docker = {},
- cmake = {},
- css = {
- virtual_text = true,
- },
+ vim = {},
+ yaml = {},
},
dashboard = {
custom_header = {
- ' ##############..... ############## ',
+ ' ##############..... ############## ',
' ##############......############## ',
' ##########..........########## ',
' ##########........########## ',
@@ -219,9 +240,9 @@ O = {
' ############...JJ...JJ..JJ JJ ',
' ##########....JJ...JJ..JJ JJ ',
' ########......JJJ..JJJ JJJ JJJ ',
- ' ###### ......... ',
+ ' ###### ......... ',
' ..... ',
- ' . ',
+ ' . ',
},
},
}