aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2023-10-02 00:02:38 +0800
committercrupest <crupest@outlook.com>2023-10-02 17:19:02 +0800
commit51ad6db5e04dc7856533731df125e6272bc8f843 (patch)
tree753243e68863a4101eacf21108fffc03180b9eda
parent2acf3a9ee8656c679f1eb230070d4e2bc963717c (diff)
downloadcrupest-51ad6db5e04dc7856533731df125e6272bc8f843.tar.gz
crupest-51ad6db5e04dc7856533731df125e6272bc8f843.tar.bz2
crupest-51ad6db5e04dc7856533731df125e6272bc8f843.zip
Update nvim configs.
-rw-r--r--configs/nvim/init.lua71
-rw-r--r--configs/nvim/lua/crupest/nvim/lsp/c.lua14
-rw-r--r--configs/nvim/lua/crupest/nvim/lsp/csharp.lua64
-rw-r--r--configs/nvim/lua/crupest/nvim/lsp/frontend.lua26
4 files changed, 107 insertions, 68 deletions
diff --git a/configs/nvim/init.lua b/configs/nvim/init.lua
index 499093c..ef73320 100644
--- a/configs/nvim/init.lua
+++ b/configs/nvim/init.lua
@@ -194,74 +194,10 @@ lspconfig.lua_ls.setup {
}
-- setup lsp frontend
-lspconfig.cssls.setup {
- capabilities = capabilities
-}
-
-lspconfig.html.setup {
- capabilities = capabilities
-}
-
-lspconfig.tsserver.setup {
- capabilities = capabilities,
- on_new_config = function(new_config, new_root_dir)
- local local_tsserver = require("crupest-util").find_npm_exe(new_root_dir, "typescript-language-server");
- if local_tsserver then
- new_config.cmd = { local_tsserver, "--stdio" }
- end
- end,
-}
+require("crupest.nvim.lsp.frontend").setup_lsp_frontend()
-local omnisharp_cmd = nil
-
-if is_win then
- omnisharp_cmd = { "C:/Users/crupest/Programs/omnisharp-win-x64/OmniSharp.exe" }
-end
-
-if omnisharp_cmd then
- require 'lspconfig'.omnisharp.setup {
- handlers = {
- ["textDocument/definition"] = require('omnisharp_extended').handler,
- },
-
- cmd = omnisharp_cmd,
-
- -- Enables support for reading code style, naming convention and analyzer
- -- settings from .editorconfig.
- enable_editorconfig_support = true,
-
- -- If true, MSBuild project system will only load projects for files that
- -- were opened in the editor. This setting is useful for big C# codebases
- -- and allows for faster initialization of code navigation features only
- -- for projects that are relevant to code that is being edited. With this
- -- setting enabled OmniSharp may load fewer projects and may thus display
- -- incomplete reference lists for symbols.
- enable_ms_build_load_projects_on_demand = false,
-
- -- Enables support for roslyn analyzers, code fixes and rulesets.
- enable_roslyn_analyzers = false,
-
- -- Specifies whether 'using' directives should be grouped and sorted during
- -- document formatting.
- organize_imports_on_format = false,
-
- -- Enables support for showing unimported types and unimported extension
- -- methods in completion lists. When committed, the appropriate using
- -- directive will be added at the top of the current file. This option can
- -- have a negative impact on initial completion responsiveness,
- -- particularly for the first few completion sessions after opening a
- -- solution.
- enable_import_completion = true,
-
- -- Specifies whether to include preview versions of the .NET SDK when
- -- determining which version to use for project loading.
- sdk_include_prereleases = true,
-
- -- Only run analyzers against open files when 'enableRoslynAnalyzers' is
- -- true
- analyze_open_documents_only = false,
- }
-end
+-- setup lsp csharp
+require("crupest.nvim.lsp.csharp").setup_lsp_csharp()
-- Use LspAttach autocommand to only map the following keys
-- after the language server attaches to the current buffer
@@ -324,4 +260,3 @@ vim.keymap.set("n", "<c-q>", require("crupest.nvim").win_close_buf)
vim.keymap.set("n", "<esc>", require("crupest.nvim").close_float)
require("crupest.nvim.fs").setup_filesystem_user_commands()
-
diff --git a/configs/nvim/lua/crupest/nvim/lsp/c.lua b/configs/nvim/lua/crupest/nvim/lsp/c.lua
new file mode 100644
index 0000000..c855af3
--- /dev/null
+++ b/configs/nvim/lua/crupest/nvim/lsp/c.lua
@@ -0,0 +1,14 @@
+local capabilities = require("cmp_nvim_lsp").default_capabilities()
+local lspconfig = require("lspconfig")
+
+local function setup_lsp_c()
+
+-- setup lsp clangd
+lspconfig.clangd.setup {
+ capabilities = capabilities
+}
+end
+
+return {
+ setup_lsp_c = setup_lsp_c
+}
diff --git a/configs/nvim/lua/crupest/nvim/lsp/csharp.lua b/configs/nvim/lua/crupest/nvim/lsp/csharp.lua
new file mode 100644
index 0000000..b06b9cc
--- /dev/null
+++ b/configs/nvim/lua/crupest/nvim/lsp/csharp.lua
@@ -0,0 +1,64 @@
+local lspconfig = require("lspconfig");
+local capabilities = require("cmp_nvim_lsp").default_capabilities()
+
+local is_win = vim.fn.has("win32") ~= 0
+
+local function setup_lsp_csharp()
+ local omnisharp_cmd = nil
+
+ if is_win then
+ omnisharp_cmd = { "C:/Users/crupest/Programs/omnisharp-win-x64/OmniSharp.exe" }
+ end
+
+ if omnisharp_cmd then
+ lspconfig.omnisharp.setup {
+ capabilities = capabilities,
+
+ handlers = {
+ ["textDocument/definition"] = require('omnisharp_extended').handler,
+ },
+
+ cmd = omnisharp_cmd,
+
+ -- Enables support for reading code style, naming convention and analyzer
+ -- settings from .editorconfig.
+ enable_editorconfig_support = true,
+
+ -- If true, MSBuild project system will only load projects for files that
+ -- were opened in the editor. This setting is useful for big C# codebases
+ -- and allows for faster initialization of code navigation features only
+ -- for projects that are relevant to code that is being edited. With this
+ -- setting enabled OmniSharp may load fewer projects and may thus display
+ -- incomplete reference lists for symbols.
+ enable_ms_build_load_projects_on_demand = false,
+
+ -- Enables support for roslyn analyzers, code fixes and rulesets.
+ enable_roslyn_analyzers = false,
+
+ -- Specifies whether 'using' directives should be grouped and sorted during
+ -- document formatting.
+ organize_imports_on_format = false,
+
+ -- Enables support for showing unimported types and unimported extension
+ -- methods in completion lists. When committed, the appropriate using
+ -- directive will be added at the top of the current file. This option can
+ -- have a negative impact on initial completion responsiveness,
+ -- particularly for the first few completion sessions after opening a
+ -- solution.
+ enable_import_completion = true,
+
+ -- Specifies whether to include preview versions of the .NET SDK when
+ -- determining which version to use for project loading.
+ sdk_include_prereleases = true,
+
+ -- Only run analyzers against open files when 'enableRoslynAnalyzers' is
+ -- true
+ analyze_open_documents_only = false,
+ }
+ end
+end
+
+return {
+ setup_lsp_csharp = setup_lsp_csharp
+}
+
diff --git a/configs/nvim/lua/crupest/nvim/lsp/frontend.lua b/configs/nvim/lua/crupest/nvim/lsp/frontend.lua
new file mode 100644
index 0000000..7ec094e
--- /dev/null
+++ b/configs/nvim/lua/crupest/nvim/lsp/frontend.lua
@@ -0,0 +1,26 @@
+local lspconfig = require("lspconfig");
+local capabilities = require("cmp_nvim_lsp").default_capabilities()
+
+local function setup_lsp_frontend()
+ lspconfig.cssls.setup {
+ capabilities = capabilities
+ }
+
+ lspconfig.html.setup {
+ capabilities = capabilities
+ }
+
+ lspconfig.tsserver.setup {
+ capabilities = capabilities,
+ on_new_config = function(new_config, new_root_dir)
+ local local_tsserver = require("crupest-util").find_npm_exe(new_root_dir, "typescript-language-server");
+ if local_tsserver then
+ new_config.cmd = { local_tsserver, "--stdio" }
+ end
+ end,
+ }
+end
+
+return {
+ setup_lsp_frontend = setup_lsp_frontend
+}