-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
158 lines (140 loc) · 4.49 KB
/
init.lua
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
local function option(name, value, targets)
local t = targets
local v = value
if targets == nil then
t = {vim.o}
end
if value == nil then
v = true
end
for i, target in ipairs(t) do
target[name] = v
end
end
local buffer = {vim.o, vim.bo}
local window = {vim.o, vim.wo}
option('shortmess', vim.o.shm .. 'I')
option('incsearch')
option('ignorecase')
option('smartcase')
option('wildignorecase')
option('autoread')
option('showmode', false)
option('laststatus', 2)
option('ruler')
option('number', true, window)
option('hidden')
option('updatetime', 300)
option('timeoutlen', 500)
option('cmdheight', 2)
option('signcolumn', 'auto', window)
option('termguicolors')
option('completeopt', 'menu,menuone,noselect')
option('shortmess', vim.o.shortmess .. 'c')
option('mouse', 'a')
option('undofile', true, buffer)
option('cursorline', true, window)
option('wildmenu', false)
option('inccommand', 'split')
option('list', true, window)
option('mousemodel', 'extend')
vim.opt.formatoptions:remove { 't' }
vim.opt.formatoptions:append { '/' }
vim.g.mapleader = ' '
-- tab settings
option('smarttab')
option('expandtab', true, buffer)
option('shiftwidth', 4, buffer)
-- Disable matchparen as it causes stutters
-- vim.cmd([[let loaded_matchparen = 1]])
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup("plugins", {
defaults = {
lazy = true,
},
dev = {
path = vim.fn.stdpath('config') .. '/local_plugins',
},
})
-- GUI
option('guifont', 'Iosevka Term:h14')
-- Ensure buffers automatic buffer reloading. Uses silent to prevent error messages for command line window/search history.
vim.api.nvim_exec([[
augroup focus_checktime
au!
au FocusGained,BufEnter * :silent! checktime
augroup END
]], false)
-- Use spellchecking/wordbreaks in text buffers
vim.api.nvim_exec([[
augroup text_spellcheck
au!
au FileType tex,markdown setlocal spell linebreak
augroup END
]], false)
vim.filetype.add({
filename = {
['Config.uk'] = 'kconfig',
['Makefile.uk'] = 'make',
['Makefile.rules'] = 'make',
},
})
local uk_group = vim.api.nvim_create_augroup('unikraft', { })
vim.api.nvim_create_autocmd('FileType', {
group = uk_group,
pattern = {'make', 'kconfig'},
callback = function()
vim.opt_local.shiftwidth = 8
vim.opt_local.tabstop = 8
vim.opt_local.expandtab = false
end,
})
vim.filetype.add({
filename = {
['Kraftfile'] = 'yaml',
['.swcrc'] = 'json',
},
})
-- some additional keybinds
vim.api.nvim_set_keymap('n', ']q', '<cmd>cn<cr>', { silent = true, noremap = true })
vim.api.nvim_set_keymap('n', '[q', '<cmd>cp<cr>', { silent = true, noremap = true })
-- More convenient window navigation
vim.api.nvim_set_keymap('', '<m-c-up>', '<c-w>k', { silent = true, noremap = true })
vim.api.nvim_set_keymap('', '<m-c-down>', '<c-w>j', { silent = true, noremap = true })
vim.api.nvim_set_keymap('', '<m-c-left>', '<c-w>h', { silent = true, noremap = true })
vim.api.nvim_set_keymap('', '<m-c-right>', '<c-w>l', { silent = true, noremap = true })
-- Same for the terminal
for i, mode in ipairs{'t', 'i'} do
vim.api.nvim_set_keymap(mode, '<m-c-up>', '<C-\\><C-N><c-w>k', { silent = true, noremap = true })
vim.api.nvim_set_keymap(mode, '<m-c-down>', '<C-\\><C-N><c-w>j', { silent = true, noremap = true })
vim.api.nvim_set_keymap(mode, '<m-c-left>', '<C-\\><C-N><c-w>h', { silent = true, noremap = true })
vim.api.nvim_set_keymap(mode, '<m-c-right>', '<C-\\><C-N><c-w>l', { silent = true, noremap = true })
end
vim.keymap.set('n', '<m-k>', '<c-w>k', { silent = true, noremap = true })
vim.keymap.set('n', '<m-j>', '<c-w>j', { silent = true, noremap = true })
vim.keymap.set('n', '<m-h>', '<c-w>h', { silent = true, noremap = true })
vim.keymap.set('n', '<m-l>', '<c-w>l', { silent = true, noremap = true })
vim.keymap.set('t', '<esc>', function ()
local ft = vim.bo.filetype
if ft == 'fzf' or ft == 'lazygit' then
return '<esc>'
else
return '<c-\\><c-n>'
end
end, { expr = true })
-- git in nvim terminal
vim.api.nvim_exec([[
let $GIT_EDITOR = 'nvr -cc split --remote-wait'
autocmd FileType gitcommit,gitrebase set bufhidden=delete
]], false)