Skip to content

Commit 78cd265

Browse files
committed
editor
1 parent ded7407 commit 78cd265

File tree

3 files changed

+82
-24
lines changed

3 files changed

+82
-24
lines changed

home/.config/doom/+bindings.el

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,6 @@
167167
:desc "Find snippet for mode" "s" #'yas-visit-snippet-file
168168
:desc "Find snippet" "S" #'+default/find-in-snippets)
169169

170-
(:prefix ("s" . "search")
171-
"b" #'swiper-all
172-
:desc "Directory" "d" #'+ivy/project-search-from-cwd
173-
:desc "Project" "/" #'+ivy/project-search
174-
"s" (λ! (minibuffer-with-setup-hook
175-
(lambda () (insert ivy--default)) (+ivy/project-search)))
176-
:desc "Symbols" "i" #'imenu
177-
:desc "Symbols across buffers" "I" #'imenu-anywhere
178-
:desc "Online providers" "o" #'+lookup/online-select
179-
)
180-
181170
(:prefix ("t" . "toggle")
182171
"d" #'toggle-debug-on-error
183172
"D" #'+my/realtime-elisp-doc

home/.config/nvim/init.lua

Lines changed: 65 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ local stl = {
4343
}
4444
o.statusline = table.concat(stl)
4545

46-
function prequire(...)
47-
local status, lib = pcall(require, ...)
48-
if status then return lib end
49-
return nil
50-
end
51-
5246
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
5347
if not vim.loop.fs_stat(lazypath) then
5448
vim.fn.system({'git', 'clone', '--filter=blob:none', 'https://github.com/folke/lazy.nvim.git', '--branch=stable', lazypath})
@@ -67,6 +61,7 @@ require('lazy').setup({
6761
'rluba/jai.vim',
6862
'kdheepak/lazygit.nvim',
6963
'ggandor/lightspeed.nvim',
64+
'NeogitOrg/neogit',
7065
'alaviss/nim.nvim',
7166
{'hrsh7th/nvim-cmp', dependencies = {'hrsh7th/cmp-buffer', 'hrsh7th/cmp-nvim-lsp'}},
7267
'terrortylor/nvim-comment',
@@ -106,11 +101,14 @@ pcall(cmd, 'colorscheme tokyonight')
106101
local function map(mode, lhs, rhs, opts)
107102
local options = {noremap = true}
108103
if opts then options = vim.tbl_extend('force', options, opts) end
109-
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
104+
vim.keymap.set(mode, lhs, rhs, options)
110105
end
111106
local function nmap(lhs, rhs, opts)
112107
map('n', lhs, rhs, opts)
113108
end
109+
local function tmap(lhs, rhs, opts)
110+
map('t', lhs, rhs, opts)
111+
end
114112
local function nmapp(lhs, rhs, opts)
115113
local options = {}
116114
if opts then options = vim.tbl_extend('force', options, opts) end
@@ -129,7 +127,7 @@ map('x', ';', ':')
129127
-- g
130128
nmap('ga', ':<C-u>CocList -I symbols<cr>')
131129
nmap('gj', ':HopLineAC<cr>')
132-
nmap('gk', ':opLineBC<cr>')
130+
nmap('gk', ':HopLineBC<cr>')
133131
xnmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
134132
-- <leader>
135133
xnmap('<leader>?', require('telescope.builtin').oldfiles, '[?] Find recently opened files')
@@ -143,7 +141,8 @@ nmap('<leader>bn', '<cmd>bn<cr>')
143141
nmap('<leader>bp', '<cmd>bp<cr>')
144142
nmap('<leader>bN', '<cmd>new<cr>')
145143
nmap('<leader>bR', '<cmd>e<cr>')
146-
-- <leader>d (diff)
144+
-- <leader>d (debug, diff)
145+
nmap('<leader>db', '<cmd>Break<cr>')
147146
nmap('<leader>dt', '<cmd>diffthis<cr>')
148147
nmap('<leader>do', '<cmd>bufdo diffoff<cr>')
149148
-- <leader>e (error)
@@ -171,7 +170,8 @@ nmapp('<leader>lr', '<Plug>(coc-rename)')
171170
nmap('<leader>qq', '<cmd>quit<cr>')
172171
-- <leader>s (search)
173172
nmap('<leader>sd', '<cmd>Telescope live_grep<cr>')
174-
nmap('<leader>ss', '<cmd>lua require("telescope.builtin").grep_string()<cr>')
173+
nmap('<leader>sp', '<cmd>lua my_fd()<cr>')
174+
nmap('<leader>ss', '<cmd>Telescope current_buffer_fuzzy_find<cr>')
175175
nmap('<leader>sS', '<cmd>Grepper -noprompt -cword<cr>')
176176
-- <leader>t (toggle)
177177
nmap('<leader>tl', '<cmd>lua require("fn").toggle_loclist()<cr>')
@@ -210,6 +210,14 @@ nmap('L', '<cmd>call MarkPop(1)<cr>')
210210
nmap('K', '<cmd>silent call CocAction("doHover")<cr>')
211211
nmap('U', '<cmd>call MyHopThenDefinition()<cr>')
212212
nmap('zx', '<cmd>bdelete<cr>')
213+
nmap('<f1>', '<cmd>Gdb<cr>')
214+
nmap('<f2>', '<cmd>Program<cr>')
215+
nmap('<f11>', '<cmd>Break<cr>')
216+
nmap('<f12>', '<cmd>Clear<cr>')
217+
tmap('<C-h>', '<C-\\><C-n><C-w>h')
218+
tmap('<C-j>', '<C-\\><C-n><C-w>j')
219+
tmap('<C-k>', '<C-\\><C-n><C-w>k')
220+
tmap('<C-l>', '<C-\\><C-n><C-w>l')
213221

214222
-- Autocmd {{{1
215223
function nvim_create_augroups(definitions)
@@ -227,9 +235,6 @@ local autocmds = {
227235
restore_cursor = {
228236
{'BufRead', '*', [[call setpos(".", getpos("'\""))]]};
229237
};
230-
packer = {
231-
{'BufWritePost', 'plugins.lua', 'PackerCompile'};
232-
};
233238
toggle_search_highlighting = {
234239
{'InsertEnter', '*', 'setlocal nohlsearch'};
235240
};
@@ -240,6 +245,15 @@ local autocmds = {
240245
}
241246
nvim_create_augroups(autocmds)
242247

248+
function my_fd(opts)
249+
opts = opts or {}
250+
opts.cwd = vim.fn.systemlist("git rev-parse --show-toplevel")[1]
251+
if vim.v.shell_error ~= 0 then
252+
opts.cwd = vim.lsp.get_active_clients()[1].config.root_dir
253+
end
254+
require'telescope.builtin'.find_files(opts)
255+
end
256+
243257
vim.api.nvim_exec([[
244258
let g:mark_ring = [{},{},{},{},{},{},{},{},{},{}]
245259
let g:mark_ring_i = 0
@@ -290,6 +304,44 @@ aug Nim
290304
au!
291305
au FileType nim :call Nim_init()
292306
aug END
307+
308+
command! GdbStart :call TermDebugSendCommand('start')
309+
command! GdbUp :call TermDebugSendCommand('up')
310+
command! GdbDown :call TermDebugSendCommand('down')
311+
command! GdbQuit :call TermDebugSendCommand('quit')
293312
]], true)
294313

314+
vim.g.termdebug_config = {
315+
wide = 1,
316+
}
317+
local function my_gdb_keymap(process)
318+
for _,buf in pairs(vim.api.nvim_list_bufs()) do
319+
if string.find(vim.api.nvim_buf_get_name(buf), process) then
320+
vim.keymap.set('n', 'c', '<cmd>Continue<cr>', {buffer=buf})
321+
vim.keymap.set('n', 'd', '<cmd>GdbDown<cr>', {buffer=buf})
322+
vim.keymap.set('n', 'f', '<cmd>Finish<cr>', {buffer=buf})
323+
vim.keymap.set('n', 'n', '<cmd>Over<cr>', {buffer=buf})
324+
vim.keymap.set('n', 'r', '<cmd>GdbStart<cr>', {buffer=buf})
325+
vim.keymap.set('n', 's', '<cmd>Step<cr>', {buffer=buf})
326+
vim.keymap.set('n', 'u', '<cmd>GdbUp<cr>', {buffer=buf})
327+
vim.keymap.set('n', 'v', '<cmd>call TermDebugSendCommand("info locals")<cr>', {buffer=buf})
328+
vim.keymap.set('n', 'w', '<cmd>call TermDebugSendCommand("where")<cr>', {buffer=buf})
329+
vim.keymap.set('t', ';', '<C-\\><C-n>', {buffer=buf})
330+
end
331+
end
332+
end
333+
vim.api.nvim_exec('packadd termdebug', true)
334+
vim.api.nvim_create_user_command('RunGdb', function(opts)
335+
vim.wo.scrolloff = 999
336+
vim.cmd "sil! unlet g:termdebug_config['command']"
337+
vim.cmd 'Termdebug'
338+
my_gdb_keymap('/bin/gdb')
339+
end, {})
340+
vim.api.nvim_create_user_command('RR', function(opts)
341+
vim.wo.scrolloff = 999
342+
vim.cmd "let g:termdebug_config['command'] = ['rr', 'replay', '--']"
343+
vim.cmd 'Termdebug'
344+
my_gdb_keymap('/bin/rr')
345+
end, {})
346+
295347
require 'plugins'

home/.config/nvim/lua/plugins.lua

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
require'hop'.setup()
2+
3+
require('telescope').setup{
4+
defaults = {
5+
mappings = {
6+
i = {
7+
['<C-h>'] = 'which_key'
8+
}
9+
}
10+
},
11+
}
12+
113
local treesitter = require 'nvim-treesitter.configs'
214
treesitter.setup {
315
ensure_installed = {'cpp', 'python'},
@@ -126,3 +138,8 @@ require('nvim_comment').setup()
126138

127139
-- Default map: <leader>h ]c [c
128140
require('gitsigns').setup()
141+
142+
local neogit = require('neogit')
143+
neogit.setup {}
144+
145+
require('which-key').setup()

0 commit comments

Comments
 (0)