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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
--<misc section>
vim.bo.modeline = false --disable modeline
vim.wo.number = false --???
vim.wo.wrap = true --enable *visual* auto-wrapping
vim.opt.autoindent = false --copy indent from current line when starting a new one
vim.opt.wildmode = 'longest,list,full'
vim.opt.smartindent = true --do smart autoindenting when starting a new line
vim.opt.hlsearch = true --highlight search
vim.opt.incsearch = true --incremental search
vim.opt.ignorecase = true --ignore case for search
vim.opt.smartcase = true --consider case if search pattern contains uppercase
vim.opt.laststatus = 0 --last window will have a status line: 0: never
vim.opt.ruler = true --show "line, column number" of cursor position
vim.opt.termguicolors = true --enables 24-bit RGB color in the |TUI|
vim.opt.cursorline = false --highlight the text line of the cursor
vim.opt.cursorcolumn = false --highlight the screen column of the cursor
vim.opt.shortmess = 'atF' --helps to avoid |hit-enter| prompts
vim.opt.encoding = 'utf-8'
vim.opt.path:append('~/.config/nvim/lua/')
vim.opt.suffixesadd = '.lua' --used when searching for a file w/ gf [I etc
vim.opt.fileencoding = 'utf-8'
vim.opt.expandtab = true --replace Tab with spaces
vim.opt.tabstop = 2 --replace Tab with spaces
vim.opt.shiftwidth = 2 --replace Tab with spaces
vim.opt.splitbelow = true --default split behavior for new windows
vim.opt.splitright = true --default split behavior
vim.opt.spellfile = os.getenv("HOME") .. '/.dictwords.utf-8.add' --added words
vim.opt.list = false --show tabs as pale >
vim.opt.listchars = 'space:*,tab:->\\'
vim.opt.autoread = true -- auto reload file when changed from outside
vim.opt.textwidth = 0
vim.wo.colorcolumn = '0'
--<https://github.com/Konfekt/vim-langtool section>
vim.g.langtool_jar='/tmp/LanguageTool-6.3/languagetool-commandline.jar'
--<completion section>
local cmp = require('cmp')
cmp.setup({
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
end,
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<Tab>'] = cmp.mapping.select_next_item(),
['<S-Tab>'] = cmp.mapping.select_prev_item(),
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'fuzzy_buffer' },
--{ name = 'look' }, --words in a dictionary slow
{ name = 'cmp_ctags' },
{ name = 'luasnip' },
}, {
{ name = 'buffer' },
})
})
cmp.setup.cmdline('/', {
sources = cmp.config.sources({
{ name = 'fuzzy_buffer' }
})
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
--<colorscheme section>
require("nord").setup({
transparent = true, --disable setting the background color
terminal_colors = true, --colors for :terminal in Neovim
diff = { mode = "bg" }, --color backgrounds in diff mode [bg|fg]
borders = true --visible border between verticaly split windows
})
vim.cmd.colorscheme("nord")
--vim.cmd('colorscheme blue') --no
--vim.cmd('colorscheme darkblue') --no
--vim.cmd('colorscheme elflord') --no
--vim.cmd('colorscheme evening') --no
--vim.cmd('colorscheme industry') --no
--vim.cmd('colorscheme murphy') --no
--vim.cmd('colorscheme pablo') --no
--vim.cmd('colorscheme peachpuff') --pink
--vim.cmd('colorscheme ron') --aqua everywhere
--vim.cmd('colorscheme torte') --no
--vim.cmd('colorscheme zellner') --white bright
--vim.cmd('colorscheme slate') --pragmatic bright
--vim.cmd('colorscheme shine') --retarded bright
--vim.cmd('colorscheme delek') --retarded bright
--vim.cmd('colorscheme morning') --slightly less retarded bright
--vim.cmd('colorscheme koehler') --norm
--vim.cmd('colorscheme desert') --norm
--<autocmds section>
vim.api.nvim_create_autocmd('BufRead', { --restore last cursor position
callback = function(opts)
vim.api.nvim_create_autocmd('BufWinEnter', {
once = true,
buffer = opts.buf,
callback = function()
local ft = vim.bo[opts.buf].filetype
local last_known_line = vim.api.nvim_buf_get_mark(opts.buf, '"')[1]
if
not (ft:match 'commit' and ft:match 'rebase')
and last_known_line > 1
and last_known_line <= vim.api.nvim_buf_line_count(opts.buf)
then
vim.api.nvim_feedkeys([[g`"]], 'nx', false)
end
end,
})
end,
})
local group = vim.api.nvim_create_augroup("filetypedetect", { clear = true })
vim.api.nvim_create_autocmd({"BufRead","BufNewFile"}, {
group = group,
pattern = {"*mutt-*"},
callback = function ()
vim.cmd("setfiletype mail")
end
})
vim.api.nvim_create_autocmd({"TermEnter"}, {
callback = function ()
vim.opt.scrolloff = 0
vim.opt.spell = false
end
})
vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
pattern = {"*.md", "*.txt"},
callback = function ()
vim.opt.scrolloff = 999
-- vim.opt.textwidth = 0
vim.opt.spell = true
vim.opt.spelllang = 'en_us'
--]s to jump to next spelling error (incl. regional)
--]S to jump to next spelling error (not incl. regional)
--z= on incorrect word for suggestions
--zg to add to dictionary
end
})
local unlim_line_length = function()
vim.opt.formatoptions:remove('t')
vim.wo.colorcolumn = ''
end
vim.api.nvim_create_autocmd({'BufNewFile','BufRead'}, {
pattern = {'*sfeedrc*','/tmp/qmv*','/tmp/calcurse-note*','/tmp/dl.sh'},
callback = unlim_line_length,
})
vim.api.nvim_create_autocmd('BufRead', {
pattern = '*.bbcode',
callback = function() vim.opt.filetype = 'bbcode' end,
})
-- vim.api.nvim_create_autocmd('BufRead', {
-- pattern = '/tmp/calcurse*',
-- callback = function() vim.opt.filetype = 'markdown' end,
-- })
vim.api.nvim_create_autocmd({'BufNewFile','BufRead'}, {
pattern = '/tmp/crontab.*',
callback = function() vim.wo.colorcolumn = '' end,
})
vim.api.nvim_create_autocmd('BufWritePre', { --auto del trail whitespace
pattern = '*',
command = ':%s/\\s\\+$//e',
})
vim.api.nvim_create_autocmd('BufRead', {
pattern = '*.c',
command = '1;/{',
})
--<keymapping section>
vim.keymap.set('n', '<Up>', '<Nop>') --disable arrow keys
vim.keymap.set('n', '<Down>', '<Nop>') --disable arrow keys
vim.keymap.set('n', '<Left>', '<Nop>') --disable arrow keys
vim.keymap.set('n', '<Right>', '<Nop>') --disable arrow keys
vim.keymap.set('n', 'gf', '<C-w><C-f>') --go to file under cursor
vim.keymap.set('v', '<', '<gv') --retain selection on indent
vim.keymap.set('v', '>', '>gv') --retain selection on indent
vim.keymap.set('n', '<F6>', ':setlocal spell! spelllang=en_us<cr>')
vim.keymap.set('n', '<C-k>', '<C-w>k') --buffer navigation
vim.keymap.set('n', '<C-j>', '<C-w>j') --buffer navigation
vim.keymap.set('n', '<C-l>', '<C-w>l') --buffer navigation
vim.keymap.set('n', '<C-h>', '<C-w>h') --buffer navigation
-- Cntrl-] to jump to definition
vim.keymap.set('n', '<C-[>', '<C-t>') --jump back from definition
vim.keymap.set('n', 'S', ':%s//g<Left><Left>') --search and replace
vim.g.mapleader = ';'
vim.keymap.set('t', '<Leader><Esc>', '<C-\\><C-N>') --make Esc work in terminal
vim.keymap.set('n', '<Leader>cfi', 'iint ){<cr>return 0;<cr>}<ESC>kkf)i') --new int i C function
vim.keymap.set('n', '<Leader>cfv', 'ivoid )<cr>{<cr>return;<cr>}<ESC>kkkf)i') --new void i C function
vim.keymap.set('n', '<Leader>ch', ':e %:p:s,.h$,.X123X,:s,.c$,.h,:s,.X123X$,.c,<CR>') --switch between .h and .c files
vim.keymap.set('v', '<Leader>y', '"+y') --copy to system clipboard
vim.keymap.set('n', '<Leader>y', '"+y') --copy to system clipboard
vim.keymap.set('n', '<Leader>yy', '"+yy') --copy to system clipboard
vim.keymap.set('n', '<Leader>p', '"+p') --paste from system clipboard
vim.keymap.set('n', '<Leader>P', '"+P') --paste from system clipboard
vim.keymap.set('v', '<Leader>p', '"+p') --paste from system clipboard
vim.keymap.set('v', '<Leader>P', '"+p') --paste from system clipboard
vim.keymap.set('n', '<Leader>a', ':lua vim.lsp.buf.code_action()<cr>') --LSP suggested action
--<toggleterm-plugin section>
require('toggleterm').setup({
open_mapping = '<C-g>',
direction = 'horizontal',
shade_terminals = true
})
--<Comment-plugin section>
require('Comment').setup() --gc = comment selection, gcc = comment line
require("nvim-surround").setup({
surrounds = {
["S"] = { add = { "<emphasis>" , "</emphasis>" } },
["C"] = { add = { "<code>" , "</code>" } },
["J"] = { add = { "<strong>" , "</strong>" } },
}
})
|