Compare commits
1 Commits
e78c8fc07f
...
helpgrep
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d21cd45701 |
@@ -1,3 +0,0 @@
|
|||||||
local opts = { buffer = true, remap = false, silent = true }
|
|
||||||
vim.keymap.set('n', '0', ':PreProcIfWrap<CR>', opts)
|
|
||||||
vim.keymap.set('v', '0', ':PreProcIfWrap<CR>', opts)
|
|
||||||
@@ -1,6 +1,2 @@
|
|||||||
vim.opt.commentstring = '//%s'
|
vim.opt.commentstring = '//%s'
|
||||||
vim.opt.matchpairs:append('<:>')
|
vim.opt.matchpairs:append('<:>')
|
||||||
|
|
||||||
local opts = { buffer = true, remap = false, silent = true }
|
|
||||||
vim.keymap.set('n', '0', ':PreProcIfWrap<CR>', opts)
|
|
||||||
vim.keymap.set('v', '0', ':PreProcIfWrap<CR>', opts)
|
|
||||||
|
|||||||
@@ -5,10 +5,11 @@ return {
|
|||||||
'nvim-telescope/telescope-fzy-native.nvim',
|
'nvim-telescope/telescope-fzy-native.nvim',
|
||||||
'nvim-tree/nvim-web-devicons',
|
'nvim-tree/nvim-web-devicons',
|
||||||
'axkirillov/easypick.nvim',
|
'axkirillov/easypick.nvim',
|
||||||
'benfowler/telescope-luasnip.nvim',
|
'catgoose/telescope-helpgrep.nvim',
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
local telescope = require('telescope')
|
local telescope = require('telescope')
|
||||||
|
local actions = require('telescope.actions')
|
||||||
telescope.setup({
|
telescope.setup({
|
||||||
defaults = {
|
defaults = {
|
||||||
mappings = {
|
mappings = {
|
||||||
@@ -21,15 +22,28 @@ return {
|
|||||||
['<C-s>'] = 'select_horizontal',
|
['<C-s>'] = 'select_horizontal',
|
||||||
['<C-h>'] = 'preview_scrolling_left',
|
['<C-h>'] = 'preview_scrolling_left',
|
||||||
['<C-l>'] = 'preview_scrolling_right',
|
['<C-l>'] = 'preview_scrolling_right',
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
layout_config = {
|
layout_config = {
|
||||||
height = 0.7,
|
height = 0.7,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
extensions = {
|
||||||
|
helpgrep = {
|
||||||
|
mappings = {
|
||||||
|
i = {
|
||||||
|
["<CR>"] = actions.select_default,
|
||||||
|
["<C-v>"] = actions.select_vertical,
|
||||||
|
},
|
||||||
|
n = {
|
||||||
|
["<CR>"] = actions.select_default,
|
||||||
|
["<C-s>"] = actions.select_horizontal,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
telescope.load_extension('fzy_native')
|
telescope.load_extension('fzy_native')
|
||||||
telescope.load_extension('luasnip')
|
|
||||||
|
|
||||||
local builtin = require('telescope.builtin')
|
local builtin = require('telescope.builtin')
|
||||||
local opts = { noremap = true }
|
local opts = { noremap = true }
|
||||||
@@ -38,7 +52,8 @@ return {
|
|||||||
vim.keymap.set('n', '<leader>gg', builtin.live_grep, opts)
|
vim.keymap.set('n', '<leader>gg', builtin.live_grep, opts)
|
||||||
vim.keymap.set('n', '<leader>rg', builtin.grep_string, opts)
|
vim.keymap.set('n', '<leader>rg', builtin.grep_string, opts)
|
||||||
vim.keymap.set('n', '<leader>gb', builtin.buffers, opts)
|
vim.keymap.set('n', '<leader>gb', builtin.buffers, opts)
|
||||||
vim.keymap.set('n', '<leader>gh', builtin.help_tags, opts)
|
vim.keymap.set('n', '<leader>ht', builtin.help_tags, opts)
|
||||||
|
vim.keymap.set('n', '<leader>gh', require('telescope-helpgrep').live_grep, opts)
|
||||||
vim.keymap.set('n', '<leader>bl', builtin.current_buffer_fuzzy_find, opts)
|
vim.keymap.set('n', '<leader>bl', builtin.current_buffer_fuzzy_find, opts)
|
||||||
|
|
||||||
require('easypick').setup({
|
require('easypick').setup({
|
||||||
|
|||||||
@@ -126,13 +126,3 @@ vim.api.nvim_create_user_command('Rg', function(opts)
|
|||||||
end
|
end
|
||||||
require('telescope.builtin').grep_string(grep_opts)
|
require('telescope.builtin').grep_string(grep_opts)
|
||||||
end, { bang = true, nargs = '*' })
|
end, { bang = true, nargs = '*' })
|
||||||
|
|
||||||
vim.api.nvim_create_user_command('PreProcIfWrap', function(opts)
|
|
||||||
local buffer = vim.api.nvim_get_current_buf()
|
|
||||||
vim.api.nvim_buf_set_lines(
|
|
||||||
buffer, opts.line2, opts.line2, true, { '#endif' })
|
|
||||||
vim.api.nvim_buf_set_lines(
|
|
||||||
buffer, opts.line1 - 1, opts.line1 - 1, true, { '#if 0' })
|
|
||||||
local window = vim.api.nvim_get_current_win()
|
|
||||||
vim.api.nvim_win_set_cursor(window, {opts.line1, 5})
|
|
||||||
end, { range = true })
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ local function special(group, name, title)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Construct a statusline for generic buffer types.
|
-- Construct a statusline for generic buffer types.
|
||||||
local function generic(group, name)
|
local function generic(group, name, show_lsp)
|
||||||
-- Display current mode with dynamic highlights.
|
-- Display current mode with dynamic highlights.
|
||||||
local line = '%#' .. group .. '# ' .. name .. ' '
|
local line = '%#' .. group .. '# ' .. name .. ' '
|
||||||
-- Display spell or paste if set with dusk highlights in a group to swallow
|
-- Display spell or paste if set with dusk highlights in a group to swallow
|
||||||
@@ -131,11 +131,11 @@ function _G.statusline_active()
|
|||||||
return special('StatusLineLight', 'Terminal', '%f')
|
return special('StatusLineLight', 'Terminal', '%f')
|
||||||
elseif vim.o.previewwindow then
|
elseif vim.o.previewwindow then
|
||||||
if mode == 'Normal' then mode = 'Preview' end
|
if mode == 'Normal' then mode = 'Preview' end
|
||||||
return generic('StatusLineLight', mode)
|
return generic('StatusLineLight', mode, false)
|
||||||
elseif vim.o.filetype == 'man' then
|
elseif vim.o.filetype == 'man' then
|
||||||
return special('StatusLineDusk', 'Manual', '%f')
|
return special('StatusLineDusk', 'Manual', '%f')
|
||||||
end
|
end
|
||||||
return generic('StatusLineLight', mode)
|
return generic('StatusLineLight', mode, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
function _G.statusline_inactive()
|
function _G.statusline_inactive()
|
||||||
@@ -152,11 +152,11 @@ function _G.statusline_inactive()
|
|||||||
elseif vim.o.buftype == 'terminal' then
|
elseif vim.o.buftype == 'terminal' then
|
||||||
line = special('StatusLineDusk', 'Terminal', '%f')
|
line = special('StatusLineDusk', 'Terminal', '%f')
|
||||||
elseif vim.o.previewwindow then
|
elseif vim.o.previewwindow then
|
||||||
line = generic('StatusLineDusk', 'Preview')
|
line = generic('StatusLineDusk', 'Preview', false)
|
||||||
elseif vim.o.filetype == 'man' then
|
elseif vim.o.filetype == 'man' then
|
||||||
line = special('StatusLineDusk', 'Manual', '%f')
|
line = special('StatusLineDusk', 'Manual', '%f')
|
||||||
else
|
else
|
||||||
line = generic('StatusLineDusk', 'Idle')
|
line = generic('StatusLineDusk', 'Idle', false)
|
||||||
end
|
end
|
||||||
return line
|
return line
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
# Go LuaSnip Snippets
|
|
||||||
|
|
||||||
local luasnip = require('luasnip')
|
|
||||||
local snip = luasnip.snippet
|
|
||||||
local text = luasnip.text_node
|
|
||||||
local ins = luasnip.insert_node
|
|
||||||
local func = luasnip.function_node
|
|
||||||
local node = luasnip.snippet_node
|
|
||||||
local key = require("luasnip.nodes.key_indexer").new_key
|
|
||||||
|
|
||||||
local function short_name(name)
|
|
||||||
local short = string.lower(string.sub(name, 1, 1))
|
|
||||||
for i = 2, #name do
|
|
||||||
local char = string.sub(name, i, i)
|
|
||||||
if char == string.upper(char) then
|
|
||||||
short = short .. char
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return string.lower(short)
|
|
||||||
end
|
|
||||||
|
|
||||||
local snippets = {
|
|
||||||
|
|
||||||
snip('func', {
|
|
||||||
text('func '),
|
|
||||||
node(1, {
|
|
||||||
func(function(args)
|
|
||||||
if string.len(args[1][1]) > 0 then
|
|
||||||
return '(' .. short_name(args[1][1]) .. ' *'
|
|
||||||
end
|
|
||||||
return ''
|
|
||||||
end, key('type')),
|
|
||||||
ins(1, '', { key = 'type' }),
|
|
||||||
func(function(args)
|
|
||||||
if string.len(args[1][1]) > 0 then
|
|
||||||
return ') '
|
|
||||||
end
|
|
||||||
return ''
|
|
||||||
end, key('type')),
|
|
||||||
}),
|
|
||||||
ins(2, 'name'),
|
|
||||||
text('('),
|
|
||||||
ins(3, ''),
|
|
||||||
text(') '),
|
|
||||||
ins(4, '', { key = 'return' }),
|
|
||||||
func(function(args)
|
|
||||||
if string.len(args[1][1]) > 0 then
|
|
||||||
return ' '
|
|
||||||
end
|
|
||||||
return ''
|
|
||||||
end, key('return')),
|
|
||||||
text({ '{', '\t' }),
|
|
||||||
ins(0, ''),
|
|
||||||
text({ '', '}' }),
|
|
||||||
}),
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return snippets
|
|
||||||
Reference in New Issue
Block a user