Skip to content

Commit bcc7825

Browse files
committed
neovim
1 parent 8882946 commit bcc7825

4 files changed

Lines changed: 212 additions & 108 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: 62 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,19 @@ require('lazy').setup({
5656
spec = {
5757
'folke/tokyonight.nvim',
5858

59-
'neoclide/coc.nvim',
59+
'ranjithshegde/ccls.nvim',
60+
'stevearc/dressing.nvim',
61+
-- 'neoclide/coc.nvim',
6062
'junegunn/fzf',
6163
'junegunn/fzf.vim',
6264
'lewis6991/gitsigns.nvim',
65+
'ThePrimeagen/harpoon',
6366
'phaazon/hop.nvim',
6467
'rluba/jai.vim',
6568
'kdheepak/lazygit.nvim',
6669
'ggandor/lightspeed.nvim',
70+
'williamboman/mason.nvim',
71+
'williamboman/mason-lspconfig.nvim',
6772
'NeogitOrg/neogit',
6873
'alaviss/nim.nvim',
6974
{'hrsh7th/nvim-cmp', dependencies = {'hrsh7th/cmp-buffer', 'hrsh7th/cmp-nvim-lsp'}},
@@ -107,7 +112,12 @@ pcall(cmd, 'colorscheme tokyonight')
107112
-- Mappings {{{1
108113
local function map(mode, lhs, rhs, opts)
109114
local options = {noremap = true}
110-
if opts then options = vim.tbl_extend('force', options, opts) end
115+
if opts then
116+
if type(opts) == 'string' then
117+
opts = {desc = opts}
118+
end
119+
options = vim.tbl_extend('force', options, opts)
120+
end
111121
vim.keymap.set(mode, lhs, rhs, options)
112122
end
113123
local function nmap(lhs, rhs, opts)
@@ -118,7 +128,12 @@ local function tmap(lhs, rhs, opts)
118128
end
119129
local function nmapp(lhs, rhs, opts)
120130
local options = {}
121-
if opts then options = vim.tbl_extend('force', options, opts) end
131+
if opts then
132+
if type(opts) == 'string' then
133+
opts = {desc = opts}
134+
end
135+
options = vim.tbl_extend('force', options, opts)
136+
end
122137
vim.api.nvim_set_keymap('n', lhs, rhs, options)
123138
end
124139

@@ -133,31 +148,28 @@ map('x', ';', ':')
133148

134149
-- g
135150
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')
151+
nmap('gj', ':HopLineAC<cr>', 'Hop line down')
152+
nmap('gk', ':HopLineBC<cr>', 'Hop line up')
139153
-- <leader>
140154
xnmap('<leader>?', require('telescope.builtin').oldfiles, '[?] Find recently opened files')
141155
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})
156+
nmap('<leader>.', '<cmd>lua require("telescope.builtin").find_files({search_dirs={vim.fn.expand("%:h:p")}})<cr>', 'Find .')
143157
-- <leader>a (app)
144158
nmap('<leader>ag', '<cmd>%!genhdr<cr>')
145159
nmap('<leader>aG', '<cmd>%!genhdr windows<cr>')
146160
-- <leader>b (buffer)
147-
nmap('<leader>bn', '<cmd>bn<cr>')
148-
nmap('<leader>bp', '<cmd>bp<cr>')
149-
nmap('<leader>bN', '<cmd>new<cr>')
161+
nmap('<leader>bn', '<cmd>bn<cr>', 'Next buffer')
162+
nmap('<leader>bp', '<cmd>bp<cr>', 'Previous buffer')
163+
nmap('<leader>bN', '<cmd>new<cr>', 'New empty buffer')
150164
nmap('<leader>bR', '<cmd>e<cr>')
151165
-- <leader>c (compile)
152-
nmap('<leader>cc', '<cmd>make<cr>')
166+
nmap('<leader>cc', '<cmd>OverseerRun<cr>', 'OverseerRun')
153167
-- <leader>d (debug, diff)
154168
nmap('<leader>db', '<cmd>Break<cr>')
155169
nmap('<leader>dt', '<cmd>diffthis<cr>')
156170
nmap('<leader>do', '<cmd>bufdo diffoff<cr>')
157171
-- <leader>e (error)
158172
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>')
161173
nmapp('<leader>en', '<Plug>(coc-diagnostic-next')
162174
nmapp('<leader>ep', '<Plug>(coc-diagnostic-prev')
163175
-- <leader>f (find & file)
@@ -172,22 +184,32 @@ nmap('<leader>fr', '<cmd>Telescope oldfiles<cr>')
172184
-- <leader>g (fugitive)
173185
nmap('<leader>gb', '<cmd>Git blame<cr>')
174186
nmap('<leader>gd', '<cmd>Git diff<cr>')
175-
nmap('<leader>gg', '<cmd>lua toggle_term_cmd({cmd="lazygit",direction="float"})<cr>')
187+
nmap('<leader>gg', '<cmd>lua ToggleTermCmd({cmd="lazygit",direction="float"})<cr>')
176188
nmap('<leader>gl', '<cmd>Git log<cr>')
189+
-- <leader>h (harpoon)
190+
local mark = require("harpoon.mark")
191+
local ui = require("harpoon.ui")
192+
nmap("<leader>ha", mark.add_file)
193+
nmap("<leader>he", ui.toggle_quick_menu)
194+
nmap("<leader>1", function() ui.nav_file(1) end, 'Harpoon 1')
195+
nmap("<leader>2", function() ui.nav_file(2) end, 'Harpoon 2')
196+
nmap("<leader>3", function() ui.nav_file(3) end, 'Harpoon 3')
197+
nmap("<leader>4", function() ui.nav_file(4) end, 'Harpoon 4')
198+
nmap("<leader>5", function() ui.nav_file(5) end, 'Harpoon 5')
199+
nmap("<leader>6", function() ui.nav_file(6) end, 'Harpoon 6')
177200
-- <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)')
201+
nmap('<leader>le', '<cmd>CocList diagnostics<cr>', 'LSP diagnostics')
202+
nmapp('<leader>lf', '<Plug>(coc-fix-current)', 'Fix')
203+
nmap('<leader>li', '<cmd>CocList outline<cr>', 'Outline')
204+
nmapp('<leader>lr', '<Plug>(coc-rename)', 'Rename')
205+
-- <leader>p (project)
206+
nmap('<leader>pf', '<cmd>lua require("telescope.builtin").find_files({search_dirs={MyProject()}})<cr>', {silent=true, desc='Find file in project'})
182207
-- <leader>q (quit)
183208
nmap('<leader>qq', '<cmd>quit<cr>')
184209
-- <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>')
210+
nmap('<leader>sd', '<cmd>lua require("telescope.builtin").live_grep({cwd=vim.fn.expand("%:p:h")})<cr>', 'Search directory')
211+
nmap('<leader>sp', '<cmd>lua require("telescope.builtin").live_grep({cwd=MyProject()})<cr>', 'Search project')
212+
nmap('<leader>ss', '<cmd>Telescope current_buffer_fuzzy_find<cr>', 'Search buffer')
191213
-- <leader>t (toggle & terminal)
192214
nmap('<leader>tf', '<cmd>ToggleTerm direction=float<cr>')
193215
nmap('<leader>th', '<cmd>ToggleTerm direction=horizontal size=10<cr>')
@@ -207,22 +229,16 @@ nmap(',m', '<cmd>call CocLocations("ccls","textDocument/references",{"role":64})
207229
nmap(',r', '<cmd>call CocLocations("ccls","textDocument/references",{"role":8})<cr>') -- read
208230
nmap(',w', '<cmd>call CocLocations("ccls","textDocument/references",{"role":16})<cr>') -- write
209231
-- 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>')
232+
nmap('xb', '<cmd>call CocLocations("ccls","$ccls/inheritance",{})<cr>', 'base')
233+
nmap('xB', '<cmd>call CocLocations("ccls","$ccls/inheritance",{"levels":3})<cr>', 'base 3')
234+
nmap('xd', '<cmd>call CocLocations("ccls","$ccls/inheritance",{"derived":v:true})<cr>', 'derive')
235+
nmap('xD', '<cmd>call CocLocations("ccls","$ccls/inheritance",{"derived":v:true,"levels":3})<cr>', 'derive 3')
236+
nmap('xc', '<cmd>call CocLocations("ccls","$ccls/call")<cr>', 'caller')
237+
nmap('xC', '<cmd>call CocLocations("ccls","$ccls/call",{"callee":v:true})<cr>', 'callee')
238+
nmap('xm', '<cmd>call CocLocations("ccls","$ccls/member")<cr>', 'member')
239+
nmap('xn', '<cmd>CocNext<cr>', 'LSP next')
240+
nmap('xp', '<cmd>CocPrev<cr>', 'LSP previous')
241+
nmap('xt', '<cmd>call MarkPush()<cr>:call CocAction("jumpTypeDefinition")<cr>', 'type definition')
226242
-- misc
227243
nmap('<M-down>', '<cmd>cnext<cr>')
228244
nmap('<M-up>', '<cmd>cprevious<cr>')
@@ -245,6 +261,7 @@ nmap('<f1>', '<cmd>Gdb<cr>')
245261
nmap('<f2>', '<cmd>Program<cr>')
246262
nmap('<f11>', '<cmd>Break<cr>')
247263
nmap('<f12>', '<cmd>Clear<cr>')
264+
nmap('<M-`>', '<cmd>OverseerToggle<cr>')
248265
tmap('<C-h>', '<C-\\><C-n><C-w>h')
249266
tmap('<C-j>', '<C-\\><C-n><C-w>j')
250267
tmap('<C-k>', '<C-\\><C-n><C-w>k')
@@ -276,16 +293,11 @@ local autocmds = {
276293
}
277294
nvim_create_augroups(autocmds)
278295

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)
296+
function MyProject()
297+
return vim.fn.systemlist("git rev-parse --show-toplevel")[1]
286298
end
287299

288-
vim.api.nvim_exec([[
300+
vim.api.nvim_exec2([[
289301
let g:mark_ring = [{},{},{},{},{},{},{},{},{},{}]
290302
let g:mark_ring_i = 0
291303
@@ -340,7 +352,7 @@ command! GdbStart :call TermDebugSendCommand('start')
340352
command! GdbUp :call TermDebugSendCommand('up')
341353
command! GdbDown :call TermDebugSendCommand('down')
342354
command! GdbQuit :call TermDebugSendCommand('quit')
343-
]], true)
355+
]], {})
344356

345357
vim.g.termdebug_config = {
346358
wide = 1,
@@ -376,7 +388,7 @@ vim.api.nvim_create_user_command('RR', function(opts)
376388
end, {})
377389

378390
M.user_terminals = {}
379-
function toggle_term_cmd(opts)
391+
function ToggleTermCmd(opts)
380392
local terms = M.user_terminals
381393
opts = vim.tbl_deep_extend('force', {hidden = true}, opts)
382394
local num = vim.v.count > 0 and vim.v.count or 1

0 commit comments

Comments
 (0)