Skip to content

Commit

Permalink
Add "class-filtering" config option.
Browse files Browse the repository at this point in the history
  • Loading branch information
nsf committed Jan 7, 2018
1 parent fbb8716 commit 4166437
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
24 changes: 13 additions & 11 deletions autocompletecontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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{
Expand All @@ -58,6 +60,7 @@ var g_default_config = config{
UnimportedPackages: false,
Partials: true,
IgnoreCase: false,
ClassFiltering: true,
}
var g_config = g_default_config

Expand Down

0 comments on commit 4166437

Please sign in to comment.