-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for automatic per-buffer mappings
Closes #25 If `g:lsc_auto_map` is set, for each buffer that opens with a tracked filetype set up `<buffer>` maps. Can either configure defaults by setting to `v:true` or only the specified keys by setting to a dict. Update README for latest configuration options and mark for tagging the next version.
- Loading branch information
Showing
4 changed files
with
75 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
let s:default_maps = { | ||
\ 'GoToDefinition': '<C-]>', | ||
\ 'FindReferences': 'gr', | ||
\ 'ShowHover': 'K', | ||
\ 'Completion': 'completefunc', | ||
\} | ||
|
||
function! lsc#config#mapKeys() abort | ||
if !exists('g:lsc_auto_map') | ||
\ || (type(g:lsc_auto_map) == v:t_bool && !g:lsc_auto_map) | ||
\ || (type(g:lsc_auto_map) == v:t_number && !g:lsc_auto_map) | ||
return | ||
endif | ||
let maps = g:lsc_auto_map | ||
if type(maps) == v:t_bool || type(maps) == v:t_number | ||
let maps = s:default_maps | ||
endif | ||
if type(maps) != v:t_dict | ||
call lsc#util#error('g:lsc_auto_map must be a bool or dict') | ||
return | ||
endif | ||
|
||
for command in ['GoToDefinition', 'FindReferences', 'ShowHover'] | ||
if has_key(maps, command) | ||
execute 'nnoremap <buffer>'.maps[command].' :LSClient'.command.'<CR>' | ||
endif | ||
endfor | ||
if !g:lsc_enable_autocomplete && has_key(maps, 'Completion') | ||
execute 'setlocal '.maps['Completion'].'=lsc#complete#complete' | ||
endif | ||
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters