-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnvim.init.lua
More file actions
231 lines (214 loc) · 6.23 KB
/
nvim.init.lua
File metadata and controls
231 lines (214 loc) · 6.23 KB
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
224
225
226
227
228
229
230
231
-- lazy.nvim bootstrap
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", lazypath
})
end
vim.opt.rtp:prepend(lazypath)
-- lazy.nvim setup
require("lazy").setup({
{
'nvim-orgmode/orgmode',
event = {'BufReadPre', 'BufNewFile'},
config = function()
-- Setup orgmode
require('orgmode').setup({
org_agenda_files = '~/orgfiles/**/*',
org_default_notes_file = '~/orgfiles/refile.org',
})
end,
},
{ "RRethy/nvim-base16" },
{
"nvim-lualine/lualine.nvim",
config = function()
require("lualine").setup()
end,
},
{
'nvim-treesitter/nvim-treesitter',
lazy = false,
build = ':TSUpdate'
},
{
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"hrsh7th/vim-vsnip",
"hrsh7th/cmp-vsnip",
},
config = function()
local cmp = require("cmp")
cmp.setup({
snippet = {
expand = function(args) vim.fn["vsnip#anonymous"](args.body) end,
},
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(),
['<CR>'] = cmp.mapping.confirm({ select = false }),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'vsnip' },
{ name = 'path' }
}, {
{ name = 'buffer' }
}),
})
cmp.setup.cmdline('/', {
mapping = cmp.mapping.preset.cmdline(),
sources = {{ name = 'buffer' }}
})
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({{ name = 'path' }}, {{ name = 'cmdline' }})
})
end,
},
{
"neovim/nvim-lspconfig",
config = function()
local capabilities = require("cmp_nvim_lsp").default_capabilities(
vim.lsp.protocol.make_client_capabilities()
)
vim.lsp.config('ruff', {
capabilities = capabilities,
})
vim.lsp.config('clangd', {
capabilities = capabilities,
cmd = {
"clangd",
"--background-index",
"--clang-tidy",
"--completion-style=detailed",
"--header-insertion=iwyu",
},
filetypes = { "c", "cpp", "objc", "objcpp", "cuda", "proto" },
root_markers = {
".clangd",
".clang-tidy",
".clang-format",
"compile_commands.json",
"compile_flags.txt",
".git",
},
})
vim.lsp.enable('ruff')
vim.lsp.enable('clangd')
end
},
-- { "github/copilot.vim" },
{ "SeniorMars/typst.nvim" },
{ "onerobotics/vim-karel" },
{ "tweekmonster/django-plus.vim" },
{
"mxw/vim-jsx",
dependencies = { "pangloss/vim-javascript" },
},
{
"tinunkai/startup.nvim",
dependencies = {
"nvim-telescope/telescope.nvim",
"nvim-lua/plenary.nvim",
},
config = function()
require("startup").setup {
theme = "evil"
}
end
},
{ "wakatime/vim-wakatime" },
})
-- nvim-treesitter
vim.api.nvim_create_autocmd("FileType", {
pattern = {"c", "cpp", "cuda", "python", "rust", "lua"},
callback = function()
vim.treesitter.start()
vim.opt_local.foldexpr = "v:lua.vim.treesitter.foldexpr()"
vim.opt_local.foldmethod = "expr"
vim.opt_local.foldlevel = 99
end,
})
-- General Settings
vim.opt.termguicolors = true
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
vim.opt.encoding = "utf-8"
vim.opt.fileencodings = { "utf-8", "cp932", "euc-jp", "sjis" }
vim.opt.fileformats = { "unix", "dos", "mac" }
vim.g.mapleader = " "
vim.diagnostic.enable(false)
vim.api.nvim_create_autocmd("LspAttach", {
callback = function(args)
local opts = { buffer = args.buf }
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
vim.keymap.set("n", "<leader>E", function()
vim.diagnostic.open_float(nil, { scope = "line", border = "rounded", source = "if_many" })
end, opts)
end,
})
-- Appearance
vim.cmd [[
colorscheme base16-tomorrow-night
set colorcolumn=119
set cursorline
set cursorcolumn
set mouse=
]]
-- Keymaps
vim.cmd [[
nnoremap <Leader>w <cmd>Telescope live_grep<cr>
nnoremap <Leader>p <cmd>Telescope find_files<cr>
nnoremap <Leader>e <cmd>Telescope diagnostics<cr>
nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
nnoremap zi :set fdm=syntax<CR>
nnoremap zp :set fdm=indent<CR>
nnoremap <C-c> :wa<CR>:sp<CR><C-W>j:terminal<CR>i make<CR>
nnoremap <C-j> :tabn<CR>
nnoremap <C-k> :tabp<CR>
inoremap <C-o> <Esc>
tnoremap <C-o> <C-\><C-n>
nnoremap <C-n> :tab sp<CR>
nnoremap <silent> <esc> :noh<CR>
nnoremap j gj
nnoremap k gk
nnoremap 0 g0
nnoremap $ g$
nnoremap ^ g^
nnoremap gj j
nnoremap gk k
nnoremap g0 0
nnoremap g$ $
nnoremap g^ ^
]]
-- Autocommands
vim.cmd [[
autocmd FileType tex inoremap <silent> \bb \begin{equation}<CR>\end{equation}<Esc>ko
autocmd FileType tex inoremap <silent> \tb \textbf{<Esc>a
autocmd FileType tex inoremap <silent> \mr \mathrm{<Esc>a
autocmd FileType tex inoremap <silent> _max _{\mathrm{max}}<Esc>a
autocmd FileType tex inoremap <silent> _min _{\mathrm{min}}<Esc>a
autocmd FileType vimscript,javascript,javascriptreact,json,jinja,css,html,htmldjango,typescript,markdown,tex,lua,karel set tabstop=2|set shiftwidth=2|set expandtab
autocmd FileType c,cpp,cuda,python,dosbatch set tabstop=4|set shiftwidth=4|set expandtab
autocmd FileType go set tabstop=4|set shiftwidth=4
autocmd FileType make set tabstop=4|set shiftwidth=4
autocmd BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm set ft=htmldjango
autocmd BufNewFile,BufRead *.js set ft=javascriptreact
]]
-- END