From 6fa767d87cd94c5237da8321ab5586b653185bd5 Mon Sep 17 00:00:00 2001 From: Dylan Le Date: Tue, 9 Aug 2022 12:16:47 -0400 Subject: [PATCH] internal/lsp: update documentation for directoryFilters setting and default value Add `**` usage to directoryFilters documentation. Change directoryFilters default value to `-**/node_modules` For golang/go#46438 Change-Id: I3ea14ad8a20893d19df4cf8d584a7c7f9b213aab Reviewed-on: https://go-review.googlesource.com/c/tools/+/422356 Run-TryBot: Robert Findley TryBot-Result: Gopher Robot gopls-CI: kokoro Reviewed-by: Robert Findley --- gopls/doc/settings.md | 8 ++++++-- internal/lsp/source/api_json.go | 4 ++-- internal/lsp/source/options.go | 8 ++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/gopls/doc/settings.md b/gopls/doc/settings.md index 890a0a3444..f71bbebdce 100644 --- a/gopls/doc/settings.md +++ b/gopls/doc/settings.md @@ -63,15 +63,19 @@ relative to the workspace folder. They are evaluated in order, and the last filter that applies to a path controls whether it is included. The path prefix can be empty, so an initial `-` excludes everything. +DirectoryFilters also supports the `**` operator to match 0 or more directories. + Examples: -Exclude node_modules: `-node_modules` +Exclude node_modules at current depth: `-node_modules` + +Exclude node_modules at any depth: `-**/node_modules` Include only project_a: `-` (exclude everything), `+project_a` Include only project_a, but not node_modules inside it: `-`, `+project_a`, `-project_a/node_modules` -Default: `["-node_modules"]`. +Default: `["-**/node_modules"]`. #### **templateExtensions** *[]string* diff --git a/internal/lsp/source/api_json.go b/internal/lsp/source/api_json.go index 0b3b3d117a..f6833fe3df 100755 --- a/internal/lsp/source/api_json.go +++ b/internal/lsp/source/api_json.go @@ -22,8 +22,8 @@ var GeneratedAPIJSON = &APIJSON{ { Name: "directoryFilters", Type: "[]string", - Doc: "directoryFilters can be used to exclude unwanted directories from the\nworkspace. By default, all directories are included. Filters are an\noperator, `+` to include and `-` to exclude, followed by a path prefix\nrelative to the workspace folder. They are evaluated in order, and\nthe last filter that applies to a path controls whether it is included.\nThe path prefix can be empty, so an initial `-` excludes everything.\n\nExamples:\n\nExclude node_modules: `-node_modules`\n\nInclude only project_a: `-` (exclude everything), `+project_a`\n\nInclude only project_a, but not node_modules inside it: `-`, `+project_a`, `-project_a/node_modules`\n", - Default: "[\"-node_modules\"]", + Doc: "directoryFilters can be used to exclude unwanted directories from the\nworkspace. By default, all directories are included. Filters are an\noperator, `+` to include and `-` to exclude, followed by a path prefix\nrelative to the workspace folder. They are evaluated in order, and\nthe last filter that applies to a path controls whether it is included.\nThe path prefix can be empty, so an initial `-` excludes everything.\n\nDirectoryFilters also supports the `**` operator to match 0 or more directories.\n\nExamples:\n\nExclude node_modules at current depth: `-node_modules`\n\nExclude node_modules at any depth: `-**/node_modules`\n\nInclude only project_a: `-` (exclude everything), `+project_a`\n\nInclude only project_a, but not node_modules inside it: `-`, `+project_a`, `-project_a/node_modules`\n", + Default: "[\"-**/node_modules\"]", Hierarchy: "build", }, { diff --git a/internal/lsp/source/options.go b/internal/lsp/source/options.go index 2f40b59ccf..096f1acf9a 100644 --- a/internal/lsp/source/options.go +++ b/internal/lsp/source/options.go @@ -119,7 +119,7 @@ func DefaultOptions() *Options { ExpandWorkspaceToModule: true, ExperimentalPackageCacheKey: true, MemoryMode: ModeNormal, - DirectoryFilters: []string{"-node_modules"}, + DirectoryFilters: []string{"-**/node_modules"}, TemplateExtensions: []string{}, }, UIOptions: UIOptions{ @@ -232,9 +232,13 @@ type BuildOptions struct { // the last filter that applies to a path controls whether it is included. // The path prefix can be empty, so an initial `-` excludes everything. // + // DirectoryFilters also supports the `**` operator to match 0 or more directories. + // // Examples: // - // Exclude node_modules: `-node_modules` + // Exclude node_modules at current depth: `-node_modules` + // + // Exclude node_modules at any depth: `-**/node_modules` // // Include only project_a: `-` (exclude everything), `+project_a` //