Skip to content

Commit b24630a

Browse files
committed
neovim
1 parent 8882946 commit b24630a

4 files changed

Lines changed: 208 additions & 105 deletions

File tree

home/.config/nvim/coc-settings.json

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,35 @@
55
"highlight.colors.enable": true,
66
"hover.target": "float",
77
"languageserver": {
8-
"ccls": {
9-
"command": "ccls",
10-
"filetypes": ["c", "cpp", "cuda", "objc", "objcpp"],
11-
"rootPatterns": [".ccls-root"],
12-
"initializationOptions": {
13-
"capabilities": {
14-
"foldingRangeProvider": false,
15-
"workspace": {
16-
"workspaceFolders": {
17-
"supported": false
18-
}
19-
}
20-
},
21-
"clang":{"extraArgs": ["--gcc-toolchain=/usr"]},
22-
"completion": {
23-
"detailedLabel": true,
24-
"placeholder": true
25-
},
26-
"client": {
27-
"snippetSupport": true
28-
},
29-
"index": {
30-
"onChange": false,
31-
"initialNoLinkage": true,
32-
"threads": 2,
33-
"initialBlacklist": ["/(test|unittests)/"]
34-
}
35-
}
36-
},
8+
// "ccls": {
9+
// "command": "ccls",
10+
// "filetypes": ["c", "cpp", "cuda", "objc", "objcpp"],
11+
// "rootPatterns": [".ccls-root"],
12+
// "initializationOptions": {
13+
// "capabilities": {
14+
// "foldingRangeProvider": false,
15+
// "workspace": {
16+
// "workspaceFolders": {
17+
// "supported": false
18+
// }
19+
// }
20+
// },
21+
// "clang":{"extraArgs": ["--gcc-toolchain=/usr"]},
22+
// "completion": {
23+
// "detailedLabel": true,
24+
// "placeholder": true
25+
// },
26+
// "client": {
27+
// "snippetSupport": true
28+
// },
29+
// "index": {
30+
// "onChange": false,
31+
// "initialNoLinkage": true,
32+
// "threads": 2,
33+
// "initialBlacklist": ["/(test|unittests)/"]
34+
// }
35+
// }
36+
// },
3737

3838
"gopls": {
3939
"command": "gopls",

home/.config/nvim/init.lua

Lines changed: 60 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,18 @@ require('lazy').setup({
5656
spec = {
5757
'folke/tokyonight.nvim',
5858

59+
'ranjithshegde/ccls.nvim',
5960
'neoclide/coc.nvim',
6061
'junegunn/fzf',
6162
'junegunn/fzf.vim',
6263
'lewis6991/gitsigns.nvim',
64+
'ThePrimeagen/harpoon',
6365
'phaazon/hop.nvim',
6466
'rluba/jai.vim',
6567
'kdheepak/lazygit.nvim',
6668
'ggandor/lightspeed.nvim',
69+
'williamboman/mason.nvim',
70+
'williamboman/mason-lspconfig.nvim',
6771
'NeogitOrg/neogit',
6872
'alaviss/nim.nvim',
6973
{'hrsh7th/nvim-cmp', dependencies = {'hrsh7th/cmp-buffer', 'hrsh7th/cmp-nvim-lsp'}},
@@ -107,7 +111,12 @@ pcall(cmd, 'colorscheme tokyonight')
107111
-- Mappings {{{1
108112
local function map(mode, lhs, rhs, opts)
109113
local options = {noremap = true}
110-
if opts then options = vim.tbl_extend('force', options, opts) end
114+
if opts then
115+
if type(opts) == 'string' then
116+
opts = {desc = opts}
117+
end
118+
options = vim.tbl_extend('force', options, opts)
119+
end
111120
vim.keymap.set(mode, lhs, rhs, options)
112121
end
113122
local function nmap(lhs, rhs, opts)
@@ -118,7 +127,12 @@ local function tmap(lhs, rhs, opts)
118127
end
119128
local function nmapp(lhs, rhs, opts)
120129
local options = {}
121-
if opts then options = vim.tbl_extend('force', options, opts) end
130+
if opts then
131+
if type(opts) == 'string' then
132+
opts = {desc = opts}
133+
end
134+
options = vim.tbl_extend('force', options, opts)
135+
end
122136
vim.api.nvim_set_keymap('n', lhs, rhs, options)
123137
end
124138

@@ -133,31 +147,28 @@ map('x', ';', ':')
133147

134148
-- g
135149
nmap('ga', ':<C-u>CocList -I symbols<cr>')
136-
nmap('gj', ':HopLineAC<cr>')
137-
nmap('gk', ':HopLineBC<cr>')
138-
xnmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
150+
nmap('gj', ':HopLineAC<cr>', 'Hop line down')
151+
nmap('gk', ':HopLineBC<cr>', 'Hop line up')
139152
-- <leader>
140153
xnmap('<leader>?', require('telescope.builtin').oldfiles, '[?] Find recently opened files')
141154
xnmap('<leader><space>', require('telescope.builtin').buffers, '[ ] Find existing buffers')
142-
nmap('<leader>.', '<cmd>lua require("telescope.builtin").find_files({search_dirs={vim.fn.expand("%:h:p")}})<cr>', {silent=true})
155+
nmap('<leader>.', '<cmd>lua require("telescope.builtin").find_files({search_dirs={vim.fn.expand("%:h:p")}})<cr>', 'Find .')
143156
-- <leader>a (app)
144157
nmap('<leader>ag', '<cmd>%!genhdr<cr>')
145158
nmap('<leader>aG', '<cmd>%!genhdr windows<cr>')
146159
-- <leader>b (buffer)
147-
nmap('<leader>bn', '<cmd>bn<cr>')
148-
nmap('<leader>bp', '<cmd>bp<cr>')
149-
nmap('<leader>bN', '<cmd>new<cr>')
160+
nmap('<leader>bn', '<cmd>bn<cr>', 'Next buffer')
161+
nmap('<leader>bp', '<cmd>bp<cr>', 'Previous buffer')
162+
nmap('<leader>bN', '<cmd>new<cr>', 'New empty buffer')
150163
nmap('<leader>bR', '<cmd>e<cr>')
151164
-- <leader>c (compile)
152-
nmap('<leader>cc', '<cmd>make<cr>')
165+
nmap('<leader>cc', '<cmd>OverseerRun<cr>', 'OverseerRun')
153166
-- <leader>d (debug, diff)
154167
nmap('<leader>db', '<cmd>Break<cr>')
155168
nmap('<leader>dt', '<cmd>diffthis<cr>')
156169
nmap('<leader>do', '<cmd>bufdo diffoff<cr>')
157170
-- <leader>e (error)
158171
nmap('<leader>ee', ':e <C-r>=expand("%:p:h") . "/"<cr>')
159-
nmap('<leader>es', ':sp <C-r>=expand("%:p:h") . "/"<cr>')
160-
nmap('<leader>ev', ':vsp <C-r>=expand("%:p:h") . "/"<cr>')
161172
nmapp('<leader>en', '<Plug>(coc-diagnostic-next')
162173
nmapp('<leader>ep', '<Plug>(coc-diagnostic-prev')
163174
-- <leader>f (find & file)
@@ -172,22 +183,32 @@ nmap('<leader>fr', '<cmd>Telescope oldfiles<cr>')
172183
-- <leader>g (fugitive)
173184
nmap('<leader>gb', '<cmd>Git blame<cr>')
174185
nmap('<leader>gd', '<cmd>Git diff<cr>')
175-
nmap('<leader>gg', '<cmd>lua toggle_term_cmd({cmd="lazygit",direction="float"})<cr>')
186+
nmap('<leader>gg', '<cmd>lua ToggleTermCmd({cmd="lazygit",direction="float"})<cr>')
176187
nmap('<leader>gl', '<cmd>Git log<cr>')
188+
-- <leader>h (harpoon)
189+
local mark = require("harpoon.mark")
190+
local ui = require("harpoon.ui")
191+
nmap("<leader>ha", mark.add_file)
192+
nmap("<leader>he", ui.toggle_quick_menu)
193+
nmap("<leader>1", function() ui.nav_file(1) end, 'Harpoon 1')
194+
nmap("<leader>2", function() ui.nav_file(2) end, 'Harpoon 2')
195+
nmap("<leader>3", function() ui.nav_file(3) end, 'Harpoon 3')
196+
nmap("<leader>4", function() ui.nav_file(4) end, 'Harpoon 4')
197+
nmap("<leader>5", function() ui.nav_file(5) end, 'Harpoon 5')
198+
nmap("<leader>6", function() ui.nav_file(6) end, 'Harpoon 6')
177199
-- <leader>l (lsp)
178-
nmap('<leader>le', '<cmd>CocList diagnostics<cr>')
179-
nmapp('<leader>lf', '<Plug>(coc-fix-current)')
180-
nmap('<leader>li', '<cmd>CocList outline<cr>')
181-
nmapp('<leader>lr', '<Plug>(coc-rename)')
200+
nmap('<leader>le', '<cmd>CocList diagnostics<cr>', 'LSP diagnostics')
201+
nmapp('<leader>lf', '<Plug>(coc-fix-current)', 'Fix')
202+
nmap('<leader>li', '<cmd>CocList outline<cr>', 'Outline')
203+
nmapp('<leader>lr', '<Plug>(coc-rename)', 'Rename')
204+
-- <leader>p (project)
205+
nmap('<leader>pf', '<cmd>lua require("telescope.builtin").find_files({search_dirs={MyProject()}})<cr>', {silent=true, desc='Find file in project'})
182206
-- <leader>q (quit)
183207
nmap('<leader>qq', '<cmd>quit<cr>')
184208
-- <leader>s (search)
185-
nmap('<leader>sb', '<cmd>Telescope current_buffer_fuzzy_find<cr>')
186-
nmap('<leader>sd', '<cmd>Telescope live_grep<cr>')
187-
nmap('<leader>sp', '<cmd>lua my_fd()<cr>')
188-
nmap('<leader>ss', '<cmd>lua require("telescope.builtin").live_grep({default_text=vim.fn.expand("<cword>")})<cr>')
189-
--nnoremap <expr> <leader>sF ':Telescope find_files<cr>' . "'" . expand('<cword>')
190-
nmap('<leader>sS', '<cmd>Grepper -noprompt -cword<cr>')
209+
nmap('<leader>sd', '<cmd>lua require("telescope.builtin").live_grep({cwd=vim.fn.expand("%:p:h")})<cr>', 'Search directory')
210+
nmap('<leader>sp', '<cmd>lua require("telescope.builtin").live_grep({cwd=MyProject()})<cr>', 'Search project')
211+
nmap('<leader>ss', '<cmd>Telescope current_buffer_fuzzy_find<cr>', 'Search buffer')
191212
-- <leader>t (toggle & terminal)
192213
nmap('<leader>tf', '<cmd>ToggleTerm direction=float<cr>')
193214
nmap('<leader>th', '<cmd>ToggleTerm direction=horizontal size=10<cr>')
@@ -207,22 +228,16 @@ nmap(',m', '<cmd>call CocLocations("ccls","textDocument/references",{"role":64})
207228
nmap(',r', '<cmd>call CocLocations("ccls","textDocument/references",{"role":8})<cr>') -- read
208229
nmap(',w', '<cmd>call CocLocations("ccls","textDocument/references",{"role":16})<cr>') -- write
209230
-- x (xref)
210-
-- bases of up to 3 levels
211-
nmap('xb', '<cmd>call CocLocations("ccls","$ccls/inheritance",{})<cr>')
212-
nmap('xB', '<cmd>call CocLocations("ccls","$ccls/inheritance",{"levels":3})<cr>')
213-
-- derived of up to 3 levels
214-
nmap('xd', '<cmd>call CocLocations("ccls","$ccls/inheritance",{"derived":v:true})<cr>')
215-
-- derived of up to 3 levels
216-
nmap('xD', '<cmd>call CocLocations("ccls","$ccls/inheritance",{"derived":v:true,"levels":3})<cr>')
217-
-- caller
218-
nmap('xc', '<cmd>call CocLocations("ccls","$ccls/call")<cr>')
219-
-- callee
220-
nmap('xC', '<cmd>call CocLocations("ccls","$ccls/call",{"callee":v:true})<cr>')
221-
-- member
222-
nmap('xm', '<cmd>call CocLocations("ccls","$ccls/member")<cr>')
223-
nmap('xn', '<cmd>CocNext<cr>')
224-
nmap('xp', '<cmd>CocPrev<cr>')
225-
nmap('xt', '<cmd>call MarkPush()<cr>:call CocAction("jumpTypeDefinition")<cr>')
231+
nmap('xb', '<cmd>call CocLocations("ccls","$ccls/inheritance",{})<cr>', 'base')
232+
nmap('xB', '<cmd>call CocLocations("ccls","$ccls/inheritance",{"levels":3})<cr>', 'base 3')
233+
nmap('xd', '<cmd>call CocLocations("ccls","$ccls/inheritance",{"derived":v:true})<cr>', 'derive')
234+
nmap('xD', '<cmd>call CocLocations("ccls","$ccls/inheritance",{"derived":v:true,"levels":3})<cr>', 'derive 3')
235+
nmap('xc', '<cmd>call CocLocations("ccls","$ccls/call")<cr>', 'caller')
236+
nmap('xC', '<cmd>call CocLocations("ccls","$ccls/call",{"callee":v:true})<cr>', 'callee')
237+
nmap('xm', '<cmd>call CocLocations("ccls","$ccls/member")<cr>', 'member')
238+
nmap('xn', '<cmd>CocNext<cr>', 'LSP next')
239+
nmap('xp', '<cmd>CocPrev<cr>', 'LSP previous')
240+
nmap('xt', '<cmd>call MarkPush()<cr>:call CocAction("jumpTypeDefinition")<cr>', 'type definition')
226241
-- misc
227242
nmap('<M-down>', '<cmd>cnext<cr>')
228243
nmap('<M-up>', '<cmd>cprevious<cr>')
@@ -245,6 +260,7 @@ nmap('<f1>', '<cmd>Gdb<cr>')
245260
nmap('<f2>', '<cmd>Program<cr>')
246261
nmap('<f11>', '<cmd>Break<cr>')
247262
nmap('<f12>', '<cmd>Clear<cr>')
263+
nmap('<M-`>', '<cmd>OverseerToggle<cr>')
248264
tmap('<C-h>', '<C-\\><C-n><C-w>h')
249265
tmap('<C-j>', '<C-\\><C-n><C-w>j')
250266
tmap('<C-k>', '<C-\\><C-n><C-w>k')
@@ -276,16 +292,11 @@ local autocmds = {
276292
}
277293
nvim_create_augroups(autocmds)
278294

279-
function my_fd(opts)
280-
opts = opts or {}
281-
opts.cwd = vim.fn.systemlist("git rev-parse --show-toplevel")[1]
282-
if vim.v.shell_error ~= 0 then
283-
opts.cwd = vim.lsp.get_active_clients()[1].config.root_dir
284-
end
285-
require'telescope.builtin'.find_files(opts)
295+
function MyProject()
296+
return vim.fn.systemlist("git rev-parse --show-toplevel")[1]
286297
end
287298

288-
vim.api.nvim_exec([[
299+
vim.api.nvim_exec2([[
289300
let g:mark_ring = [{},{},{},{},{},{},{},{},{},{}]
290301
let g:mark_ring_i = 0
291302
@@ -340,7 +351,7 @@ command! GdbStart :call TermDebugSendCommand('start')
340351
command! GdbUp :call TermDebugSendCommand('up')
341352
command! GdbDown :call TermDebugSendCommand('down')
342353
command! GdbQuit :call TermDebugSendCommand('quit')
343-
]], true)
354+
]], {})
344355

345356
vim.g.termdebug_config = {
346357
wide = 1,
@@ -376,7 +387,7 @@ vim.api.nvim_create_user_command('RR', function(opts)
376387
end, {})
377388

378389
M.user_terminals = {}
379-
function toggle_term_cmd(opts)
390+
function ToggleTermCmd(opts)
380391
local terms = M.user_terminals
381392
opts = vim.tbl_deep_extend('force', {hidden = true}, opts)
382393
local num = vim.v.count > 0 and vim.v.count or 1

0 commit comments

Comments
 (0)