diff --git a/README.md b/README.md index b36ea00d..0e676e60 100644 --- a/README.md +++ b/README.md @@ -185,6 +185,10 @@ You can change all available options using `gocode set` command. The config file A boolean option. If set to true, gocode will perform case-insensitive matching when doing prefix-based filtering. Default: **false**. + - *class-filtering* + + A boolean option. Enables or disables gocode's feature where it performs class-based filtering if partial input matches corresponding class keyword: const, var, type, func, package. Default: **true**. + ### Debugging If something went wrong, the first thing you may want to do is manually start the gocode daemon with a debug mode enabled and in a separate terminal window. It will show you all the stack traces, panics if any and additional info about autocompletion requests. Shutdown the daemon if it was already started and run a new one explicitly with a debug mode enabled: diff --git a/autocompletecontext.go b/autocompletecontext.go index aec6c53c..d5d4bc47 100644 --- a/autocompletecontext.go +++ b/autocompletecontext.go @@ -393,17 +393,19 @@ func (c *auto_complete_context) apropos(file []byte, filename string, cursor int } class := decl_invalid - switch cc.partial { - case "const": - class = decl_const - case "var": - class = decl_var - case "type": - class = decl_type - case "func": - class = decl_func - case "package": - class = decl_package + if g_config.ClassFiltering { + switch cc.partial { + case "const": + class = decl_const + case "var": + class = decl_var + case "type": + class = decl_type + case "func": + class = decl_func + case "package": + class = decl_package + } } if cc.decl_import { diff --git a/config.go b/config.go index 96d2fb6f..075c5c06 100644 --- a/config.go +++ b/config.go @@ -31,6 +31,7 @@ type config struct { UnimportedPackages bool `json:"unimported-packages"` Partials bool `json:"partials"` IgnoreCase bool `json:"ignore-case"` + ClassFiltering bool `json:"class-filtering"` } var g_config_desc = map[string]string{ @@ -45,6 +46,7 @@ var g_config_desc = map[string]string{ "unimported-packages": "If set to {true}, gocode will try to import certain known packages automatically for identifiers which cannot be resolved otherwise. Currently only a limited set of standard library packages is supported.", "partials": "If set to {false}, gocode will not filter autocompletion results based on entered prefix before the cursor. Instead it will return all available autocompletion results viable for a given context. Whether this option is set to {true} or {false}, gocode will return a valid prefix length for output formats which support it. Setting this option to a non-default value may result in editor misbehaviour.", "ignore-case": "If set to {true}, gocode will perform case-insensitive matching when doing prefix-based filtering.", + "class-filtering": "Enables or disables gocode's feature where it performs class-based filtering if partial input matches corresponding class keyword: const, var, type, func, package.", } var g_default_config = config{ @@ -58,6 +60,7 @@ var g_default_config = config{ UnimportedPackages: false, Partials: true, IgnoreCase: false, + ClassFiltering: true, } var g_config = g_default_config