Skip to content

Commit 4166437

Browse files
committed
Add "class-filtering" config option.
1 parent fbb8716 commit 4166437

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ You can change all available options using `gocode set` command. The config file
185185

186186
A boolean option. If set to true, gocode will perform case-insensitive matching when doing prefix-based filtering. Default: **false**.
187187

188+
- *class-filtering*
189+
190+
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**.
191+
188192
### Debugging
189193

190194
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:

autocompletecontext.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -393,17 +393,19 @@ func (c *auto_complete_context) apropos(file []byte, filename string, cursor int
393393
}
394394

395395
class := decl_invalid
396-
switch cc.partial {
397-
case "const":
398-
class = decl_const
399-
case "var":
400-
class = decl_var
401-
case "type":
402-
class = decl_type
403-
case "func":
404-
class = decl_func
405-
case "package":
406-
class = decl_package
396+
if g_config.ClassFiltering {
397+
switch cc.partial {
398+
case "const":
399+
class = decl_const
400+
case "var":
401+
class = decl_var
402+
case "type":
403+
class = decl_type
404+
case "func":
405+
class = decl_func
406+
case "package":
407+
class = decl_package
408+
}
407409
}
408410

409411
if cc.decl_import {

config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type config struct {
3131
UnimportedPackages bool `json:"unimported-packages"`
3232
Partials bool `json:"partials"`
3333
IgnoreCase bool `json:"ignore-case"`
34+
ClassFiltering bool `json:"class-filtering"`
3435
}
3536

3637
var g_config_desc = map[string]string{
@@ -45,6 +46,7 @@ var g_config_desc = map[string]string{
4546
"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.",
4647
"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.",
4748
"ignore-case": "If set to {true}, gocode will perform case-insensitive matching when doing prefix-based filtering.",
49+
"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.",
4850
}
4951

5052
var g_default_config = config{
@@ -58,6 +60,7 @@ var g_default_config = config{
5860
UnimportedPackages: false,
5961
Partials: true,
6062
IgnoreCase: false,
63+
ClassFiltering: true,
6164
}
6265
var g_config = g_default_config
6366

0 commit comments

Comments
 (0)