diff --git a/src/languageserverinstance.jl b/src/languageserverinstance.jl index a509cb53..63babb1a 100644 --- a/src/languageserverinstance.jl +++ b/src/languageserverinstance.jl @@ -42,6 +42,7 @@ mutable struct LanguageServerInstance lint_options::StaticLint.LintOptions lint_missingrefs::Symbol lint_disableddirs::Vector{String} + lint_ignoredglobs::Vector{String} completion_mode::Symbol inlay_hints::Bool inlay_hints_variable_types::Bool @@ -85,7 +86,8 @@ mutable struct LanguageServerInstance true, StaticLint.LintOptions(), :all, - LINT_DIABLED_DIRS, + LINT_DISABLED_DIRS, + LINT_IGNORED_GLOBS, :qualify, # options: :import or :qualify, anything else turns this off false, true, diff --git a/src/requests/init.jl b/src/requests/init.jl index eb5580b1..696d939d 100644 --- a/src/requests/init.jl +++ b/src/requests/init.jl @@ -97,10 +97,17 @@ end function load_folder(path::String, server) if load_rootpath(path) + ignoredGlobs = Regex.(joinpath.(Ref(path), server.lint_ignoredglobs)) try for (root, _, files) in walkdir(path, onerror=x -> x) + if any(occursin.(ignoredGlobs, Ref(root))) + continue + end for file in files filepath = joinpath(root, file) + if any(occursin.(ignoredGlobs, Ref(filepath))) + continue + end if isvalidjlfile(filepath) uri = filepath2uri(filepath) if hasdocument(server, uri) @@ -196,6 +203,8 @@ function initialized_notification(params::InitializedParams, server::LanguageSer ) end + request_julia_config(server, conn) + if server.workspaceFolders !== nothing server.workspace = JuliaWorkspace(Set(filepath2uri.(server.workspaceFolders))) @@ -212,8 +221,6 @@ function initialized_notification(params::InitializedParams, server::LanguageSer end end - request_julia_config(server, conn) - if server.number_of_outstanding_symserver_requests > 0 create_symserver_progress_ui(server) end diff --git a/src/requests/workspace.jl b/src/requests/workspace.jl index 2caadcdf..43809422 100644 --- a/src/requests/workspace.jl +++ b/src/requests/workspace.jl @@ -88,7 +88,8 @@ end isnothing(::Nothing) = true end -const LINT_DIABLED_DIRS = ["test", "docs"] +const LINT_DISABLED_DIRS = ["test", "docs"] +const LINT_IGNORED_GLOBS = ["\\..*"] function request_julia_config(server::LanguageServerInstance, conn) (ismissing(server.clientCapabilities.workspace) || server.clientCapabilities.workspace.configuration !== true) && return @@ -111,29 +112,33 @@ function request_julia_config(server::LanguageServerInstance, conn) ConfigurationItem(missing, "julia.inlayHints.static.enabled"), ConfigurationItem(missing, "julia.inlayHints.static.variableTypes.enabled"), ConfigurationItem(missing, "julia.inlayHints.static.parameterNames.enabled"), + ConfigurationItem(missing, "julia.lint.ignoredGlobs"), ])) new_runlinter = something(response[11], true) new_SL_opts = StaticLint.LintOptions(response[1:10]...) new_lint_missingrefs = Symbol(something(response[12], :all)) - new_lint_disableddirs = something(response[13], LINT_DIABLED_DIRS) + new_lint_disableddirs = something(response[13], LINT_DISABLED_DIRS) new_completion_mode = Symbol(something(response[14], :import)) inlayHints = something(response[15], true) inlayHintsVariableTypes = something(response[16], true) inlayHintsParameterNames = Symbol(something(response[17], :literals)) + new_lint_ignoredglobs = something(response[18], LINT_IGNORED_GLOBS) rerun_lint = begin any(getproperty(server.lint_options, opt) != getproperty(new_SL_opts, opt) for opt in fieldnames(StaticLint.LintOptions)) || server.runlinter != new_runlinter || server.lint_missingrefs != new_lint_missingrefs || - server.lint_disableddirs != new_lint_disableddirs + server.lint_disableddirs != new_lint_disableddirs || + server.lint_ignoredglobs != new_lint_ignoredglobs end server.lint_options = new_SL_opts server.runlinter = new_runlinter server.lint_missingrefs = new_lint_missingrefs server.lint_disableddirs = new_lint_disableddirs + server.lint_ignoredglobs = new_lint_ignoredglobs server.completion_mode = new_completion_mode server.inlay_hints = inlayHints server.inlay_hints_variable_types = inlayHintsVariableTypes diff --git a/test/test_juliaworkspace.jl b/test/test_juliaworkspace.jl index 404890cc..906ee09e 100644 --- a/test/test_juliaworkspace.jl +++ b/test/test_juliaworkspace.jl @@ -113,3 +113,36 @@ end jw = delete_file(jw, project_file_uri) @test !haskey(jw._packages, project_uri) end + +@testitem "load_folder" begin + using LanguageServer: filepath2uri, load_folder, hasdocument + + include("test_shared_server.jl") + pkg_root = abspath(joinpath(@__DIR__, "..")) + + filepath = "test/test_juliaworkspace.jl" + + empty!(server._documents) + load_folder(pkg_root, server) + + uri = filepath2uri(joinpath(pkg_root, filepath)) + @test hasdocument(server, uri) + + server.lint_ignoredglobs = [ + "\\..*", + filepath, + ] + empty!(server._documents) + load_folder(pkg_root, server) + + @test !hasdocument(server, uri) + + server.lint_ignoredglobs = [ + "\\..*", + "test", + ] + empty!(server._documents) + load_folder(pkg_root, server) + + @test !hasdocument(server, uri) +end