aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile8
-rw-r--r--bindings.lua61
-rw-r--r--init.lua65
3 files changed, 69 insertions, 65 deletions
diff --git a/Makefile b/Makefile
index a43dff1..116c2a0 100644
--- a/Makefile
+++ b/Makefile
@@ -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')
diff --git a/init.lua b/init.lua
index f7a38de..5ef81a0 100644
--- a/init.lua
+++ b/init.lua
@@ -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