diff options
| -rw-r--r-- | after/ftplugin/fugitive.lua | 2 | ||||
| -rw-r--r-- | after/ftplugin/tex.lua | 38 | ||||
| -rw-r--r-- | colors/notsoquiet.lua | 32 | ||||
| -rw-r--r-- | init.lua | 2 | ||||
| -rw-r--r-- | lua/mo/fzf.lua | 20 | ||||
| -rw-r--r-- | lua/mo/statusline.lua | 20 | ||||
| -rw-r--r-- | nvim-pack-lock.json | 10 | ||||
| -rw-r--r-- | plugin/10_options.lua | 4 | ||||
| -rw-r--r-- | plugin/11_keymaps.lua | 46 | ||||
| -rw-r--r-- | plugin/12_autocommands.lua | 6 | ||||
| -rw-r--r-- | plugin/plugins/gitsigns.lua | 1 | ||||
| -rw-r--r-- | plugin/plugins/mini.lua | 94 |
12 files changed, 212 insertions, 63 deletions
diff --git a/after/ftplugin/fugitive.lua b/after/ftplugin/fugitive.lua new file mode 100644 index 0000000..2d1fbb5 --- /dev/null +++ b/after/ftplugin/fugitive.lua @@ -0,0 +1,2 @@ +vim.keymap.set("n", "<Leader>p", "<Cmd>Git push<CR>", { buffer = true, remap = false }) +vim.keymap.set("n", "<Leader>P", "<Cmd>Git pull<CR>", { buffer = true, remap = false }) diff --git a/after/ftplugin/tex.lua b/after/ftplugin/tex.lua index 963ab7f..5a51d91 100644 --- a/after/ftplugin/tex.lua +++ b/after/ftplugin/tex.lua @@ -1,19 +1,33 @@ vim.cmd([[setlocal shiftwidth=2 tabstop=2]]) vim.fn.call("vimtex#imaps#add_map", { - { - lhs = "++", - rhs = "\\item ", - leader = "", - wrapper = "vimtex#imaps#wrap_environment", - context = { "itemize", "enumerate", "description" }, - }, + { + lhs = "++", + rhs = "\\item ", + leader = "", + wrapper = "vimtex#imaps#wrap_environment", + context = { "itemize", "enumerate", "description" }, + }, }) vim.fn.call("vimtex#imaps#add_map", { - { - lhs = "e", - rhs = "\\eps", - wrapper = "vimtex#imaps#wrap_math", - }, + { + lhs = "e", + rhs = "\\eps", + wrapper = "vimtex#imaps#wrap_math", + }, }) + +vim.b.surround_101 = "\\begin{\1environment: \1}\r\\end{\1\1}" -- surround with e (environment) +vim.b.surround_99 = "\\\1command: \1{\r}" -- surround with c (command) + +vim.keymap.set("v", "<C-i>", function() + local key = vim.api.nvim_replace_termcodes("Scemph<CR>", true, false, true) + vim.api.nvim_feedkeys(key, "v", false) +end, { desc = "Latex: Emphasize text" }) + +vim.keymap.set("v", "<C-b>", function() + local key = + vim.api.nvim_replace_termcodes("Sctextbf<CR>", true, false, true) + vim.api.nvim_feedkeys(key, "v", false) +end, { desc = "Latex: Make text bold" }) diff --git a/colors/notsoquiet.lua b/colors/notsoquiet.lua index f87ae7b..b4d2b84 100644 --- a/colors/notsoquiet.lua +++ b/colors/notsoquiet.lua @@ -9,7 +9,7 @@ local hi = function(name, val) end local c = { - bg = "#1e1e1e", + bg = vim.g.notsoquiet_trans and "none" or "#1e1e1e", bg1 = "#303030", bg2 = "#222222", fg = "#cccccc", @@ -25,6 +25,7 @@ local c = { blue = "#6688ff", blue1 = "#729fcf", darkblue = "#364e81", + darkerblue = "#213768", yellow = "#ffff00", darkyellow = "#cdcd00", pink = "#d7005f", @@ -41,6 +42,8 @@ hi("Repeat", { link = "Keyword" }) hi("Macro", { link = "Keyword" }) hi("Define", { link = "Keyword" }) +hi("PreProc", { fg = c.orange }) + hi("Function", { fg = c.magenta, bold = true }) hi("@function", { link = "Function" }) @@ -77,7 +80,7 @@ hi("texMathDelim", { fg = c.orange }) hi("texMathSymbol", { link = "Number" }) hi("texMathDelimZone", { fg = c.fg1, bold = true }) -hi("StatusLine", { bg = c.darkblue, bold = true, fg = c.fg1 }) +hi("StatusLine", { bg = c.darkblue, fg = c.fg1 }) hi("Todo", { fg = c.yellow, reverse = true, bold = true }) hi("MiniHipatternsTodo", { link = "Todo" }) @@ -87,6 +90,21 @@ hi("SpellCap", { sp = "#0087d7", undercurl = true }) hi("SpellLocal", { sp = "#d787d7", undercurl = true }) hi("SpellRare", { sp = "#00afaf", undercurl = true }) +hi("DiffAdd", { bg = "#232D1A" }) +hi("diffAdded", { link = "DiffAdd" }) +hi("Added", { link = "DiffAdd" }) +hi("DiffChange", { bg = "#1D2C36" }) +hi("diffChanged", { link = "DiffChange" }) +hi("Changed", { link = "DiffChange" }) +hi("DiffDelete", { bg = "#3E2225" }) +hi("diffRemoved", { link = "DiffDelete" }) +hi("Removed", { link = "DiffDelete" }) +hi("DiffText", { fg = "#BBBBBB", bg = "#324757" }) + +hi("GitSignsAdd", { fg = "#405827" }) +hi("GitSignsChange", { fg = "#0b3e5a" }) +hi("GitSignsDelete", { fg = "#5c262e" }) + hi("DiffTextAdd", { italic = true }) hi("DiffAdded", { link = "DiffAdd" }) hi("@diff.plus", { link = "DiffAdd" }) @@ -114,6 +132,16 @@ hi("FzfLuaFzfPointer", { fg = c.red }) hi("DiagnosticHint", { fg = c.blue }) hi("DiagnosticUnderlineHint", { sp = c.blue, underline = true }) +hi("SLDev", { bg = c.darkerblue }) +hi("SLFilename", { link = "StatusLine" }) +hi("SLFileInfo", { bg = c.darkerblue, bold = true }) +hi("SLLocation", { bg = c.darkerblue }) + +hi("DiagSLError", { bg = c.darkerblue, fg = "Red" }) +hi("DiagSLWarn", { bg = c.darkerblue, fg = "Orange" }) +hi("DiagSLInfo", { bg = c.darkerblue, fg = "LightBlue" }) +hi("DiagSLHint", { bg = c.darkerblue, fg = c.blue }) + -- hi("Normal", { fg = "#dadada", bg = "None" }) -- hi("NormalFloat", { fg = "#dadada", bg = "#303030" }) -- hi("String", { fg = "#6eb167" }) @@ -88,6 +88,8 @@ vim.pack.add({ "https://github.com/tpope/vim-fugitive", "https://github.com/tpope/vim-surround", + "https://github.com/lewis6991/gitsigns.nvim", + "https://github.com/stevearc/quicker.nvim", "https://github.com/stevearc/conform.nvim", diff --git a/lua/mo/fzf.lua b/lua/mo/fzf.lua index c5c4b3e..b4c22ba 100644 --- a/lua/mo/fzf.lua +++ b/lua/mo/fzf.lua @@ -22,11 +22,19 @@ fzf.setup({ defaults = { git_icons = false, file_icons = false }, tags = { previewer = "bat" }, btags = { previewer = "bat" }, - files = { fzf_opts = { ["--ansi"] = false } }, + files = { + previewer = "bat", + fzf_opts = { ["--ansi"] = true }, + cwd_header = true, + winopts = { toggle_behavior = "default", preview = { hidden = true } }, + formatter = "path.dirname_first", + }, grep = { fzf_opts = { ["--ansi"] = false }, - rg_glob = true, rg_opts = " --color=never --column --line-number --no-heading --smart-case --max-columns=4096 -e", + rg_glob = true, + glob_flag = "--iglob", + glob_separator = "%s%-%-", }, builtin = { winopts = { width = 1, height = 1 } }, blines = swiper, @@ -35,14 +43,14 @@ fzf.setup({ git = { blame = swiper }, winopts = function() - local height = math.ceil(vim.o.lines / 2) + local height = math.ceil(2 * vim.o.lines / 3) return { backdrop = 80, row = 1, col = 0, width = 1, height = height > 3 and height or 1, - border = {"", " ", "", "", "", "", "", ""}, + border = { "", " ", "", "", "", "", "", "" }, toggle_behavior = "extend", --- @diagnostic disable-next-line: missing-fields preview = { @@ -50,7 +58,7 @@ fzf.setup({ treesitter = false, layout = "vertical", vertical = "up:60%", - border = {"", " ", "", "", "", "", "", ""}, + border = { "", " ", "", "", "", "", "", "" }, }, on_create = function() vim.keymap.set( @@ -68,7 +76,9 @@ fzf.setup({ end, keymap = { fzf = { + true, ["ctrl-q"] = "select-all+accept", + ["alt-p"] = "toggle-preview", }, }, }) diff --git a/lua/mo/statusline.lua b/lua/mo/statusline.lua deleted file mode 100644 index b24436c..0000000 --- a/lua/mo/statusline.lua +++ /dev/null @@ -1,20 +0,0 @@ --- local function lsp_status() --- local clients = vim.lsp.get_active_clients({ bufnr = 0 }) --- if #clients == 0 then return "" end --- local names = {} --- for _, client in ipairs(clients) do --- table.insert(names, client.name) --- end --- return "[" .. table.concat(names, ", ") .. "]" --- end - -local M = {} - -function M.lsp_status() - local clients = vim.lsp.get_clients({ bufnr = 0 }) - if #clients == 0 then return "" end - - return "%#StatusLineLsp#[" .. table.concat(vim.tbl_map(function(client) return client.name end, clients), ",") .. "]%* " -end - -return M diff --git a/nvim-pack-lock.json b/nvim-pack-lock.json index 62a5473..20bb1a6 100644 --- a/nvim-pack-lock.json +++ b/nvim-pack-lock.json @@ -1,7 +1,7 @@ { "plugins": { "alacritty.nvim": { - "rev": "4ca80fce586727b33951ae46b2d07c1a0ebf6321", + "rev": "b2db010a1f3cdb9dc10a10666b599ed9a87cd802", "src": "https://github.com/moreka/alacritty.nvim" }, "blink.cmp": { @@ -13,15 +13,19 @@ "src": "https://github.com/stevearc/conform.nvim" }, "fzf-lua": { - "rev": "696f8c071723f845b904af2f99a798650210355e", + "rev": "20e2d3099ba99f37f9a7c7d9ed2a9d83c3b20618", "src": "https://github.com/ibhagwan/fzf-lua" }, + "gitsigns.nvim": { + "rev": "abf82a65f185bd54adc0679f74b7d6e1ada690c9", + "src": "https://github.com/lewis6991/gitsigns.nvim" + }, "mini.nvim": { "rev": "c163117900c17d4abf30bc09452a261c8536060c", "src": "https://github.com/nvim-mini/mini.nvim" }, "nvim-lspconfig": { - "rev": "92ee7d42320edfbb81f3cad851314ab197fa324a", + "rev": "dec357ee48ff7e2e5b76898fd7c67b61a627d3ac", "src": "https://github.com/neovim/nvim-lspconfig" }, "nvim-treesitter": { diff --git a/plugin/10_options.lua b/plugin/10_options.lua index ce3b235..f56dc6c 100644 --- a/plugin/10_options.lua +++ b/plugin/10_options.lua @@ -48,6 +48,4 @@ vim.g.tex_no_error = 1 vim.g.tex_comment_nospell = 1 vim.opt.tags:append({ "tags;~", ".tags;~" }) -vim.o.laststatus = 1 -vim.o.statusline = "%<%f %h%w%m%r %=%{% &showcmdloc == 'statusline' ? '%-10.S ' : '' %}%{% exists('b:keymap_name') ? '<'..b:keymap_name..'> ' : '' %}%{% &busy > 0 ? '◐ ' : '' %}%{% luaeval('(package.loaded[''vim.diagnostic''] and #vim.diagnostic.count() ~= 0 and vim.diagnostic.status() .. '' '') or '''' ') %}%{% v:lua.require'mo.statusline'.lsp_status() %}%{% &ruler ? ( &rulerformat == '' ? '%-14.(%l,%c%V%) %P' : &rulerformat ) : '' %}" - +vim.o.laststatus = 2 diff --git a/plugin/11_keymaps.lua b/plugin/11_keymaps.lua index 9dcd4f4..9758fb3 100644 --- a/plugin/11_keymaps.lua +++ b/plugin/11_keymaps.lua @@ -1,3 +1,6 @@ +-- vim: foldmethod=marker + +-- stylua: ignore start local map = function(mode, lhs, rhs, desc) vim.keymap.set(mode, lhs, rhs, { desc = desc }) end local nmap = function(lhs, rhs, desc) map("n", lhs, rhs, desc) end local mapleader = function(mode, suffix, rhs, desc) map(mode, "<Leader>" .. suffix, rhs, desc) end @@ -21,38 +24,59 @@ vim.keymap.set({ "n", "x" }, "k", [[v:count == 0 ? 'gk' : 'k']], { expr = true, nmap("gK", "K", "use the keywordprg instead of hover") -map('t', '<C-[>', [[<C-\><C-N>]], "go to normal mode from terminal mode") -map('t', '<Esc>', '<Esc>', "map <Esc> to literal ESC in terminal mode") +map("t", "<C-[>", [[<C-\><C-N>]], "go to normal mode from terminal mode") +map("t", "<Esc>", "<Esc>", "map <Esc> to literal ESC in terminal mode") + +-- stylua: ignore end --- lua exec +-- lua exec {{{ nmapleader("x", function() - local line = "lua " .. vim.api.nvim_get_current_line() - vim.api.nvim_command(line) - vim.api.nvim_input("<Down>") + local line = "lua " .. vim.api.nvim_get_current_line() + vim.api.nvim_command(line) + vim.api.nvim_input("<Down>") end, "execute lua line and go to next line") + mapleader("x", "x", ":lua<CR>") nmap("<Leader><Leader>x", "<Cmd>luafile %<CR>") +-- }}} --- lsp and format +-- lsp and format {{{ nmapleader("e", "<Cmd>lua vim.diagnostic.open_float()<CR>") nmap("gd", "<Cmd>lua vim.lsp.buf.definition()<CR>") nmap("<C-f>", "<Cmd>lua require'conform'.format{async=true}<CR>") +-- }}} --- fzf +-- fzf {{{ +-- stylua: ignore start nmap("<C-p>", "<Cmd>FzfLua files<CR>", "fzf: find files") nmap("<C-t>", "<Cmd>FzfLua resume<CR>", "fzf: resume") nmap("<C-\\>", "<Cmd>FzfLua buffers<CR>", "fzf: buffers") nmap("<C-/>", "<Cmd>FzfLua oldfiles<CR>", "fzf: oldfiles") -nmapleader("fg", "<Cmd>FzfLua live_grep_native<CR>", "fzf: grep") -nmapleader("fc", '<Cmd>FzfLua files prompt="Nvim Config>\\ " cwd=~/.config/nvim<CR>', "fzf: search config") -nmapleader("fp", '<Cmd>lua FzfLua.files({cwd=vim.fn.stdpath("data").."/site/pack/core/opt/"})<CR>', "fzf: search plugins") +nmapleader("fg", "<Cmd>FzfLua live_grep<CR>", "fzf: grep") +nmapleader("fc", "<Cmd>FzfLua files cwd=~/.config/nvim<CR>", "fzf: search config") +nmapleader("fp", "<Cmd>FzfLua files cwd=~/.local/share/nvim/site/pack/core/opt<CR>", "fzf: search plugins") nmapleader("fh", "<Cmd>FzfLua helptags<CR>", "fzf: help tags") nmapleader("fk", "<Cmd>FzfLua keymaps<CR>", "fzf: keymaps") +-- stylua: ignore end +-- }}} + +-- fzf misc {{{ map("n", "z=", "<Cmd>FzfLua spell_suggest<CR>", "fzf: suggest spelling") +vim.keymap.set("i", "<C-x><C-f>", function() + vim.cmd([[packadd fzf-lua]]) + require("fzf-lua").complete_file({ + cmd = "rg --files", + winopts = { preview = { hidden = true } }, + }) +end, { silent = true, desc = "fzf: complete file" }) +-- }}} + -- git nmapleader("gs", "<Cmd>Git<CR>", "git status") -- qf +-- stylua: ignore start nmapleader("q", function() require("quicker").toggle() end, "Toggle quickfix list") +-- stylua: ignore end diff --git a/plugin/12_autocommands.lua b/plugin/12_autocommands.lua index 829ed97..73bce84 100644 --- a/plugin/12_autocommands.lua +++ b/plugin/12_autocommands.lua @@ -27,12 +27,6 @@ au("LspAttach", { desc = "add sign column when LSP is attached and redraw status", }) -au("LspDetach", { - group = group, - command = "redrawstatus", - desc = "redraw status when LSP is dettached", -}) - au("FileType", { group = group, pattern = "fugitive,git,help,man,qf,query,scratch", diff --git a/plugin/plugins/gitsigns.lua b/plugin/plugins/gitsigns.lua new file mode 100644 index 0000000..d16d238 --- /dev/null +++ b/plugin/plugins/gitsigns.lua @@ -0,0 +1 @@ +require("gitsigns").setup() diff --git a/plugin/plugins/mini.lua b/plugin/plugins/mini.lua index 24027e0..92f86c6 100644 --- a/plugin/plugins/mini.lua +++ b/plugin/plugins/mini.lua @@ -32,6 +32,98 @@ vim.schedule(function() }) end) +vim.schedule(function() require("mini.icons").setup() end) + +local section_filename = function() + local st = "%{% &busy > 0 ? '◐ ' : '' %}" + -- In terminal always use plain name + if vim.bo.buftype == "terminal" then + return st .. "%t" + elseif _G.MiniStatusline.is_truncated(140) then + -- File name with 'truncate', 'modified', 'readonly' flags + -- Use relative path if truncated + return st .. "%f%m%r" + else + -- Use fullpath if not truncated + return st .. "%F%m%r" + end +end + +local section_git = function() + if _G.MiniStatusline.is_truncated(40) then return "" end + local summary = vim.b.gitsigns_head + if summary == nil then return "" end + return " " .. (summary == "" and "-" or summary) +end + +local section_diff = function() + if _G.MiniStatusline.is_truncated(75) then return "" end + local summary = vim.b.gitsigns_status + if summary == nil then return "" end + return (summary == "" and "-" or summary) +end + +local my_diag_status = function(hl_end) + local diag = vim.diagnostic + local counts = diag.count(0) + local signs = { "E", "W", "I", "H" } + local hl_map = { + [diag.severity.ERROR] = "DiagSLError", + [diag.severity.WARN] = "DiagSLWarn", + [diag.severity.INFO] = "DiagSLInfo", + [diag.severity.HINT] = "DiagSLHint", + } + local result_str = vim.iter(pairs(counts)) + :map( + function(severity, count) + return ("%%#%s#%s:%s"):format( + hl_map[severity], + signs[severity], + count + ) + end + ) + :join(" ") + if result_str:len() > 0 then + result_str = result_str .. "%##%#" .. hl_end .. "#" + end + return result_str +end + +local section_diagnostics = function() + if _G.MiniStatusline.is_truncated(75) then return "" end + if package.loaded["vim.diagnostic"] and #vim.diagnostic.count() ~= 0 then + return my_diag_status("SLDev") + end + return "" +end + vim.schedule(function() - require("mini.icons").setup() + local statusline = require("mini.statusline") + statusline.setup({ + content = { + active = function() + local git = section_git() + local diff = section_diff() + local diagnostics = section_diagnostics() + + local lsp = statusline.section_lsp({ trunc_width = 75 }) + local filename = section_filename() + local fileinfo = vim.bo.filetype + local location = "%-6.(%l,%c%V%) %P" + -- "%{% &ruler ? ( &rulerformat == '' ? '' : &rulerformat ) : '' %}" + + return statusline.combine_groups({ + { hl = "SLFilename", strings = { filename } }, + "%=", -- End left alignment + { hl = "SLDev", strings = { git, diff, diagnostics, lsp } }, + "%<", -- Mark general truncate point + { hl = "SLFileInfo", strings = { fileinfo } }, + { hl = "SLLocation", strings = { location } }, + }) + end, + inactive = nil, + }, + use_icons = true, + }) end) |
