diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2021-08-02 22:18:31 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2021-08-02 22:18:31 +0200 |
| commit | 85e8aced46fecc5acbdf96bac5dc3af6217ba16e (patch) | |
| tree | a0e2b3b6894b7ac4421fb900ddd65f3f1c228d3a | |
| parent | 8ed38b8d12679c1ea9f71edcf8f8c2511b4cd5fb (diff) | |
| download | vis-lspc-85e8aced46fecc5acbdf96bac5dc3af6217ba16e.tar.gz vis-lspc-85e8aced46fecc5acbdf96bac5dc3af6217ba16e.zip | |
extract bindings into a seperate source file
| -rw-r--r-- | Makefile | 8 | ||||
| -rw-r--r-- | bindings.lua | 61 | ||||
| -rw-r--r-- | init.lua | 65 |
3 files changed, 69 insertions, 65 deletions
@@ -1,15 +1,17 @@ .PHONY: check format check-luacheck check-format +LUA_FILES := $(shell find -name "*.lua" -not -path "./json.lua") + # bash's process substitution is used for check-format SHELL := /bin/bash check: check-luacheck check-format check-luacheck: - luacheck --globals=vis -- init.lua + luacheck --globals=vis -- $(LUA_FILES) check-format: - diff init.lua <(lua-format init.lua) >/dev/null + for lf in $(LUA_FILES); do diff $$lf <(lua-format $$lf) >/dev/null; done format: - lua-format -i init.lua + lua-format -i $(LUA_FILES) diff --git a/bindings.lua b/bindings.lua new file mode 100644 index 0000000..08ce1c9 --- /dev/null +++ b/bindings.lua @@ -0,0 +1,61 @@ +-- Copyright (c) 2021 Florian Fischer. All rights reserved. +-- Use of this source code is governed by a MIT license found in the LICENSE file. +-- vis-lspc default bindings +vis:map(vis.modes.NORMAL, '<F2>', function() + vis:command('lspc-start-server') +end, 'lspc: start lsp server') + +vis:map(vis.modes.NORMAL, '<F3>', function() + vis:command('lspc-open') +end, 'lspc: open current file') + +vis:map(vis.modes.NORMAL, '<C-]>', function() + vis:command('lspc-definition') +end, 'lspc: jump to definition') + +vis:map(vis.modes.NORMAL, '<C-t>', function() + vis:command('lspc-back') +end, 'lspc: go back position stack') + +vis:map(vis.modes.NORMAL, '<C- >', function() + vis:command('lspc-completion') +end, 'lspc: completion') + +vis:map(vis.modes.INSERT, '<C- >', function() + vis:command('lspc-completion') + vis.mode = vis.modes.INSERT +end, 'lspc: completion') + +-- bindings inspired by nvim +-- https://github.com/neovim/nvim-lspconfig +vis:map(vis.modes.NORMAL, 'gD', function() + vis:command('lspc-declaration') +end, 'lspc: jump to declaration') + +vis:map(vis.modes.NORMAL, 'gd', function() + vis:command('lspc-definition') +end, 'lspc: jump to definition') + +vis:map(vis.modes.NORMAL, 'gi', function() + vis:command('lspc-implementation') +end, 'lspc: jump to implementation') + +vis:map(vis.modes.NORMAL, 'gr', function() + vis:command('lspc-references') +end, 'lspc: show references') + +vis:map(vis.modes.NORMAL, ' D', function() + vis:command('lspc-typeDefinition') +end, 'lspc: jump to type definition') + +vis:map(vis.modes.NORMAL, ' e', function() + vis:command('lspc-show-diagnostics') +end, 'lspc: show diagnostic of current line') + +vis:map(vis.modes.NORMAL, 'K', function() + vis:command('lspc-hover') +end, 'lspc: hover over current position') + +vis:map(vis.modes.NORMAL, '<C-k>', function() + vis:command('lspc-signature-help') +end, 'lspc: signature help') @@ -1350,71 +1350,12 @@ vis.events.subscribe(vis.events.FILE_OPEN, function(file) lspc_open(ls, win, file) end) --- vis-lspc default bindings - -vis:map(vis.modes.NORMAL, '<F2>', function() - vis:command('lspc-start-server') -end, 'lspc: start lsp server') - -vis:map(vis.modes.NORMAL, '<F3>', function() - vis:command('lspc-open') -end, 'lspc: open current file') - -vis:map(vis.modes.NORMAL, '<C-]>', function() - vis:command('lspc-definition') -end, 'lspc: jump to definition') - -vis:map(vis.modes.NORMAL, '<C-t>', function() - vis:command('lspc-back') -end, 'lspc: go back position stack') - -vis:map(vis.modes.NORMAL, '<C- >', function() - vis:command('lspc-completion') -end, 'lspc: completion') - -vis:map(vis.modes.INSERT, '<C- >', function() - vis:command('lspc-completion') - vis.mode = vis.modes.INSERT -end, 'lspc: completion') - --- bindings inspired by nvim --- https://github.com/neovim/nvim-lspconfig - -vis:map(vis.modes.NORMAL, 'gD', function() - vis:command('lspc-declaration') -end, 'lspc: jump to declaration') - -vis:map(vis.modes.NORMAL, 'gd', function() - vis:command('lspc-definition') -end, 'lspc: jump to definition') - -vis:map(vis.modes.NORMAL, 'gi', function() - vis:command('lspc-implementation') -end, 'lspc: jump to implementation') - -vis:map(vis.modes.NORMAL, 'gr', function() - vis:command('lspc-references') -end, 'lspc: show references') - -vis:map(vis.modes.NORMAL, ' D', function() - vis:command('lspc-typeDefinition') -end, 'lspc: jump to type definition') - -vis:map(vis.modes.NORMAL, ' e', function() - vis:command('lspc-show-diagnostics') -end, 'lspc: show diagnostic of current line') - -vis:map(vis.modes.NORMAL, 'K', function() - vis:command('lspc-hover') -end, 'lspc: hover over current position') - -vis:map(vis.modes.NORMAL, '<C-k>', function() - vis:command('lspc-signature-help') -end, 'lspc: signature help') - vis:option_register('lspc-highlight-diagnostics', 'bool', function(value) lspc.highlight_diagnostics = value return true end, 'Should lspc highlight diagnostics if available') +local source_str = debug.getinfo(1, 'S').source:sub(2) +local script_path = source_str:match('(.*/)') +dofile(script_path .. 'bindings.lua') return lspc |
