feat!: remove trouble, use nvim-bqf

trouble, after a :grep jumps to a first result. Did not find how to not
jump...
This commit is contained in:
fiplox 2023-06-20 19:01:48 +02:00
parent 6f4b4ae1b8
commit 11cba124b9
5 changed files with 50 additions and 157 deletions

View File

@ -67,19 +67,6 @@ vim.api.nvim_create_autocmd('FileType', {
vim.opt_local.textwidth = 80
end,
})
function ToggleTroubleAuto()
local ok, trouble = pcall(require, 'trouble')
if ok then
vim.defer_fn(function()
vim.cmd 'lcl'
vim.cmd 'cclose'
trouble.open 'loclist'
end, 0)
end
end
-- vim.cmd "autocmd VimLeave * call os.execute("mkdir /tmp/nvim"), writefile([getcwd()], expand('/tmp/nvim/cwd'))"
vim.cmd [[autocmd BufWinEnter quickfix silent :lua ToggleTroubleAuto()]]
vim.cmd [[
augroup change_cursor
au!

View File

@ -32,30 +32,12 @@ keymap('n', '<leader>rs', ':s///gI<Left><Left><Left><Left><Left><Left>', { norem
keymap('n', '<leader>rr', ':%s///gI<Left><Left><Left><Left>', { noremap = true })
keymap('v', '<leader>r', ':s///gI<Left><Left><Left><Left>', { noremap = true })
keymap('n', '<leader>xl', '<cmd>TroubleToggle loclist<cr>', { silent = true, noremap = true })
keymap('n', '<leader>xq', '<cmd>TroubleToggle quickfix<cr>', { silent = true, noremap = true })
keymap('n', 'gR', '<cmd>TroubleToggle lsp_references<cr>', { silent = true, noremap = true })
keymap('n', '<leader>xx', '<cmd>TroubleToggle<cr>', { silent = true, noremap = true })
keymap(
'n',
'<leader>xw',
'<cmd>TroubleToggle workspace_diagnostics<cr>',
{ silent = true, noremap = true }
)
keymap(
'n',
'<leader>xd',
'<cmd>TroubleToggle document_diagnostics<cr>',
{ silent = true, noremap = true }
)
keymap('n', 'D', '"_d', { noremap = true })
keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opt)
keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opt)
keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.hover()<CR>', opt)
keymap('n', 'gI', '<cmd>lua vim.lsp.buf.implementation()<CR>', opt)
keymap('n', 'gr', '<cmd>TroubleToggle lsp_references<CR>', opt)
keymap('n', 'gl', '<cmd>lua vim.diagnostic.open_float()<CR>', opt)
keymap('n', '<leader>lf', '<cmd>lua vim.lsp.buf.format { async = true }<cr>', opt)
keymap('n', '<leader>li', '<cmd>LspInfo<cr>', opt)
@ -101,7 +83,9 @@ local function file_exists(name)
if f ~= nil then
io.close(f)
return true
else return false end
else
return false
end
end
if file_exists('/tmp/colemak') then
@ -155,6 +139,19 @@ local opts = {
noremap = true, -- use `noremap` when creating keymaps
nowait = false, -- use `nowait` when creating keymaps
}
vim.keymap.set('n', 'L', function()
local win = vim.api.nvim_get_current_win()
local qf_winid = vim.fn.getloclist(win, { winid = 0 }).winid
local action = qf_winid > 0 and 'lclose' or 'lopen'
vim.cmd(action)
end, { noremap = true, silent = true })
vim.keymap.set('n', 'X', function()
local qf_winid = vim.fn.getqflist({ winid = 0 }).winid
local action = qf_winid > 0 and 'cclose' or 'copen'
vim.cmd('botright ' .. action)
end, { noremap = true, silent = true })
-- }}}
-- leader mappings {{{
-- TODO create entire treesitter section
@ -169,7 +166,7 @@ local mappings = {
['f'] = { '<cmd>e ~/.config/nvim/ <cr>', 'Neovim config' },
['rr'] = 'Search and replace all',
['rs'] = 'Search and replace',
['c'] = { '<cmd>lua UnMapDHM()<cr>', 'Qwerty' },
['q'] = { '<cmd>lua UnMapDHM()<cr>', 'Qwerty' },
['b'] = {
function()
require('buffer_manager.ui').toggle_quick_menu()

View File

@ -23,7 +23,7 @@ opt.shortmess:append('I', 'W', 's')
opt.iskeyword:prepend { '-' }
opt.timeoutlen = 300
opt.fillchars = 'eob: '
opt.cmdheight = 0
opt.cmdheight = 1
opt.grepprg = 'rg --vimgrep --no-heading --smart-case --hidden'
opt.grepformat = '%f:%l:%c:%m'
@ -74,3 +74,5 @@ vim.api.nvim_create_autocmd({ 'BufWinEnter', 'FileType' }, {
group = vim.api.nvim_create_augroup('nvim-lastplace', {}),
callback = run,
})
vim.cmd("command! -nargs=+ Grep execute 'silent grep! <args>' | copen")

23
lua/plugins/bqf.lua Normal file
View File

@ -0,0 +1,23 @@
return {
'kevinhwang91/nvim-bqf',
lazy = false,
opts = {
-- description = [[Give the window magic, when the window is splited horizontally, keep
-- the distance between the current line and the top/bottom border of neovim unchanged.
-- It's a bit like a floating window, but the window is indeed a normal window, without
-- any floating attributes.]],
magic_window = true,
preview = {
auto_preview = true,
show_title = true,
show_scroll_bar = true,
winblend = 12,
wrap = false,
buf_label = true,
},
func_map = {
openc = '<CR>',
open = 'o',
}
}
}

View File

@ -1,75 +1,21 @@
return {
'folke/which-key.nvim',
'nvim-lua/plenary.nvim',
-- 'mfussenegger/nvim-jdtls',
-- 'simrat39/rust-tools.nvim',
-- 'MunifTanjim/nui.nvim',
{'rush-rs/tree-sitter-asm', ft = 'asm'},
{ 'jghauser/mkdir.nvim', lazy = false },
-- 'mfussenegger/nvim-jdtls',
-- 'simrat39/rust-tools.nvim',
{ 'rush-rs/tree-sitter-asm', ft = 'asm' },
{ 'jghauser/mkdir.nvim', lazy = false },
{
url = 'https://git.filnar.com/fiplox/neogruber.git',
-- dir = '~/dev/neogruber.nvim/',
lazy = false,
-- event = 'VeryLazy'
},
-- 'rcarriga/cmp-dap',
{
'phaazon/hop.nvim', -- event = 'BufRead',
keys = { { 's', ':HopChar2<cr>' }, { 'S', ':HopWord<cr>' } },
config = true,
},
--[[ {
'stevearc/dressing.nvim',
lazy = true,
init = function()
vim.ui.select = function(...)
require('lazy').load { plugins = { 'dressing.nvim' } }
return vim.ui.select(...)
end
vim.ui.input = function(...)
require('lazy').load { plugins = { 'dressing.nvim' } }
return vim.ui.input(...)
end
end,
opts = {
select = {
trim_prompt = false,
},
},
},]]
--[[ {
'folke/noice.nvim',
opts = {
messages = {
view_search = false,
},
cmdline = {
enabled = true,
view = 'cmdline', -- view for rendering the cmdline. Change to `cmdline` to get a classic cmdline at the bottom
},
presets = {
bottom_search = true, -- use a classic bottom cmdline for search
command_palette = false, -- position the cmdline and popupmenu together
long_message_to_split = true, -- long messages will be sent to a split
inc_rename = false, -- enables an input dialog for inc-rename.nvim
lsp_doc_border = false, -- add a border to hover docs and signature help
},
lsp = {
-- override markdown rendering so that **cmp** and other plugins use **Treesitter**
override = {
['vim.lsp.util.convert_input_to_markdown_lines'] = true,
['vim.lsp.util.stylize_markdown'] = true,
['cmp.entry.get_documentation'] = true,
},
hover = {
enabled = false,
},
signature = {
enabled = false,
},
},
},
},]]
{
'numToStr/Comment.nvim',
-- event = 'VeryLazy',
@ -114,7 +60,8 @@ return {
if ctx.ctype == U.ctype.blockwise then
location = require('ts_context_commentstring.utils').get_cursor_location()
elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then
location = require('ts_context_commentstring.utils').get_visual_start_location()
location = require('ts_context_commentstring.utils')
.get_visual_start_location()
end
return require('ts_context_commentstring.internal').calculate_commentstring {
@ -210,14 +157,6 @@ return {
-- The diffview integration enables the diff popup, which is a wrapper around `sindrets/diffview.nvim`.
--
-- Requires you to have `sindrets/diffview.nvim` installed.
-- use {
-- 'TimUntersberger/neogit',
-- requires = {
-- 'nvim-lua/plenary.nvim',
-- 'sindrets/diffview.nvim'
-- }
-- }
--
diffview = true,
},
-- Setting any section to `false` will make the section not render at all
@ -371,7 +310,7 @@ return {
},
},
},
{
{
'nvim-treesitter/nvim-treesitter',
-- lazy = false,
-- dependencies = { 'nvim-treesitter/playground' },
@ -400,61 +339,6 @@ return {
}
end,
},
{
'folke/trouble.nvim',
-- dependencies = {
-- 'nvim-tree/nvim-web-devicons',
-- },
cmd = { 'TroubleToggle', 'Trouble' },
opts = {
position = 'bottom', -- position of the list can be: bottom, top, left, right
height = 10, -- height of the trouble list when position is top or bottom
width = 50, -- width of the list when position is left or right
icons = true, -- use devicons for filenames
mode = 'loclist', -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist"
fold_open = '', -- icon used for open folds
fold_closed = '', -- icon used for closed folds
group = true, -- group results by file
padding = true, -- add an extra new line on top of the list
action_keys = {
-- key mappings for actions in the trouble list
-- map to {} to remove a mapping, for example:
-- close = {},
close = 'q', -- close the list
cancel = '<esc>', -- cancel the preview and get back to your last window / buffer / cursor
refresh = 'r', -- manually refresh
jump_close = { '<cr>', '<tab>' }, -- jump to the diagnostic or open / close folds
open_split = { '<c-x>' }, -- open buffer in new split
open_vsplit = { '<c-v>' }, -- open buffer in new vsplit
open_tab = { '<c-t>' }, -- open buffer in new tab
jump = { 'o' }, -- jump to the diagnostic and close the list
toggle_mode = 'm', -- toggle between "workspace" and "document" diagnostics mode
toggle_preview = 'P', -- toggle auto_preview
hover = 'K', -- opens a small popup with the full multiline message
preview = 'p', -- preview the diagnostic location
close_folds = { 'zM', 'zm' }, -- close all folds
open_folds = { 'zR', 'zr' }, -- open all folds
toggle_fold = { 'zA', 'za' }, -- toggle fold of current file
previous = 'k', -- preview item
next = 'j', -- next item
},
indent_lines = true, -- add an indent guide below the fold icons
auto_open = false, -- automatically open the list when you have diagnostics
auto_close = true, -- automatically close the list when you have no diagnostics
auto_preview = false, -- automatically preview the location of the diagnostic. <esc> to close preview and go back to last window
auto_fold = false, -- automatically fold a file trouble list at creation
auto_jump = { 'lsp_definitions' }, -- for the given modes, automatically jump if there is only a single result
signs = {
-- icons / text used for a diagnostic
error = '',
warning = '',
hint = '',
information = '',
other = '🞊',
},
use_diagnostic_signs = false, -- enabling this will use the signs defined in your lsp client
},
},
{
'j-morano/buffer_manager.nvim',
opts = {