diff options
Diffstat (limited to 'pkgs')
| -rw-r--r-- | pkgs/custom-neovim/config/init.lua | 3 | ||||
| -rw-r--r-- | pkgs/custom-neovim/config/lua/autocommands.lua | 1 | ||||
| -rw-r--r-- | pkgs/custom-neovim/config/lua/mappings.lua | 16 | ||||
| -rw-r--r-- | pkgs/custom-neovim/config/lua/options.lua | 2 | ||||
| -rw-r--r-- | pkgs/custom-neovim/config/lua/plugins/auto-session.lua | 1 | ||||
| -rw-r--r-- | pkgs/custom-neovim/config/lua/plugins/dropbar.lua | 44 | ||||
| -rw-r--r-- | pkgs/custom-neovim/config/lua/plugins/mini/statusline.lua | 29 | ||||
| -rw-r--r-- | pkgs/custom-neovim/config/lua/plugins/tabby.lua | 6 | ||||
| -rw-r--r-- | pkgs/custom-neovim/config/lua/statusline.lua | 209 | ||||
| -rw-r--r-- | pkgs/custom-neovim/default.nix | 5 | ||||
| -rw-r--r-- | pkgs/custom-neovim/design.md | 10 |
11 files changed, 216 insertions, 110 deletions
diff --git a/pkgs/custom-neovim/config/init.lua b/pkgs/custom-neovim/config/init.lua index 4a42bfc..337b021 100644 --- a/pkgs/custom-neovim/config/init.lua +++ b/pkgs/custom-neovim/config/init.lua @@ -17,8 +17,9 @@ require("plugins.mini.clue") require("plugins.mini.indentscope") require("plugins.mini.notify") require("plugins.treesitter") -require("plugins.oil") require("plugins.mini.files") +require("plugins.dropbar") +require("plugins.auto-session") -- LSP Plugins: require("plugins.lspconfig") diff --git a/pkgs/custom-neovim/config/lua/autocommands.lua b/pkgs/custom-neovim/config/lua/autocommands.lua index 5780482..d3e3835 100644 --- a/pkgs/custom-neovim/config/lua/autocommands.lua +++ b/pkgs/custom-neovim/config/lua/autocommands.lua @@ -6,3 +6,4 @@ vim.api.nvim_create_autocmd("TermOpen", { vim.cmd "startinsert!" end, }) + diff --git a/pkgs/custom-neovim/config/lua/mappings.lua b/pkgs/custom-neovim/config/lua/mappings.lua index b108e1a..2f872d4 100644 --- a/pkgs/custom-neovim/config/lua/mappings.lua +++ b/pkgs/custom-neovim/config/lua/mappings.lua @@ -16,6 +16,7 @@ mapkey("n", "<leader>?", "Open help picker", ":lua Snacks.picker.help()<cr>") mapkey("n", "<leader>p", "Open picker picker", ":lua Snacks.picker.pickers()<cr>") mapkey("n", "<leader>'", "Open last picker", ":lua Snacks.picker.resume()<cr>") mapkey("n", "<leader><leader>", "Open smart picker", ":lua Snacks.picker.smart()<cr>") +mapkey("n", "<leader>z", "Open zoxide picker", ":lua Snacks.picker.zoxide()<cr>") -- Tabs mapkey("n", "<leader>t", "Manage tabs", "") @@ -28,12 +29,12 @@ mapkey("n", "<leader>tp", "Go to previous tab", ":tabprev<cr>") mapkey("n", "<leader>w", "Manage windows", "<C-w>") -- Sessions -mapkey("n", "<leader>s", "Manage sessions", "") -mapkey("n", "<leader>sw", "Save current session", ":SessionSave<cr>") -mapkey("n", "<leader>ss", "Switch and save session", ":SessionSave<cr> <bar> :SessionSelect<cr>") -mapkey("n", "<leader>sp", "Open session picker", ":SessionSelect<cr>") -mapkey("n", "<leader>sd", "Delete current session", ":SessionDelete<cr>") -mapkey("n", "<leader>sl", "Open last session", ":SessionLoadLast<cr>") +mapkey("n", "<leader>m", "Manage sessions", "") +mapkey("n", "<leader>mw", "Save current session", ":SessionSave<cr>") +mapkey("n", "<leader>ms", "Switch and save session", ":SessionSave<cr> <bar> :SessionSelect<cr>") +mapkey("n", "<leader>mp", "Open session picker", ":SessionSelect<cr>") +mapkey("n", "<leader>md", "Delete current session", ":SessionDelete<cr>") +mapkey("n", "<leader>ml", "Open last session", ":SessionLoadLast<cr>") -- Terminals mapkey("n", "<leader>c", "Manage terminals", "") @@ -53,7 +54,10 @@ end, { expr = true }) -- Make enter complete command. mapkey("n", "<esc>", "Clear highlights", ":noh<cr>") -- Make esc clear highlights mapkey("n", "<leader>q", "Close buffer", ":bd<cr>") mapkey("n", "<leader>Q", "Force close buffer", ":bd!<cr>") + +-- Really delete mapkey({"n", "v"}, "<leader>d", "Really delete", [["_d]]) +mapkey({"n", "v"}, "<leader>x", "Really delete character", [["_x]]) -- Visual Movement Keys. -- mapkey({"n", "v"}, "j", "Go down visually", "gj") diff --git a/pkgs/custom-neovim/config/lua/options.lua b/pkgs/custom-neovim/config/lua/options.lua index f2ffcc9..e937102 100644 --- a/pkgs/custom-neovim/config/lua/options.lua +++ b/pkgs/custom-neovim/config/lua/options.lua @@ -12,7 +12,7 @@ vim.o.relativenumber = true -- set relative numbered lines vim.o.scrolloff = 4 -- minimal number of screen lines to keep above and below the cursor vim.o.signcolumn = "yes" -- always show the sign column, otherwise it would shift the text each time vim.o.clipboard = "unnamedplus" -- use system clipboard -vim.o.sessionoptions = 'curdir,folds,globals,help,tabpages,terminal,winsize' -- Things to save with the session. +vim.o.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions" -- Indention local indent = 2 diff --git a/pkgs/custom-neovim/config/lua/plugins/auto-session.lua b/pkgs/custom-neovim/config/lua/plugins/auto-session.lua new file mode 100644 index 0000000..99df59b --- /dev/null +++ b/pkgs/custom-neovim/config/lua/plugins/auto-session.lua @@ -0,0 +1 @@ +require("auto-session").setup() diff --git a/pkgs/custom-neovim/config/lua/plugins/dropbar.lua b/pkgs/custom-neovim/config/lua/plugins/dropbar.lua index 6d78b09..2d5fdaa 100644 --- a/pkgs/custom-neovim/config/lua/plugins/dropbar.lua +++ b/pkgs/custom-neovim/config/lua/plugins/dropbar.lua @@ -1 +1,43 @@ -require("dropbar").setup {} +local dropbar = require('dropbar') +local sources = require('dropbar.sources') +local utils = require('dropbar.utils') + +Utils.link_highlight("DropBarFileName", "MiniFilesTitleFocused") + +local custom_path = { + get_symbols = function(buff, win, cursor) + local symbols = sources.path.get_symbols(buff, win, cursor) + symbols[#symbols].name_hl = 'DropBarFileName' + if vim.bo[buff].modified then + symbols[#symbols].name = symbols[#symbols].name .. ' [+]' + symbols[#symbols].name_hl = 'DropBarFileName' + symbols[#symbols].truncate = false + end + return symbols + end, +} + +dropbar.setup({ + bar = { + sources = function(buf, _) + if vim.bo[buf].ft == 'markdown' then + return { + custom_path, + sources.markdown, + } + end + if vim.bo[buf].buftype == 'terminal' then + return { + sources.terminal, + } + end + return { + custom_path, + utils.source.fallback { + sources.lsp, + sources.treesitter, + }, + } + end, + }, +}) diff --git a/pkgs/custom-neovim/config/lua/plugins/mini/statusline.lua b/pkgs/custom-neovim/config/lua/plugins/mini/statusline.lua index acb04be..e5931a2 100644 --- a/pkgs/custom-neovim/config/lua/plugins/mini/statusline.lua +++ b/pkgs/custom-neovim/config/lua/plugins/mini/statusline.lua @@ -1 +1,28 @@ -require("mini.statusline") {} +require("mini.statusline").setup() + +MiniStatusline.config = { + content = { + active = function() + local mode, mode_hl = MiniStatusline.section_mode({ trunc_width = 120 }) + local git = MiniStatusline.section_git({ trunc_width = 40 }) + local diff = MiniStatusline.section_diff({ trunc_width = 75 }) + local diagnostics = MiniStatusline.section_diagnostics({ trunc_width = 75 }) + local lsp = MiniStatusline.section_lsp({ trunc_width = 75 }) + local filename = MiniStatusline.section_filename({ trunc_width = 140 }) + local fileinfo = MiniStatusline.section_fileinfo({ trunc_width = 120 }) + local location = MiniStatusline.section_location({ trunc_width = 75 }) + local search = MiniStatusline.section_searchcount({ trunc_width = 75 }) + + return MiniStatusline.combine_groups({ + { hl = mode_hl, strings = { mode } }, + { hl = 'MiniStatuslineDevinfo', strings = { git, diff, diagnostics, lsp } }, + '%<', -- Mark general truncate point + { hl = 'MiniStatuslineFilename', strings = { filename } }, + '%=', -- End left alignment + { hl = 'MiniStatuslineFileinfo', strings = { fileinfo } }, + { hl = mode_hl, strings = { search, location } }, + }) + end + }, + use_icons = true, +} diff --git a/pkgs/custom-neovim/config/lua/plugins/tabby.lua b/pkgs/custom-neovim/config/lua/plugins/tabby.lua index c4533c7..c00dad7 100644 --- a/pkgs/custom-neovim/config/lua/plugins/tabby.lua +++ b/pkgs/custom-neovim/config/lua/plugins/tabby.lua @@ -1,6 +1,6 @@ local general_theme = Utils.generate_theme_from_highlight_groups() local colors = { - current = { fg = general_theme.modes.insert, bg = general_theme.background, style = 'bold'}, + current = { fg = general_theme.modes.normal, bg = general_theme.background, style = 'bold'}, not_current = { fg = general_theme.text.light, bg = general_theme.background }; fill = { bg = general_theme.background }; }; @@ -24,7 +24,7 @@ require('tabby').setup({ return { line.sep('', hl, theme.fill), -- tab.is_current() and '' or '', - tab.number(), + -- tab.number(), tab.name(), line.sep('', hl, theme.fill), hl = hl, @@ -44,7 +44,7 @@ require('tabby').setup({ end), { line.sep('', theme.tail, theme.fill), - { ' ', hl = theme.tail }, + -- { ' ', hl = theme.tail }, }, hl = theme.fill, } diff --git a/pkgs/custom-neovim/config/lua/statusline.lua b/pkgs/custom-neovim/config/lua/statusline.lua index 9ee89c2..9f0106d 100644 --- a/pkgs/custom-neovim/config/lua/statusline.lua +++ b/pkgs/custom-neovim/config/lua/statusline.lua @@ -3,15 +3,12 @@ -- TODO: Components to add -- -- mode --- git diff -- git branch -- -- cwd -- -- lsp diagnostics -- lsp status --- position % --- location ##:## -- Highlight pattern local hi_pattern = '%%#%s#%s%%*' @@ -56,105 +53,131 @@ local mode_to_str = { ['t'] = 'TERMINAL', } -local statusline_components = { +local statusline_components = {} - micro_spacer = function() - return " " - end, +statusline_components.micro_spacer = function() + return " " +end - spacer = function() - return '%=' - end, +statusline_components.spacer = function() + return '%=' +end - old_diagnostic_status = function() - local ok = ' λ ' +statusline_components.diagnostic_status = function() + local diagnostics = {} - local ignore = { - ['c'] = true, -- command mode - ['t'] = true -- terminal mode - } + local errors = #vim.diagnostic.get(0, { severity = 1 }) - local mode = vim.api.nvim_get_mode().mode + if errors > 0 then + table.insert(diagnostics, "%#DiagnosticSignError# " .. tostring(errors)) + end - if ignore[mode] then - return ok - end + local warnings = #vim.diagnostic.get(0, { severity = 2 }) - local levels = vim.diagnostic.severity - local errors = #vim.diagnostic.get(0, {severity = levels.ERROR}) - if errors > 0 then - return ' ✘ ' - end + if warnings > 0 then + table.insert(diagnostics, "%#DiagnosticSignWarn# " .. tostring(warnings)) + end - local warnings = #vim.diagnostic.get(0, {severity = levels.WARN}) - if warnings > 0 then - return ' ▲ ' - end + local infos = #vim.diagnostic.get(0, { severity = 3 }) - return ok - end, - - diagnostic_status = function() - return "" - end, - - mode = function() - -- Get the respective string to display. - local mode = mode_to_str[vim.api.nvim_get_mode().mode] or 'UNKNOWN' - - -- Set the highlight group. - local hl = 'MiniStatuslineModeOther' - if mode:find 'NORMAL' then - hl = 'MiniStatuslineModeNormal' - elseif mode:find 'PENDING' then - hl = 'MiniStatuslineModeNormal' - elseif mode:find 'VISUAL' then - hl = 'MiniStatuslineModeVisual' - elseif mode:find 'REPLACE' then - hl = 'MiniStatuslineModeReplace' - elseif mode:find 'INSERT' or mode:find 'SELECT' then - hl = 'MiniStatuslineModeInsert' - elseif mode:find 'COMMAND' or mode:find 'TERMINAL' or mode:find 'EX' then - hl = 'MiniStatuslineModeCommand' - end + if infos > 0 then + table.insert(diagnostics, "%#DiagnosticSignInfo# " .. tostring(infos)) + end - -- Construct the component. - return hi_pattern:format(hl, string.format(' %s ', mode)) - end, - - position = function() - -- Get the respective string to display. - local mode = mode_to_str[vim.api.nvim_get_mode().mode] or 'UNKNOWN' - - -- Set the highlight group. - local hl = 'MiniStatuslineModeOther' - if mode:find 'NORMAL' then - hl = 'MiniStatuslineModeNormal' - elseif mode:find 'PENDING' then - hl = 'MiniStatuslineModeNormal' - elseif mode:find 'VISUAL' then - hl = 'MiniStatuslineModeVisual' - elseif mode:find 'REPLACE' then - hl = 'MiniStatuslineModeReplace' - elseif mode:find 'INSERT' or mode:find 'SELECT' then - hl = 'MiniStatuslineModeInsert' - elseif mode:find 'COMMAND' or mode:find 'TERMINAL' or mode:find 'EX' then - hl = 'MiniStatuslineModeCommand' - end + local hints = #vim.diagnostic.get(0, { severity = 4 }) - -- Construct the component. - return hi_pattern:format(hl, ' %2l:%-2c ') - end, + if hints > 0 then + table.insert(diagnostics, "%#DiagnosticSignHint# " .. tostring(hints)) + end - git_branch = function() - if vim.b.minigit_summary and vim.b.minigit_summary.head_name then - return string.format(' %s ', vim.b.minigit_summary.head_name) - else - return '' -- Return an empty string or some default value if the branch name is not available - end + table.insert(diagnostics, "%#StatusLine#") + + vim.defer_fn(vim.cmd.redrawstatus, 500) + + return table.concat(diagnostics, " ") +end + +statusline_components.mode = function() + -- Get the respective string to display. + local mode = mode_to_str[vim.api.nvim_get_mode().mode] or 'UNKNOWN' + + -- Set the highlight group. + local hl = 'MiniStatuslineModeOther' + if mode:find 'NORMAL' then + hl = 'MiniStatuslineModeNormal' + elseif mode:find 'PENDING' then + hl = 'MiniStatuslineModeNormal' + elseif mode:find 'VISUAL' then + hl = 'MiniStatuslineModeVisual' + elseif mode:find 'REPLACE' then + hl = 'MiniStatuslineModeReplace' + elseif mode:find 'INSERT' or mode:find 'SELECT' then + hl = 'MiniStatuslineModeInsert' + elseif mode:find 'COMMAND' or mode:find 'TERMINAL' or mode:find 'EX' then + hl = 'MiniStatuslineModeCommand' end -} + -- Construct the component. + return hi_pattern:format(hl, string.format(' %s ', mode)) +end + +statusline_components.position = function() + -- Get the respective string to display. + local mode = mode_to_str[vim.api.nvim_get_mode().mode] or 'UNKNOWN' + + -- Set the highlight group. + local hl = 'MiniStatuslineModeOther' + if mode:find 'NORMAL' then + hl = 'MiniStatuslineModeNormal' + elseif mode:find 'PENDING' then + hl = 'MiniStatuslineModeNormal' + elseif mode:find 'VISUAL' then + hl = 'MiniStatuslineModeVisual' + elseif mode:find 'REPLACE' then + hl = 'MiniStatuslineModeReplace' + elseif mode:find 'INSERT' or mode:find 'SELECT' then + hl = 'MiniStatuslineModeInsert' + elseif mode:find 'COMMAND' or mode:find 'TERMINAL' or mode:find 'EX' then + hl = 'MiniStatuslineModeCommand' + end + + -- Construct the component. + return hi_pattern:format(hl, ' %2l:%-2c ') +end + +statusline_components.git_branch = function() + if vim.b.minigit_summary and vim.b.minigit_summary.head_name then + return string.format(' %s ', vim.b.minigit_summary.head_name) + else + return '' -- Return an empty string or some default value if the branch name is not available + end +end + +statusline_components.working_directory = function() + local text = vim.fn.getcwd() + + local parts = {} + for part in string.gmatch(text, "[^/]+") do + table.insert(parts, part) + end + + -- replace /home/USER with ~/ + if #parts >= 3 then + table.remove(parts, 1) + table.remove(parts, 1) + table.insert(parts, 1, "~") + end + + text = table.concat(parts, "/") + + -- if the cwd takes up more than half the bar width, shorten it. + if text:len() > (vim.api.nvim_win_get_width(0) / 2.5) then + if #parts >= 1 then + text = ".../" .. parts[#parts] + end + end + return string.format(' %s ', text) +end Statusline_component = function(name) return statusline_components[name]() @@ -168,15 +191,15 @@ local statusline = { get_component("micro_spacer"), get_component("mode"), - get_component("diagnostic_status"), + get_component("working_directory"), get_component("git_branch"), + get_component("diagnostic_status"), - get_component("spacer"), -- spacer + get_component("spacer"), - '%{&filetype}', -- filetype - ' %2p%% ', -- progress % + ' %{&filetype} ', -- filetype + '%2p%% ', -- progress % get_component("position"), - } vim.o.statusline = table.concat(statusline, '') diff --git a/pkgs/custom-neovim/default.nix b/pkgs/custom-neovim/default.nix index 6b78fde..a0d6f03 100644 --- a/pkgs/custom-neovim/default.nix +++ b/pkgs/custom-neovim/default.nix @@ -18,10 +18,11 @@ in nvim-treesitter.withAllGrammars # All treesitter grammars. tabby-nvim # Tab bar. lualine-nvim # Status line. - alpha-nvim # Dashboard. + # alpha-nvim # Dashboard. persisted-nvim # Session manager. snacks-nvim - oil-nvim + # oil-nvim + dropbar-nvim # Colorschemes oxocarbon-nvim # IBM Carbon themes. diff --git a/pkgs/custom-neovim/design.md b/pkgs/custom-neovim/design.md index d634834..4f83cf5 100644 --- a/pkgs/custom-neovim/design.md +++ b/pkgs/custom-neovim/design.md @@ -13,7 +13,13 @@ - Figure out good session management - Configure terminal management - add quick window switcher plugin -- make vertical dividers the same color as text - add automatic parentheses - add smart indentation - +- make tabby run on highlight groups +- add modified tags to tabby +- add gitsigns +- base statusline git branch on gitsigns +- add git status to statusline +- dim unfocused windows +- prevent dropbar filename from truncating +- add keybind to activate dropbar drop down menu |
