Skip to content

Commit

Permalink
Add commands for GoToDefinition and FindReferences
Browse files Browse the repository at this point in the history
Friendlier than calling a function, especially from autoload.
Commands use the prefix LSClient.
  • Loading branch information
natebosch committed May 20, 2017
1 parent 0ffbc18 commit 5beb21a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- More detail in completion suggestions, doc comment in preview window.
- Sort diagnostics in location list.
- Allow only 1 server command per filetype.
- Add commands for GoToDefinition and FindReferences

# 0.1.3

Expand Down
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ Install with your method of choice. If you don't have a preference check out
## Configuration

Map a filetype to the command that starts the language server for that filetype
in your `vimrc`. I also recommend a mapping to the function call to jump to
definition.
in your `vimrc`. I also recommend mapping shortcuts to the go to definition and
find references commands.

```viml
let g:lsc_server_commands = {'dart': 'dart_language_server'}
nnoremap gd :call lsc#reference#goToDefinition()<CR>
nnoremap gd :LSClientGoToDefinition<CR>
nnoremap gr :LSClientFindReferences<CR>
```

## Features
Expand Down Expand Up @@ -61,11 +62,11 @@ documentation in the preview window. Close the window after completion with

### Jump to definition

While the cursor is on any identifier call `lsc#reference#goToDefinition()` (see
above for recommended mapping) to jump to the location of the definition. If the
cursor moves before the server responds the response will be ignored.
While the cursor is on any identifier call `LSClientGoToDefinition` to jump to
the location of the definition. If the cursor moves before the server responds
the response will be ignored.

### Find references

While the cursor is on any identifier call `lsc#reference#findReferences()` to
populate the quickfix list with usage locations.
While the cursor is on any identifier call `LSClientFindReferences` to populate
the quickfix list with usage locations.
3 changes: 3 additions & 0 deletions plugin/lsc.vim
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ if !exists('g:lsc_server_commands')
let g:lsc_server_commands = {}
endif

command! LSClientGoToDefinition call lsc#reference#goToDefinition()
command! LSClientFindReferences call lsc#reference#findReferences()

" RegisterLanguageServer
"
" Registers a command as the server to start the first time a file with type
Expand Down

0 comments on commit 5beb21a

Please sign in to comment.