Compare commits

..

2 Commits

Author SHA1 Message Date
11cba124b9 feat!: remove trouble, use nvim-bqf
trouble, after a :grep jumps to a first result. Did not find how to not
jump...
2023-06-20 19:01:48 +02:00
6f4b4ae1b8 feat: use feline instead of lualine 2023-06-20 19:00:40 +02:00
9 changed files with 396 additions and 204 deletions

View File

@ -16,7 +16,7 @@ vim.opt.runtimepath:prepend(lazypath)
vim.api.nvim_create_autocmd('User', { vim.api.nvim_create_autocmd('User', {
pattern = 'LazyVimStarted', pattern = 'LazyVimStarted',
callback = function() callback = function()
require 'lualine' require 'feline'
require 'config.mappings' require 'config.mappings'
require 'config.autocmd' require 'config.autocmd'
-- require 'noice' -- require 'noice'

View File

@ -67,19 +67,6 @@ vim.api.nvim_create_autocmd('FileType', {
vim.opt_local.textwidth = 80 vim.opt_local.textwidth = 80
end, 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 [[ vim.cmd [[
augroup change_cursor augroup change_cursor
au! 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('n', '<leader>rr', ':%s///gI<Left><Left><Left><Left>', { noremap = true })
keymap('v', '<leader>r', ':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', 'D', '"_d', { noremap = true })
keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opt) keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opt)
keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<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', '<C-k>', '<cmd>lua vim.lsp.buf.hover()<CR>', opt)
keymap('n', 'gI', '<cmd>lua vim.lsp.buf.implementation()<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', '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>lf', '<cmd>lua vim.lsp.buf.format { async = true }<cr>', opt)
keymap('n', '<leader>li', '<cmd>LspInfo<cr>', opt) keymap('n', '<leader>li', '<cmd>LspInfo<cr>', opt)
@ -101,7 +83,9 @@ local function file_exists(name)
if f ~= nil then if f ~= nil then
io.close(f) io.close(f)
return true return true
else return false end else
return false
end
end end
if file_exists('/tmp/colemak') then if file_exists('/tmp/colemak') then
@ -155,6 +139,19 @@ local opts = {
noremap = true, -- use `noremap` when creating keymaps noremap = true, -- use `noremap` when creating keymaps
nowait = false, -- use `nowait` 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 {{{ -- leader mappings {{{
-- TODO create entire treesitter section -- TODO create entire treesitter section
@ -169,7 +166,7 @@ local mappings = {
['f'] = { '<cmd>e ~/.config/nvim/ <cr>', 'Neovim config' }, ['f'] = { '<cmd>e ~/.config/nvim/ <cr>', 'Neovim config' },
['rr'] = 'Search and replace all', ['rr'] = 'Search and replace all',
['rs'] = 'Search and replace', ['rs'] = 'Search and replace',
['c'] = { '<cmd>lua UnMapDHM()<cr>', 'Qwerty' }, ['q'] = { '<cmd>lua UnMapDHM()<cr>', 'Qwerty' },
['b'] = { ['b'] = {
function() function()
require('buffer_manager.ui').toggle_quick_menu() require('buffer_manager.ui').toggle_quick_menu()

View File

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

View File

@ -49,4 +49,288 @@ M.lsp_config = {
}, },
} }
M.lspservername = function()
local msg = ''
local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype')
local clients = vim.lsp.get_active_clients()
if next(clients) == nil then return msg end
for _, client in ipairs(clients) do
local filetypes = client.config.filetypes
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
return client.name
end
end
return msg
end
M.feline_theme = {
fg = '#c9d1d9',
bg = '#101010',
green = '#66cc66',
yellow = '#ffdd11',
purple = '#c678dd',
orange = '#cc8c3c',
peanut = '#f6d5a4',
red = '#e06c75',
aqua = '#61afef',
bg2 = '#484848',
dark_red = '#f75f5f',
normal = '#A9A9A9'
}
M.feline_vi_mode_colors = {
NORMAL = 'normal',
OP = 'green',
INSERT = 'yellow',
VISUAL = 'orange',
LINES = 'orange',
BLOCK = 'dark_red',
REPLACE = 'red',
COMMAND = 'aqua',
}
local left_component_separator = {
str = '',
hl = {
fg = '#4a4a4a',
},
}
local right_component_separator = {
str = '',
hl = {
fg = '#4a4a4a',
},
}
local left_section_separator = {
str = '█',
hl = {
fg = 'normal',
},
}
local right_section_separator = {
str = '',
hl = {
fg = '#4a4a4a',
},
}
local function selectionCount()
local isVisualMode = vim.fn.mode():find("[Vv]")
if not isVisualMode then return "" end
local starts = vim.fn.line("v")
local ends = vim.fn.line(".")
local lines = starts <= ends and ends - starts + 1 or starts - ends + 1
return "" .. tostring(lines) .. "L " .. tostring(vim.fn.wordcount().visual_chars) .. "C"
end
M.feline_c = {
right_separator = {
provider = '',
left_sep = ' ',
hl = {
fg = '#484848'
}
},
left_separator = {
provider = '',
left_sep = ' ',
hl = {
fg = '#484848'
}
},
vim_mode = {
provider = {
name = 'vi_mode',
opts = {
show_mode_name = true,
-- padding = "center", -- Uncomment for extra padding.
},
},
hl = function()
return {
bg = require('feline.providers.vi_mode').get_mode_color(),
fg = 'bg',
style = 'bold',
name = 'NeovimModeHLColor',
}
end,
left_sep = 'block',
right_sep = {
str = '█',
hl = function()
return {
fg = require('feline.providers.vi_mode').get_mode_color(),
style = 'bold',
name = 'NeovimModeHLColor',
}
end,
},
},
diagnostic_errors = {
provider = 'diagnostic_errors',
hl = {
fg = 'red',
},
},
diagnostic_warnings = {
provider = 'diagnostic_warnings',
hl = {
fg = 'yellow',
},
},
diagnostic_hints = {
provider = 'diagnostic_hints',
hl = {
fg = 'aqua',
},
},
diagnostic_info = {
provider = 'diagnostic_info',
},
file_info = {
provider = {
name = 'file_info',
opts = {
colored_icon = true,
type = 'relative-short',
},
},
hl = {
fg = 'bg2',
},
left_sep = ' ',
},
lsp_client_names = {
provider = 'lsp_client_names',
hl = {
fg = 'bg2',
},
left_sep = 'right',
},
file_type = {
provider = {
name = 'file_type',
opts = {
filetype_icon = false,
colored_icon = false,
case = 'lowercase',
},
},
hl = {
fg = 'bg2',
},
left_sep = left_component_separator,
right_sep = ' ',
},
file_encoding = {
provider = 'file_encoding',
hl = {
fg = 'bg2',
},
left_sep = left_component_separator,
right_sep = ' ',
},
position = {
provider = 'position',
hl = function()
return {
bg = require('feline.providers.vi_mode').get_mode_color(),
fg = 'bg',
style = 'bold',
name = 'NeovimModeHLColor',
}
end,
right_sep = 'block',
left_sep = {
str = '█',
hl = function()
return {
fg = require('feline.providers.vi_mode').get_mode_color(),
style = 'bold',
name = 'NeovimModeHLColor',
}
end,
},
},
select_count = {
provider = selectionCount,
hl = function()
return {
fg = require('feline.providers.vi_mode').get_mode_color(),
style = 'bold',
name = 'NeovimModeHLColor',
}
end,
left_sep = ' ',
right_sep = ' ',
},
line_percentage = {
provider = 'line_percentage',
hl = {
fg = 'normal',
},
left_sep = ' ',
right_sep = ' ',
},
scroll_bar = {
provider = 'scroll_bar',
hl = {
fg = 'yellow',
style = 'bold',
},
},
search_count = {
provider = 'search_count',
left_sep = left_component_separator,
right_sep = ' ',
},
macro = {
provider = 'macro',
hl = {
style = 'bold',
bg = 'bg2',
},
left_sep = 'block',
right_sep = 'block',
},
gitBranch = {
provider = 'git_branch',
hl = {
fg = 'peanut',
bg = 'bg2',
style = 'bold',
},
left_sep = ' ',
right_sep = right_section_separator,
},
gitDiffAdded = {
provider = 'git_diff_added',
hl = {
fg = 'green',
bg = 'bg2',
},
left_sep = 'block',
right_sep = 'block',
},
gitDiffRemoved = {
provider = 'git_diff_removed',
hl = {
fg = 'red',
bg = 'bg2',
},
left_sep = 'block',
right_sep = 'block',
},
gitDiffChanged = {
provider = 'git_diff_changed',
hl = {
fg = 'fg',
bg = 'bg2',
},
left_sep = 'block',
right_sep = 'right_filled',
},
}
return M return M

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',
}
}
}

61
lua/plugins/feline.lua Normal file
View File

@ -0,0 +1,61 @@
return {
'feline-nvim/feline.nvim',
dependencies = {
'nvim-tree/nvim-web-devicons',
},
config = function()
local feline = require 'feline'
local utils = require 'config.utils'
local c = utils.feline_c
local theme = utils.feline_theme
local vi_mode_colors = utils.feline_vi_mode_colors
local left = {
c.vim_mode,
-- c.gitBranch,
-- c.gitDiffAdded,
-- c.gitDiffRemoved,
-- c.gitDiffChanged,
c.file_info,
c.right_separator,
c.lsp_client_names,
c.diagnostic_errors,
c.diagnostic_warnings,
c.diagnostic_info,
c.diagnostic_hints,
}
-- local middle = {
-- c.separator,
-- }
local right = {
c.file_type,
c.search_count,
c.macro,
c.file_encoding,
c.line_percentage,
c.select_count,
c.position,
}
local components = {
active = {
left,
-- middle,
right,
},
inactive = {
left,
-- middle,
right,
},
}
feline.setup {
components = components,
theme = theme,
vi_mode_colors = vi_mode_colors,
}
end,
}

View File

@ -1,75 +1,21 @@
return { return {
'folke/which-key.nvim', 'folke/which-key.nvim',
'nvim-lua/plenary.nvim', 'nvim-lua/plenary.nvim',
-- 'mfussenegger/nvim-jdtls', -- 'mfussenegger/nvim-jdtls',
-- 'simrat39/rust-tools.nvim', -- 'simrat39/rust-tools.nvim',
-- 'MunifTanjim/nui.nvim', { 'rush-rs/tree-sitter-asm', ft = 'asm' },
{'rush-rs/tree-sitter-asm', ft = 'asm'}, { 'jghauser/mkdir.nvim', lazy = false },
{ 'jghauser/mkdir.nvim', lazy = false },
{ {
url = 'https://git.filnar.com/fiplox/neogruber.git', url = 'https://git.filnar.com/fiplox/neogruber.git',
-- dir = '~/dev/neogruber.nvim/', -- dir = '~/dev/neogruber.nvim/',
lazy = false, lazy = false,
-- event = 'VeryLazy' -- event = 'VeryLazy'
}, },
-- 'rcarriga/cmp-dap',
{ {
'phaazon/hop.nvim', -- event = 'BufRead', 'phaazon/hop.nvim', -- event = 'BufRead',
keys = { { 's', ':HopChar2<cr>' }, { 'S', ':HopWord<cr>' } }, keys = { { 's', ':HopChar2<cr>' }, { 'S', ':HopWord<cr>' } },
config = true, 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', 'numToStr/Comment.nvim',
-- event = 'VeryLazy', -- event = 'VeryLazy',
@ -114,7 +60,8 @@ return {
if ctx.ctype == U.ctype.blockwise then if ctx.ctype == U.ctype.blockwise then
location = require('ts_context_commentstring.utils').get_cursor_location() location = require('ts_context_commentstring.utils').get_cursor_location()
elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then 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 end
return require('ts_context_commentstring.internal').calculate_commentstring { 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`. -- The diffview integration enables the diff popup, which is a wrapper around `sindrets/diffview.nvim`.
-- --
-- Requires you to have `sindrets/diffview.nvim` installed. -- Requires you to have `sindrets/diffview.nvim` installed.
-- use {
-- 'TimUntersberger/neogit',
-- requires = {
-- 'nvim-lua/plenary.nvim',
-- 'sindrets/diffview.nvim'
-- }
-- }
--
diffview = true, diffview = true,
}, },
-- Setting any section to `false` will make the section not render at all -- Setting any section to `false` will make the section not render at all
@ -371,7 +310,7 @@ return {
}, },
}, },
}, },
{ {
'nvim-treesitter/nvim-treesitter', 'nvim-treesitter/nvim-treesitter',
-- lazy = false, -- lazy = false,
-- dependencies = { 'nvim-treesitter/playground' }, -- dependencies = { 'nvim-treesitter/playground' },
@ -400,61 +339,6 @@ return {
} }
end, 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', 'j-morano/buffer_manager.nvim',
opts = { opts = {

View File

@ -1,46 +0,0 @@
return {
'nvim-lualine/lualine.nvim',
dependencies = {
'nvim-tree/nvim-web-devicons',
},
opts = {
options = {
icons_enabled = true,
theme = 'auto',
component_separators = { left = '', right = '' },
section_separators = { left = '', right = '' },
disabled_filetypes = {
statusline = {},
winbar = {},
},
ignore_focus = {},
always_divide_middle = true,
globalstatus = false,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
}
},
sections = {
lualine_a = { 'mode' },
lualine_b = { 'diagnostics' },
lualine_c = { 'filename' },
lualine_x = { 'encoding', 'fileformat', 'filetype' },
lualine_y = { 'progress' },
lualine_z = { 'selectioncount', 'location' }
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { 'filename' },
lualine_x = { 'location' },
lualine_y = {},
lualine_z = {}
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {}
}
}