-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinit.lua
More file actions
221 lines (185 loc) · 7.06 KB
/
init.lua
File metadata and controls
221 lines (185 loc) · 7.06 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
local Plug = vim.fn['plug#']
vim.call('plug#begin')
Plug('nvim-lua/plenary.nvim')
Plug('tpope/vim-surround')
Plug('christoomey/vim-tmux-navigator')
Plug('djoshea/vim-autoread')
Plug('wakatime/vim-wakatime')
Plug('jiangmiao/auto-pairs')
Plug('nvim-treesitter/nvim-treesitter', { ['do'] = ':TSUpdate' })
Plug('nvim-treesitter/nvim-treesitter-textobjects')
Plug('preservim/nerdtree')
Plug('numToStr/Comment.nvim')
Plug('stevearc/oil.nvim')
-- theme
Plug('ellisonleao/gruvbox.nvim')
-- juypter
Plug('quarto-dev/quarto-nvim')
Plug('jmbuhr/otter.nvim')
Plug('benlubas/molten-nvim', { ['do'] = ':UpdateRemotePlugins', ['version'] = '^1.0.0' })
-- lsp
Plug('williamboman/mason.nvim')
Plug('williamboman/mason-lspconfig.nvim')
Plug('neovim/nvim-lspconfig')
-- autocomplete
Plug('hrsh7th/nvim-cmp')
Plug('hrsh7th/cmp-nvim-lsp')
Plug('hrsh7th/cmp-buffer')
Plug('Exafunction/codeium.vim')
-- git
Plug('tpope/vim-fugitive')
Plug('vincent178/nvim-github-linker')
-- fuzzy finder
Plug('ibhagwan/fzf-lua', { ['branch'] = 'main' })
vim.call('plug#end')
vim.g.mapleader = " "
vim.opt.background = "dark" -- or "light" for light mode
vim.opt.swapfile = false -- boolean: use a swapfile for the buffer
vim.opt.mouse = 'a' -- string, global: Enable mouse support, 'a' for all previous modes
vim.opt.number = true -- boolean: show line numbers
vim.opt.relativenumber = true -- boolean: show relative line numbers
vim.opt.signcolumn = "yes" -- string: show the sign column
-- Encoding
vim.opt.encoding = 'utf8' -- string: string encoding to use
vim.opt.fileencoding = 'utf8' -- string: file encoding to use
-- Search
vim.opt.incsearch = true -- boolean
vim.opt.hlsearch = true -- boolean
vim.opt.smartcase = true -- boolean: override the 'ignorecase' option if the search pattern contains upper case characters.
vim.opt.ignorecase = true -- boolean: ignore case in search patterns
-- Tab and Space
vim.opt.expandtab = true -- boolean: use Leaders instead of tabs
vim.opt.shiftwidth = 4 -- number: size of an indent
vim.opt.softtabstop = 4 -- number: number of Leaders tabs count for in insert mode
vim.opt.tabstop = 4 -- number: number of Leaders tabs count for
-- Splits
vim.opt.splitright = true -- boolean: place new window to right of current one
vim.opt.splitbelow = true -- boolean: place new window below the current one
-- Folding
vim.opt.foldmethod = 'expr'
vim.opt.foldexpr = 'nvim_treesitter#foldexpr()'
vim.opt.foldenable = false -- boolean: disable folding at startup
vim.cmd('colorscheme gruvbox')
-- clear sign column highlights so that sign column is the same color as where your line numbers show up
-- https://stackoverflow.com/questions/15277241/changing-vim-gutter-color
vim.cmd('highlight clear SignColumn')
-- remove ':' from the characters list considered being possibly part of a file name and path name
-- https://stackoverflow.com/questions/36500099/vim-gf-should-open-file-and-jump-to-line
vim.cmd('set isfname-=:')
vim.api.nvim_create_autocmd('TextYankPost', {
group = vim.api.nvim_create_augroup('highlight_yank', {}),
desc = 'Hightlight selection on yank',
pattern = '*',
callback = function()
vim.highlight.on_yank { higroup = 'IncSearch', timeout = 500 }
end,
})
vim.diagnostic.config({
virtual_text = true,
signs = true,
update_in_insert = true,
underline = false,
severity_sort = true,
float = false,
})
require('nvim-treesitter.configs').setup({
ensure_installed = {"c", "cpp", "go", "lua", "rust", "python", "typescript", "javascript", "ruby", "markdown", "markdown_inline"},
highlight = {
enable = true,
},
indent = {
enable = true,
},
incremental_selection = {
enable = true,
},
textobjects = {
select = {
enable = true,
lookahead = true,
keymaps = {
['af'] = '@function.outer',
['if'] = '@function.inner',
['ac'] = '@class.outer',
['ic'] = '@class.inner',
},
},
}
})
require("oil").setup()
require('mason').setup({})
require("mason-lspconfig").setup({
ensure_installed = {"rust_analyzer", "gopls", "pyright", "ts_ls", "ruby_lsp", "clangd", "jsonls"},
handlers = {
function (server_name)
require("lspconfig")[server_name].setup({})
end,
},
})
local cmp = require('cmp')
cmp.setup({
mapping = cmp.mapping.preset.insert({
['<CR>'] = cmp.mapping.confirm({ select = true }),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'buffer', keyword_length = 2 },
{ name = 'otter' }
})
})
require('fzf-lua').setup({
keymap = {
fzf = {
["ctrl-q"] = "select-all+accept",
}
},
})
require('quarto').setup({
codeRunner = {
enabled = true,
default_method = 'molten'
},
})
require('Comment').setup({
ignore = '^$',
})
require("nvim-github-linker").setup()
-- keymaps
vim.keymap.set('i', '<C-a>', '<Home>')
vim.keymap.set('i', '<C-e>', '<End>')
vim.keymap.set('i', '<C-b>', '<Left>')
vim.keymap.set('i', '<C-f>', '<Right>')
vim.keymap.set('c', '<C-a>', '<Home>')
vim.keymap.set('c', '<C-b>', '<Left>')
vim.keymap.set('c', '<C-f>', '<Right>')
vim.keymap.set('n', '<Leader>q', ':QuartoPreview<CR>')
vim.keymap.set('n', '<Leader>rc', require("quarto.runner").run_cell)
vim.keymap.set('n', '<Leader>ra', require("quarto.runner").run_all)
vim.keymap.set('n', '<Leader>rd', ':MoltenDelete<CR>')
vim.keymap.set('n', '<Leader>n', '<cmd>NERDTreeToggle<CR>')
vim.keymap.set('n', '<Leader>g', require('fzf-lua').live_grep_glob)
vim.keymap.set('n', '<Leader>f', require('fzf-lua').files)
vim.keymap.set('n', '<Leader>b', require('fzf-lua').buffers)
vim.keymap.set('n', '<CR>', '<cmd>noh<CR><CR>')
vim.keymap.set('n', '[q', '<cmd>cprevious<CR>')
vim.keymap.set('n', ']q', '<cmd>cnext<CR>')
vim.keymap.set('n', '<c-]>', 'g<c-]>')
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
vim.keymap.set('n', '[e', function() vim.diagnostic.goto_prev({ severity = vim.diagnostic.severity.ERROR }) end)
vim.keymap.set('n', ']e', function() vim.diagnostic.goto_next({ severity = vim.diagnostic.severity.ERROR }) end)
vim.keymap.set('n', '<Leader>l', vim.diagnostic.setloclist)
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
callback = function(ev)
local opts = { buffer = ev.buf }
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, 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', '<Leader>rn', vim.lsp.buf.rename, opts)
vim.keymap.set({ 'n', 'v' }, '<Leader>ca', vim.lsp.buf.code_action, opts)
vim.keymap.set({ 'n', 'v' }, '<Leader>=', function() vim.lsp.buf.format { async = true } end, opts)
end,
})