1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
-- load standard vis module, providing parts of the Lua API
require('vis')
require('plugins/filetype')
require('plugins/textobject-lexer')
local cursors = require('plugins/vis-cursors')
cursors.cursors_path = string.format('%s/vis/cursors',
os.getenv('XDG_DATA_HOME') or
os.getenv('HOME') .. "/.local/share")
local spellcheck = require('plugins/vis-spellcheck')
spellcheck.list_cmd = 'hunspell -l -d %s'
spellcheck.cmd = 'hunspell -d %s'
require('plugins/vis-commentary')
require('plugins/vis-ctags')
-- This hooks vis.events.START so its fine to load it before the default settings
require('plugins/vis-modelines/vis-modelines')
local lspc = require('plugins/vis-lspc')
if next(lspc) then
lspc.logging = true
lspc.message_level = 2
lspc.ls_map.latex = { name = 'latex', cmd = 'texlab' }
lspc.ls_map.html = { name = 'html', cmd = 'vscode-html-languageserver --stdio' }
lspc.ls_map.typescript = { name = 'typescript', cmd = 'typescript-language-server --stdio' }
lspc.ls_map.java = { name = 'java', cmd = 'jdtls' }
lspc.ls_map.ltex = {
name = 'ltex',
cmd = 'ltex-ls --no-endless',
}
lspc.ls_map.python = {
name = 'python-lsp-server',
cmd = 'pylsp',
settings = {
pylsp = {
plugins = {
rope_completion = { "eager" },
rope_rename = { enabled = true },
pylsp_rope = { enabled = true },
},
},
},
}
vis.events.subscribe(lspc.events.LS_DID_OPEN, function(ls, file)
if ls.name == 'ltex' then
if not ls.settings then ls.settings = {} end
if not ls.settings.ltex then ls.settings.ltex = {} end
ls.settings.ltex.language = file.spelling_language:gsub('_', '-') or 'en-US'
end
end)
vis:map(vis.modes.VISUAL, ' rn', function()
vis:feedkeys(":lspc-rename ")
end, 'lspc: rename current symbol')
vis:map(vis.modes.NORMAL, '< -n>', function()
vis:command('lspc-next-diagnostic')
end, 'lspc: jump to next diagnostic')
vis:map(vis.modes.NORMAL, '< -N>', function()
vis:command('lspc-prev-diagnostic')
end, 'lspc: jump to prev diagnostic')
end
local lockfiles = require('plugins/vis-lockfiles')
lockfiles.change_file_on_abort = true
require('plugins/vis-snippets')
vis:map(vis.modes.NORMAL, "<C-s>", function()
vis:command('snippet')
end)
local build = require('plugins/vis-build')
build.get_default_build_cmd = function()
if os.getenv('PWD'):match('Unterricht') then
return "lesson-make"
end
return "make"
end
local fzf_open = require('plugins/vis-fzf-open')
fzf_open.fzf_path = "FZF_DEFAULT_COMMAND='rg --hidden -g !.git -l \"\"' fzf"
vis:map(vis.modes.NORMAL, ";o", function()
vis:command('fzf')
end)
require('plugins/suw')
local theme = "theme"
vis.events.subscribe(vis.events.INIT, function()
-- Your global configuration options
vis:command("set theme " .. theme)
end)
local inotify = require('plugins/vis-inotify')
inotify.add_recreate_watch('/home/muhq/.config/vis/themes/theme.lua', function(_)
vis:command("set theme " .. theme) -- reload vis theme
end, '-P')
-- seperate default settings into per file and per window to not override settings from
-- vis-editorconf which are set on FILE_OPEN
-- default file settings
vis.events.subscribe(vis.events.FILE_OPEN, function()
vis.options.autoindent = true
end)
-- default window settings
vis.events.subscribe(vis.events.WIN_OPEN, function(win)
local tabwidth = 4
win.options.tabwidth = tabwidth
win.options.numbers = true
win.options.showtabs = true
win.options.colorcolumn = 80
if win.file.name then
if win.file.name:find("COMMIT_EDITMSG") then
win.options.colorcolumn = 72
win:set_syntax("diff")
elseif win.file.name:find('meson.build') and win.syntax ~= 'meson' then
win:set_syntax('python')
elseif win.file.name:find('slides.md') then
win:set_syntax('slides')
end
if win.syntax == "python" or win.syntax == "rust" then
win.options.expandtab = true
vis:map(vis.modes.INSERT, '<Backspace>', function()
local found_tab = true
for selection in vis.win:selections_iterator() do
local pos = selection.pos
if not pos or pos < tabwidth or vis.win.file:content(pos - tabwidth, tabwidth) ~= string.rep(' ', tabwidth) then
found_tab = false
break
end
end
vis:feedkeys(string.rep('<vis-delete-char-prev>', found_tab and tabwidth or 1))
end)
end
end
end)
-- load plugins that hook FILE_OPEN or WIN_OPEN to change settings after hooks
-- with default settings
if vis:module_exist('editorconfig') then
require('plugins/vis-editorconfig')
else
vis:info('skip vis-editorconfig: editorconfig not available from lua')
end
vis:map(vis.modes.NORMAL, ";;", "<vis-window-next>")
vis:command_register('ltex', function()
vis:command('lspc-start-server ltex')
end)
|