Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Commit

Permalink
feat(langs): Add lsp_config option to configure lsp provider.
Browse files Browse the repository at this point in the history
  • Loading branch information
connorgmeean committed Oct 12, 2022
1 parent 83afc26 commit 0e966de
Show file tree
Hide file tree
Showing 30 changed files with 331 additions and 122 deletions.
9 changes: 7 additions & 2 deletions lua/doom/modules/langs/bash/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ bash.settings = {
disable_lsp = false,
--- name of the language server
--- @type string
language_server_name = "bashls",
lsp_name = "bashls",
--- Custom config to pass to nvim-lspconfig
--- @type table|nil
lsp_config = nil,

--- disables null-ls formatting sources
--- @type boolean
Expand Down Expand Up @@ -62,7 +65,9 @@ bash.autocmds = {
"bash,sh",
langs_utils.wrap_language_setup("bash", function()
if not bash.settings.disable_lsp then
langs_utils.use_lsp_mason(bash.settings.language_server_name)
langs_utils.use_lsp_mason(bash.settings.lsp_name, {
config = bash.settings.lsp_config,
})
end

if not bash.settings.disable_treesitter then
Expand Down
25 changes: 14 additions & 11 deletions lua/doom/modules/langs/c_sharp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,18 @@ c_sharp.settings = {
disable_lsp = false,
--- name of the language server
--- @type string
language_server_name = "omnisharp",
lsp_name = "omnisharp",
--- Custom config to pass to nvim-lspconfig
--- @type table|nil
lsp_config = {
cmd = { c_sharp.settings.lsp_name },
root_dir = function(fname)
local lsp_util = require("lspconfig.util")
return lsp_util.root_pattern("*.sln")(fname)
or lsp_util.root_pattern("*.csproj")(fname)
or lsp_util.root_pattern("ProjectSettings")(fname) -- Add support for unity projects
end,
},

--- disables null-ls formatting sources
--- @type boolean
Expand All @@ -38,16 +49,8 @@ c_sharp.autocmds = {
vim.cmd("packadd nvim-lspconfig")

if not c_sharp.settings.disable_lsp then
local lsp_util = require("lspconfig.util")
langs_utils.use_lsp_mason(c_sharp.settings.language_server_name, {
config = {
cmd = { c_sharp.settings.language_server_name },
root_dir = function(fname)
return lsp_util.root_pattern("*.sln")(fname)
or lsp_util.root_pattern("*.csproj")(fname)
or lsp_util.root_pattern("ProjectSettings")(fname) -- Add support for unity projects
end,
},
langs_utils.use_lsp_mason(c_sharp.settings.lsp_name, {
config = c_sharp.settings.lsp_config,
})
end

Expand Down
17 changes: 10 additions & 7 deletions lua/doom/modules/langs/cc/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ cc.settings = {
disable_lsp = false,
--- name of the language server
--- @type string
language_server_name = utils.get_sysname() == "Darwin" and "clangd" or "ccls",
lsp_name = utils.get_sysname() == "Darwin" and "clangd" or "ccls",
--- Custom config to pass to nvim-lspconfig
--- @type table|nil
lsp_config = {
capabilities = {
offsetEncoding = { "utf-16" },
},
},

--- disables null-ls formatting sources
--- @type boolean
Expand Down Expand Up @@ -51,12 +58,8 @@ cc.autocmds = {
"cpp,c",
langs_utils.wrap_language_setup("cc", function()
if not cc.settings.disable_lsp then
langs_utils.use_lsp_mason(cc.settings.language_server_name, {
config = {
capabilities = {
offsetEncoding = { "utf-16" },
}
}
langs_utils.use_lsp_mason(cc.settings.lsp_name, {
config = cc.settings.lsp_config,
})
end

Expand Down
10 changes: 8 additions & 2 deletions lua/doom/modules/langs/css/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ css.settings = {
disable_lsp = false,
--- Name of the language server
--- @type string
language_server_name = "cssls",
lsp_name = "cssls",
--- Custom config to pass to nvim-lspconfig
--- @type table|nil
lsp_config = nil,


--- Disables null-ls formatting sources
--- @type boolean
Expand Down Expand Up @@ -50,7 +54,9 @@ css.autocmds = {
"css,scss,vue,svelte,html",
langs_utils.wrap_language_setup("css", function()
if not css.settings.disable_lsp then
langs_utils.use_lsp_mason(css.settings.language_server_name)
langs_utils.use_lsp_mason(css.settings.lsp_name, {
config = css.settings.lsp_config,
})
end

if not css.settings.disable_treesitter then
Expand Down
9 changes: 7 additions & 2 deletions lua/doom/modules/langs/dockerfile/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ dockerfile.settings = {
disable_lsp = false,
--- Name of the language server
--- @type string
language_server_name = "dockerls",
lsp_name = "dockerls",
--- Custom config to pass to nvim-lspconfig
--- @type table|nil
lsp_config = nil,

--- Disables null-ls diagnostic sources
--- @type boolean
Expand All @@ -36,7 +39,9 @@ dockerfile.autocmds = {
"dockerfile",
langs_utils.wrap_language_setup("dockerfile", function()
if not dockerfile.settings.disable_lsp then
langs_utils.use_lsp_mason(dockerfile.settings.language_server_name)
langs_utils.use_lsp_mason(dockerfile.settings.lsp_name, {
config = dockerfile.settings.lsp_config,
})
end

if not dockerfile.settings.disable_treesitter then
Expand Down
7 changes: 0 additions & 7 deletions lua/doom/modules/langs/fish/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ fish.settings = {
--- @type string|string[]
treesitter_grammars = "fish",

-- --- Disables default LSP config
-- --- @type boolean
-- disable_lsp = false,
-- --- Name of the language server
-- --- @type string
-- language_server_name = "tsserver",

--- Disables null-ls formatting sources
--- @type boolean
disable_formatting = false,
Expand Down
14 changes: 7 additions & 7 deletions lua/doom/modules/langs/gdscript/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ gdscript.settings = {
--- @type string|string[]
treesitter_grammars = { "gdscript", "godot_resource" },

--- Disables default LSP config
--- @type boolean
disable_lsp = false,
--- Name of the language server
--- @type string
language_server_name = "tsserver",
-- --- Disables default LSP config
-- --- @type boolean
-- disable_lsp = false,
-- --- Name of the language server
-- --- @type string
-- lsp_name = "tsserver",

--- Disables null-ls formatting sources
--- @type boolean
Expand Down Expand Up @@ -50,7 +50,7 @@ gdscript.autocmds = {
langs_utils.wrap_language_setup("gdscript", function()

if not gdscript.settings.disable_lsp then
langs_utils.use_lsp_mason(gdscript.settings.language_server_name, {
langs_utils.use_lsp_mason(gdscript.settings.lsp_name, {
no_installer = true,
config = {
flags = {
Expand Down
4 changes: 2 additions & 2 deletions lua/doom/modules/langs/glsl/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ glsl.settings = {
-- disable_lsp = false,
-- --- Name of the language server
-- --- @type string
-- language_server_name = "tsserver",
-- lsp_name = "tsserver",

--- Disables null-ls diagnostic sources
--- @type boolean
Expand Down Expand Up @@ -41,7 +41,7 @@ glsl.autocmds = {
langs_utils.wrap_language_setup("glsl", function()

-- if not glsl.settings.disable_lsp then
-- langs_utils.use_lsp_mason(glsl.settings.language_server_name)
-- langs_utils.use_lsp_mason(glsl.settings.lsp_name)
-- end

if not glsl.settings.disable_treesitter then
Expand Down
10 changes: 8 additions & 2 deletions lua/doom/modules/langs/go/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ go.settings = {
disable_lsp = false,
--- Name of the language server
--- @type string
language_server_name = "gopls",
lsp_name = "gopls",
--- Custom config to pass to nvim-lspconfig
--- @type table|nil
lsp_config = nil,


--- Disables null-ls formatting sources
--- @type boolean
Expand Down Expand Up @@ -50,7 +54,9 @@ go.autocmds = {
langs_utils.wrap_language_setup("go", function()

if not go.settings.disable_lsp then
langs_utils.use_lsp_mason(go.settings.language_server_name)
langs_utils.use_lsp_mason(go.settings.lsp_name, {
config = go.settings.lsp_config,
})
end

if not go.settings.disable_treesitter then
Expand Down
9 changes: 7 additions & 2 deletions lua/doom/modules/langs/haskell/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ haskell.settings = {
disable_lsp = false,
--- Name of the language server
--- @type string
language_server_name = "hls",
lsp_name = "hls",
--- Custom config to pass to nvim-lspconfig
--- @type table|nil
lsp_config = nil,

--- Disables null-ls formatting sources
--- @type boolean
Expand All @@ -37,7 +40,9 @@ haskell.autocmds = {
langs_utils.wrap_language_setup("haskell", function()
if not haskell.settings.disable_lsp then
print("starting lsp")
langs_utils.use_lsp_mason(haskell.settings.language_server_name)
langs_utils.use_lsp_mason(haskell.settings.lsp_name, {
config = haskell.settings.lsp_config,
})
end

if not haskell.settings.disable_treesitter then
Expand Down
9 changes: 7 additions & 2 deletions lua/doom/modules/langs/html/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ html.settings = {
disable_lsp = false,
--- Name of the language server
--- @type string
language_server_name = "html",
lsp_name = "html",
--- Custom config to pass to nvim-lspconfig
--- @type table|nil
lsp_config = nil,

--- Disables null-ls formatting sources
--- @type boolean
Expand All @@ -40,7 +43,9 @@ html.autocmds = {
"*.html",
langs_utils.wrap_language_setup("html", function()
if not html.settings.disable_lsp then
langs_utils.use_lsp_mason(html.settings.language_server_name)
langs_utils.use_lsp_mason(html.settings.lsp_name, {
config = html.settings.lsp_config,
})
end

if not html.settings.disable_treesitter then
Expand Down
9 changes: 7 additions & 2 deletions lua/doom/modules/langs/java/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ java.settings = {
disable_lsp = false,
--- Name of the language server
--- @type string
language_server_name = "jdtls",
lsp_name = "jdtls",
--- Custom config to pass to nvim-lspconfig
--- @type table|nil
lsp_config = nil,

--- Disables null-ls formatting sources
--- @type boolean
Expand All @@ -37,7 +40,9 @@ java.autocmds = {
langs_utils.wrap_language_setup("java", function()

if not java.settings.disable_lsp then
langs_utils.use_lsp_mason(java.settings.language_server_name)
langs_utils.use_lsp_mason(java.settings.lsp_name, {
config = java.settings.lsp_config,
})
end

if not java.settings.disable_treesitter then
Expand Down
25 changes: 15 additions & 10 deletions lua/doom/modules/langs/json/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,18 @@ json.settings = {
disable_lsp = false,
--- Name of the language server
--- @type string
language_server_name = "jsonls",
lsp_name = "jsonls",
--- Custom config to pass to nvim-lspconfig
--- @type table|function|nil
lsp_config = function()
return {
settings = {
json = {
schemas = require("schemastore").json.schemas(),
},
},
}
end,

--- Disables null-ls formatting sources
--- @type boolean
Expand All @@ -33,7 +44,7 @@ json.packages = {
["SchemaStore.nvim"] = {
"b0o/SchemaStore.nvim",
commit = "f55842dc797faad8cf7b0d9ce75c59da654aa018",
ft = "json",
opt = true,
},
}

Expand All @@ -45,14 +56,8 @@ json.autocmds = {
langs_utils.wrap_language_setup("json", function()
vim.cmd("packadd SchemaStore.nvim")
if not json.settings.disable_lsp then
langs_utils.use_lsp_mason(json.settings.language_server_name, {
config = {
settings = {
json = {
schemas = require("schemastore").json.schemas(),
},
},
},
langs_utils.use_lsp_mason(json.settings.lsp_name, {
config = json.settings.lsp_config,
})
end

Expand Down
9 changes: 7 additions & 2 deletions lua/doom/modules/langs/kotlin/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ kotlin.settings = {
disable_lsp = false,
--- Name of the language server
--- @type string
language_server_name = "kotlin_language_server",
lsp_name = "kotlin_language_server",
--- Custom config to pass to nvim-lspconfig
--- @type table|nil
lsp_config = nil,

--- Disables null-ls formatting sources
--- @type boolean
Expand Down Expand Up @@ -49,7 +52,9 @@ kotlin.autocmds = {
"kotlin",
langs_utils.wrap_language_setup("kotlin", function()
if not kotlin.settings.disable_lsp then
langs_utils.use_lsp_mason(kotlin.settings.language_server_name)
langs_utils.use_lsp_mason(kotlin.settings.lsp_name, {
config = kotlin.settings.lsp_config,
})
end

if not kotlin.settings.disable_treesitter then
Expand Down
Loading

0 comments on commit 0e966de

Please sign in to comment.