Skip to content

Commit

Permalink
refactor: export ws markers - 7
Browse files Browse the repository at this point in the history
  • Loading branch information
kylo252 committed Nov 10, 2022
1 parent a335f50 commit 1a4360a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 36 deletions.
8 changes: 5 additions & 3 deletions lua/lspconfig/server_configurations/eslint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if is_windows then
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
end

local root_file = {
local workspace_markers = {
'.eslintrc',
'.eslintrc.js',
'.eslintrc.cjs',
Expand All @@ -57,7 +57,7 @@ if root_with_package then
local path_sep = is_windows and '\\' or '/'
for line in io.lines(root_with_package .. path_sep .. 'package.json') do
if line:find 'eslintConfig' then
table.insert(root_file, 'package.json')
table.insert(workspace_markers, 'package.json')
break
end
end
Expand All @@ -77,8 +77,9 @@ return {
'svelte',
'astro',
},
workspace_markers = workspace_markers,
-- https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-file-formats
root_dir = util.root_pattern(unpack(root_file)),
root_dir = util.root_pattern(unpack(workspace_markers)),
-- Refer to https://github.com/Microsoft/vscode-eslint#settings-options for documentation.
settings = {
validate = 'on',
Expand Down Expand Up @@ -185,5 +186,6 @@ Messages handled in lspconfig: `eslint/openDoc`, `eslint/confirmESLintExecution`
Additional messages you can handle: `eslint/noConfig`
]],
workspace_markers = workspace_markers,
},
}
14 changes: 5 additions & 9 deletions lua/lspconfig/server_configurations/gradle_ls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,16 @@ if vim.fn.has 'win32' == 1 then
bin_name = bin_name .. '.bat'
end

local root_files = {
local workspace_markers = {
'settings.gradle', -- Gradle (multi-project)
}

local fallback_root_files = {
'build.gradle', -- Gradle
'build.gradle', -- Gradle (fallback)
}

return {
default_config = {
filetypes = { 'groovy' },
root_dir = function(fname)
return util.root_pattern(unpack(root_files))(fname) or util.root_pattern(unpack(fallback_root_files))(fname)
end,
workspace_markers = workspace_markers,
root_dir = util.root_pattern(unpack(workspace_markers)),
cmd = { bin_name },
-- gradle-language-server expects init_options.settings to be defined
init_options = {
Expand All @@ -36,7 +32,7 @@ Microsoft's lsp server for gradle files
If you're setting this up manually, build vscode-gradle using `./gradlew installDist` and point `cmd` to the `gradle-language-server` generated in the build directory
]],
default_config = {
root_dir = [[root_pattern("settings.gradle")]],
workspace_markers = workspace_markers,
cmd = { 'gradle-language-server' },
init_options = {
settings = {
Expand Down
19 changes: 5 additions & 14 deletions lua/lspconfig/server_configurations/hls.lua
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
local util = require 'lspconfig.util'

local workspace_markers = { 'hie.yaml', 'stack.yaml', 'cabal.project', '*.cabal', 'package.yaml' }

return {
default_config = {
cmd = { 'haskell-language-server-wrapper', '--lsp' },
filetypes = { 'haskell', 'lhaskell' },
root_dir = function(filepath)
return (
util.root_pattern('hie.yaml', 'stack.yaml', 'cabal.project')(filepath)
or util.root_pattern('*.cabal', 'package.yaml')(filepath)
)
end,
workspace_markers = workspace_markers,
root_dir = util.root_pattern(unpack(workspace_markers)),
single_file_support = true,
settings = {
haskell = {
Expand Down Expand Up @@ -42,14 +40,7 @@ Haskell Language Server
]],

default_config = {
root_dir = [[
function (filepath)
return (
util.root_pattern('hie.yaml', 'stack.yaml', 'cabal.project')(filepath)
or util.root_pattern('*.cabal', 'package.yaml')(filepath)
)
end
]],
workspace_markers = workspace_markers,
},
},
}
16 changes: 6 additions & 10 deletions lua/lspconfig/server_configurations/kotlin_language_server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,20 @@ end
-- These are configuration files for the various build systems supported by
-- Kotlin. I am not sure whether the language server supports Ant projects,
-- but I'm keeping it here as well since Ant does support Kotlin.
local root_files = {
local workspace_markers = {
'settings.gradle', -- Gradle (multi-project)
'settings.gradle.kts', -- Gradle (multi-project)
'build.xml', -- Ant
'pom.xml', -- Maven
}

local fallback_root_files = {
'build.gradle', -- Gradle
'build.gradle.kts', -- Gradle
'build.gradle', -- Gradle (fallback)
'build.gradle.kts', -- Gradle (fallback)
}

return {
default_config = {
filetypes = { 'kotlin' },
root_dir = function(fname)
return util.root_pattern(unpack(root_files))(fname) or util.root_pattern(unpack(fallback_root_files))(fname)
end,
workspace_markers = workspace_markers,
root_dir = util.root_pattern(unpack(workspace_markers)),
cmd = { bin_name },
},
docs = {
Expand All @@ -46,7 +42,7 @@ return {
Note that there is no LICENSE specified yet.
]],
default_config = {
root_dir = [[root_pattern("settings.gradle")]],
workspace_markers = workspace_markers,
cmd = { 'kotlin-language-server' },
capabilities = [[
smart code completion,
Expand Down

0 comments on commit 1a4360a

Please sign in to comment.