diff options
| author | Hsieh Chin Fan <pham@topo.tw> | 2024-07-31 11:49:46 +0800 |
|---|---|---|
| committer | Hsieh Chin Fan <pham@topo.tw> | 2024-07-31 13:47:57 +0800 |
| commit | e94b17515037564d993209f7917329e8f9a42727 (patch) | |
| tree | d629aa93c0fefc0ab8abee658cc7037492379e76 /vim | |
| parent | 0cf71e0018a5c11dd2cd2183e3f0632ec4ce01df (diff) | |
Update
Diffstat (limited to 'vim')
| -rw-r--r-- | vim/init/basic.vim | 2 | ||||
| -rw-r--r-- | vim/init/keymaps.vim | 35 | ||||
| -rw-r--r-- | vim/mini.lua | 994 |
3 files changed, 533 insertions, 498 deletions
diff --git a/vim/init/basic.vim b/vim/init/basic.vim index 58277b9..17a97da 100644 --- a/vim/init/basic.vim +++ b/vim/init/basic.vim | |||
| @@ -23,7 +23,7 @@ augroup tabinfo | |||
| 23 | autocmd BufDelete * call RemoveBufFromTabs() | 23 | autocmd BufDelete * call RemoveBufFromTabs() |
| 24 | 24 | ||
| 25 | function! AddBufToTab() | 25 | function! AddBufToTab() |
| 26 | if !has_key(t:, 'bufs') | let t:['bufs'] = [] | endif | 26 | if !has_key(t:, 'bufs') | let t:bufs = [] | endif |
| 27 | call add(t:bufs, bufnr()) | call sort(t:bufs) | call uniq(t:bufs) | 27 | call add(t:bufs, bufnr()) | call sort(t:bufs) | call uniq(t:bufs) |
| 28 | endfunc | 28 | endfunc |
| 29 | function! RemoveBufFromTabs() | 29 | function! RemoveBufFromTabs() |
diff --git a/vim/init/keymaps.vim b/vim/init/keymaps.vim index 4df45ad..ce6cf84 100644 --- a/vim/init/keymaps.vim +++ b/vim/init/keymaps.vim | |||
| @@ -196,7 +196,6 @@ function! DeleteMark(mark) | |||
| 196 | endfunc | 196 | endfunc |
| 197 | nnoremap dm :call DeleteMark(getchar())<CR> | 197 | nnoremap dm :call DeleteMark(getchar())<CR> |
| 198 | 198 | ||
| 199 | |||
| 200 | " Usage: z' to fold lines not near marks, use v:count to set offset | 199 | " Usage: z' to fold lines not near marks, use v:count to set offset |
| 201 | " For example: 15z' | 200 | " For example: 15z' |
| 202 | autocmd BufEnter * let b:fold_for_marks = 0 | 201 | autocmd BufEnter * let b:fold_for_marks = 0 |
| @@ -205,8 +204,8 @@ function! ToggleFoldForMarks(offset) | |||
| 205 | if !b:fold_for_marks || a:offset | 204 | if !b:fold_for_marks || a:offset |
| 206 | " If toggling from other foldmethod, save view! | 205 | " If toggling from other foldmethod, save view! |
| 207 | if !b:fold_for_marks | 206 | if !b:fold_for_marks |
| 208 | mkview | 207 | mkview |
| 209 | setlocal foldmethod=manual | 208 | setlocal foldmethod=manual |
| 210 | endif | 209 | endif |
| 211 | 210 | ||
| 212 | " Then clear all folds | 211 | " Then clear all folds |
| @@ -242,6 +241,7 @@ function! ToggleFoldForMarks(offset) | |||
| 242 | let b:fold_for_marks = 1 | 241 | let b:fold_for_marks = 1 |
| 243 | echo "Folds for Marks" | 242 | echo "Folds for Marks" |
| 244 | else | 243 | else |
| 244 | " Reset everything | ||
| 245 | loadview | 245 | loadview |
| 246 | let b:fold_for_marks = 0 | 246 | let b:fold_for_marks = 0 |
| 247 | echo "Reset Folds" | 247 | echo "Reset Folds" |
| @@ -249,6 +249,35 @@ function! ToggleFoldForMarks(offset) | |||
| 249 | endfunction | 249 | endfunction |
| 250 | nnoremap <expr> z' ":\<C-u>call ToggleFoldForMarks("..v:count..")\<CR>" | 250 | nnoremap <expr> z' ":\<C-u>call ToggleFoldForMarks("..v:count..")\<CR>" |
| 251 | 251 | ||
| 252 | function! ChangeUnfold(downward, count) | ||
| 253 | " Only do this if foldmethod is manual or count is given | ||
| 254 | if &foldmethod != 'manual' || !a:count | return | endif | ||
| 255 | |||
| 256 | " Move to fold upward/downward | ||
| 257 | if downward | ||
| 258 | norm! zj | ||
| 259 | else | ||
| 260 | norm! zk | ||
| 261 | endif | ||
| 262 | let foldstart = foldclosed('.') | ||
| 263 | let foldend = foldclosedend('.') | ||
| 264 | |||
| 265 | " Change folding area | ||
| 266 | norm! zd | ||
| 267 | let move = (a:count ? a:count : 1) | ||
| 268 | if downward | ||
| 269 | let foldstart += move | ||
| 270 | else | ||
| 271 | let foldend -= move | ||
| 272 | endif | ||
| 273 | exe foldstart..","..foldend.."fold" | ||
| 274 | |||
| 275 | " Get back to origin cursor position | ||
| 276 | norm! '' | ||
| 277 | endfunc | ||
| 278 | nnoremap <expr> z> ":\<C-u>call ChangeUnfold(1,"..v:count..")\<CR>" | ||
| 279 | nnoremap <expr> z< ":\<C-u>call ChangeUnfold(0,"..v:count..")\<CR>" | ||
| 280 | |||
| 252 | "}}} | 281 | "}}} |
| 253 | " EDIT {{{ | 282 | " EDIT {{{ |
| 254 | 283 | ||
diff --git a/vim/mini.lua b/vim/mini.lua index 01e0cf1..750c94e 100644 --- a/vim/mini.lua +++ b/vim/mini.lua | |||
| @@ -3,6 +3,343 @@ | |||
| 3 | -- Ref: https://github.com/echasnovski/mini.nvim | 3 | -- Ref: https://github.com/echasnovski/mini.nvim |
| 4 | -- https://lazy.folke.io/spec | 4 | -- https://lazy.folke.io/spec |
| 5 | 5 | ||
| 6 | -- Install mini.nvim {{{ | ||
| 7 | -- Put this at the top of 'init.lua' | ||
| 8 | local path_package = vim.fn.stdpath("data") .. "/site" | ||
| 9 | local mini_path = path_package .. "/pack/deps/start/mini.nvim" | ||
| 10 | vim.o.packpath = path_package | ||
| 11 | |||
| 12 | if not vim.loop.fs_stat(mini_path) then | ||
| 13 | vim.cmd('echo "Installing `mini.nvim`" | redraw') | ||
| 14 | local clone_cmd = { | ||
| 15 | "git", | ||
| 16 | "clone", | ||
| 17 | "--filter=blob:none", | ||
| 18 | -- Uncomment next line to use 'stable' branch | ||
| 19 | -- '--branch', 'stable', | ||
| 20 | "https://github.com/echasnovski/mini.nvim", | ||
| 21 | mini_path, | ||
| 22 | } | ||
| 23 | vim.fn.system(clone_cmd) | ||
| 24 | vim.cmd("packadd mini.nvim | helptags ALL") | ||
| 25 | end | ||
| 26 | |||
| 27 | -- }}} | ||
| 28 | -- mini.deps {{{ | ||
| 29 | require("mini.deps").setup({ | ||
| 30 | path = { package = path_package }, | ||
| 31 | }) | ||
| 32 | Add, Now, Later = MiniDeps.add, MiniDeps.now, MiniDeps.later | ||
| 33 | -- }}} | ||
| 34 | -- -- mini.basics {{{ | ||
| 35 | -- require("mini.basics").setup() | ||
| 36 | -- -- }}} | ||
| 37 | -- mini.misc {{{ | ||
| 38 | require("mini.misc").setup({ | ||
| 39 | make_global = { "put", "put_text", "zoom" }, | ||
| 40 | }) | ||
| 41 | vim.keymap.set( 'n', '<leader>Z', function() | ||
| 42 | zoom() | ||
| 43 | vim.cmd("silent! call ToggleWinPadding()") | ||
| 44 | end, { buffer = bufnr, desc = 'zoom' }) | ||
| 45 | --}}} | ||
| 46 | -- mini.extra {{{ | ||
| 47 | require("mini.extra").setup() | ||
| 48 | -- }}} | ||
| 49 | -- mini.colors {{{ | ||
| 50 | require("mini.colors").setup() | ||
| 51 | vim.keymap.set("n", "<leader><leader>co", function() | ||
| 52 | require("mini.colors").interactive() | ||
| 53 | end) | ||
| 54 | -- }}} | ||
| 55 | -- mini.base16 {{{ | ||
| 56 | require("mini.base16").setup({ | ||
| 57 | palette = { | ||
| 58 | -- Default Background | ||
| 59 | base00 = "#2d2a2e", | ||
| 60 | -- Lighter Background (Used for status bars, line number and folding marks) | ||
| 61 | base01 = "#37343a", | ||
| 62 | -- Selection Background | ||
| 63 | base02 = "#423f46", | ||
| 64 | -- Comments, Invisible, Line Highlighting | ||
| 65 | base03 = "#848089", | ||
| 66 | -- Dark Foreground (Used for status bars) | ||
| 67 | base04 = "#66d9ef", | ||
| 68 | -- Default Foreground, Caret, Delimiters, Operators | ||
| 69 | base05 = "#e3e1e4", | ||
| 70 | -- Light Foreground (Not often used) | ||
| 71 | base06 = "#a1efe4", | ||
| 72 | -- Light Background (Not often used) | ||
| 73 | base07 = "#f8f8f2", | ||
| 74 | -- Variables, XML Tags, Markup Link Text, Markup Lists, Diff Deleted | ||
| 75 | base08 = "#f85e84", | ||
| 76 | -- Integers, Boolean, Constants, XML Attributes, Markup Link Url | ||
| 77 | base09 = "#ef9062", | ||
| 78 | -- Classes, Markup Bold, Search Text Background | ||
| 79 | base0A = "#a6e22e", | ||
| 80 | -- Strings, Inherited Class, Markup Code, Diff Inserted | ||
| 81 | base0B = "#e5c463", | ||
| 82 | -- Support, Regular Expressions, Escape Characters, Markup Quotes | ||
| 83 | base0C = "#66d9ef", | ||
| 84 | -- Functions, Methods, Attribute IDs, Headings | ||
| 85 | base0D = "#9ecd6f", | ||
| 86 | -- Keywords, Storage, Selector, Markup Italic, Diff Changed | ||
| 87 | base0E = "#a1efe4", | ||
| 88 | -- Deprecated, Opening/Closing Embedded Language Tags, e.g. <?php ?> | ||
| 89 | base0F = "#f9f8f5", | ||
| 90 | }, | ||
| 91 | use_cterm = false, | ||
| 92 | }) | ||
| 93 | -- | ||
| 94 | -- Override settings for search | ||
| 95 | vim.cmd("hi Search guibg=#e5c07b") | ||
| 96 | -- | ||
| 97 | -- Resume terminal color | ||
| 98 | for i = 1, 15, 1 do | ||
| 99 | vim.cmd("let terminal_color_" .. i .. " = ''") | ||
| 100 | end | ||
| 101 | -- | ||
| 102 | -- Override settings for bufferline | ||
| 103 | vim.cmd("hi BufferLineTabSelected guibg=#f85e84") | ||
| 104 | vim.cmd("hi BufferLineTab guibg=Gray") | ||
| 105 | -- | ||
| 106 | --}}} | ||
| 107 | -- mini.icons {{{ | ||
| 108 | require("mini.icons").setup({}) | ||
| 109 | --}}} | ||
| 110 | -- mini.comment {{{ | ||
| 111 | require("mini.comment").setup({ | ||
| 112 | -- Module mappings. Use `''` (empty string) to disable one. | ||
| 113 | mappings = { | ||
| 114 | -- Toggle comment (like `gcip` - comment inner paragraph) for both | ||
| 115 | -- Normal and Visual modes | ||
| 116 | comment = "gc", | ||
| 117 | -- | ||
| 118 | -- Toggle comment on current line | ||
| 119 | comment_line = "<C-/>", | ||
| 120 | -- | ||
| 121 | -- Toggle comment on visual selection | ||
| 122 | comment_visual = "<C-/>", | ||
| 123 | -- | ||
| 124 | -- Define 'comment' textobject (like `dgc` - delete whole comment block) | ||
| 125 | -- Works also in Visual mode if mapping differs from `comment_visual` | ||
| 126 | textobject = "gc", | ||
| 127 | }, | ||
| 128 | }) -- }}} | ||
| 129 | -- mini.cursorword {{{ | ||
| 130 | require("mini.cursorword").setup() | ||
| 131 | -- }}} | ||
| 132 | -- mini.diff {{{ | ||
| 133 | require("mini.diff").setup({ | ||
| 134 | -- Options for how hunks are visualized | ||
| 135 | view = { | ||
| 136 | -- Visualization style. Possible values are 'sign' and 'number'. | ||
| 137 | -- Default: 'number' if line numbers are enabled, 'sign' otherwise. | ||
| 138 | style = "sign", | ||
| 139 | -- | ||
| 140 | -- Signs used for hunks with 'sign' view | ||
| 141 | signs = { add = "+", change = "▒", delete = "-" }, | ||
| 142 | -- | ||
| 143 | -- Priority of used visualization extmarks | ||
| 144 | priority = 199, | ||
| 145 | }, | ||
| 146 | }) | ||
| 147 | -- | ||
| 148 | vim.keymap.set("n", "\\gh", function() | ||
| 149 | MiniDiff.toggle_overlay() | ||
| 150 | end, { buffer = bufnr, desc = "Toggle diff" }) | ||
| 151 | -- | ||
| 152 | -- }}} | ||
| 153 | -- mini.map {{{ | ||
| 154 | require("mini.map").setup() | ||
| 155 | vim.keymap.set("n", "\\m", function() | ||
| 156 | require("mini.map").toggle() | ||
| 157 | end, { desc = "Minimap", buffer = bufnr }) | ||
| 158 | -- }}} | ||
| 159 | -- mini.visits {{{ | ||
| 160 | |||
| 161 | require("mini.visits").setup() | ||
| 162 | -- vim.keymap.set("n", "<leader><leader>li", function() | ||
| 163 | -- MiniVisits.list_paths() | ||
| 164 | -- end, { buffer = bufnr, desc = "" }) | ||
| 165 | -- | ||
| 166 | -- }}} | ||
| 167 | -- mini.ai {{{ | ||
| 168 | require("mini.ai").setup {} | ||
| 169 | -- }}} | ||
| 170 | -- mini.surround {{{ | ||
| 171 | require("mini.surround").setup { | ||
| 172 | mappings = { | ||
| 173 | add = 's' | ||
| 174 | } | ||
| 175 | } | ||
| 176 | -- }}} | ||
| 177 | -- mini.indentscope {{{ | ||
| 178 | require("mini.indentscope").setup() | ||
| 179 | -- }}} | ||
| 180 | -- mini.splitjoin {{{ | ||
| 181 | require("mini.splitjoin").setup() | ||
| 182 | -- }}} | ||
| 183 | -- mini.move {{{ | ||
| 184 | require("mini.move").setup() | ||
| 185 | -- }}} | ||
| 186 | -- mini.hipatterns {{{ | ||
| 187 | -- | ||
| 188 | local hipatterns = require("mini.hipatterns") | ||
| 189 | hipatterns.setup({ | ||
| 190 | highlighters = { | ||
| 191 | -- Highlight standalone 'FIXME', 'HACK', 'TODO', 'NOTE' | ||
| 192 | fixme = { pattern = "%f[%w]()FIXME()%f[%W]", group = "MiniHipatternsFixme" }, | ||
| 193 | hack = { pattern = "%f[%w]()HACK()%f[%W]", group = "MiniHipatternsHack" }, | ||
| 194 | todo = { pattern = "%f[%w]()TODO()%f[%W]", group = "MiniHipatternsTodo" }, | ||
| 195 | note = { pattern = "%f[%w]()NOTE()%f[%W]", group = "MiniHipatternsNote" }, | ||
| 196 | -- | ||
| 197 | -- Highlight hex color strings (`#rrggbb`) using that color | ||
| 198 | hex_color = hipatterns.gen_highlighter.hex_color(), | ||
| 199 | }, | ||
| 200 | }) | ||
| 201 | vim.keymap.set("n", "<leader><leader>hi", function() | ||
| 202 | MiniHipatterns.toggle() | ||
| 203 | end, { buffer = bufnr, desc = "Toggle hex color highlight" }) | ||
| 204 | -- | ||
| 205 | -- }}} | ||
| 206 | -- mini.pairs {{{ | ||
| 207 | require("mini.pairs").setup() | ||
| 208 | -- }}} | ||
| 209 | -- -- mini.statusline {{{ | ||
| 210 | -- -- | ||
| 211 | -- require("mini.statusline").setup({ | ||
| 212 | -- content = { | ||
| 213 | -- active = status_config, | ||
| 214 | -- }, | ||
| 215 | -- }) | ||
| 216 | -- local function diagnostics_table(args) | ||
| 217 | -- local info = vim.b.coc_diagnostic_info | ||
| 218 | -- if MiniStatusline.is_truncated(args.trunc_width) or info == nil then | ||
| 219 | -- return {} | ||
| 220 | -- end | ||
| 221 | -- local table = {} | ||
| 222 | -- table.e = (info["error"] or 0) > 0 and "E" .. info["error"] or "" | ||
| 223 | -- table.w = (info["warning"] or 0) > 0 and "W" .. info["warning"] or "" | ||
| 224 | -- table.h = (info["hint"] or 0) > 0 and "H" .. info["hint"] or "" | ||
| 225 | -- table.i = (info["information"] or 0) > 0 and "I" .. info["information"] or "" | ||
| 226 | -- table.s = vim.g.coc_status | ||
| 227 | -- return table | ||
| 228 | -- end | ||
| 229 | -- | ||
| 230 | -- function status_config() | ||
| 231 | -- local mode, mode_hl = MiniStatusline.section_mode({ trunc_width = 120 }) | ||
| 232 | -- local git = MiniStatusline.section_git({ trunc_width = 75 }) | ||
| 233 | -- local diagnostics = diagnostics_table({ trunc_width = 75 }) | ||
| 234 | -- local filename = MiniStatusline.section_filename({ trunc_width = 140 }) | ||
| 235 | -- local fileinfo = MiniStatusline.section_fileinfo({ trunc_width = 120 }) | ||
| 236 | -- local location = MiniStatusline.section_location({ trunc_width = 75 }) | ||
| 237 | -- | ||
| 238 | -- return MiniStatusline.combine_groups({ | ||
| 239 | -- { hl = mode_hl, strings = { mode } }, | ||
| 240 | -- { hl = "MiniStatuslineDevinfo", strings = { git, diagnostics["s"] } }, | ||
| 241 | -- { hl = "MiniStatuslineError", strings = { diagnostics["e"] } }, | ||
| 242 | -- { hl = "MiniStatuslineWarning", strings = { diagnostics["w"] } }, | ||
| 243 | -- { hl = "MiniStatuslineInfo", strings = { diagnostics["i"] } }, | ||
| 244 | -- { hl = "MiniStatuslineHint", strings = { diagnostics["h"] } }, | ||
| 245 | -- "%<", -- Mark general truncate point | ||
| 246 | -- { hl = "MiniStatuslineFilename", strings = { filename } }, | ||
| 247 | -- "%=", -- End left alignment | ||
| 248 | -- { hl = "MiniStatuslineFileinfo", strings = { fileinfo } }, | ||
| 249 | -- { hl = mode_hl, strings = { location } }, | ||
| 250 | -- }) | ||
| 251 | -- end | ||
| 252 | -- | ||
| 253 | -- -- }}} | ||
| 254 | -- -- mini.completion {{{ | ||
| 255 | -- require('mini.completion').setup() | ||
| 256 | -- -- }}} | ||
| 257 | -- -- mini.tabline {{{ | ||
| 258 | -- | ||
| 259 | -- require('mini.tabline').setup { | ||
| 260 | -- format = function(buf_id, label) | ||
| 261 | -- local suffix = vim.bo[buf_id].modified and '+ ' or '' | ||
| 262 | -- return MiniTabline.default_format(buf_id, label) .. suffix | ||
| 263 | -- end, | ||
| 264 | -- tabpage_section = 'right' | ||
| 265 | -- } | ||
| 266 | -- | ||
| 267 | -- for i = 1, 9, 1 do | ||
| 268 | -- vim.keymap.set("n", string.format("<A-%s>", i), function() | ||
| 269 | -- vim.api.nvim_set_current_buf(vim.fn.getbufinfo({ buflisted=true })[i].bufnr) | ||
| 270 | -- end, {silent = true}) | ||
| 271 | -- end | ||
| 272 | -- | ||
| 273 | -- -- }}} | ||
| 274 | -- -- mini.clue {{{ | ||
| 275 | -- local miniclue = require('mini.clue') | ||
| 276 | -- miniclue.setup({ | ||
| 277 | -- triggers = { | ||
| 278 | -- -- Leader triggers | ||
| 279 | -- { mode = 'n', keys = '<Leader>' }, | ||
| 280 | -- { mode = 'x', keys = '<Leader>' }, | ||
| 281 | -- | ||
| 282 | -- -- Built-in completion | ||
| 283 | -- { mode = 'i', keys = '<C-x>' }, | ||
| 284 | -- | ||
| 285 | -- -- `g` key | ||
| 286 | -- { mode = 'n', keys = 'g' }, | ||
| 287 | -- { mode = 'x', keys = 'g' }, | ||
| 288 | -- | ||
| 289 | -- -- Marks | ||
| 290 | -- { mode = 'n', keys = "'" }, | ||
| 291 | -- { mode = 'n', keys = '`' }, | ||
| 292 | -- { mode = 'x', keys = "'" }, | ||
| 293 | -- { mode = 'x', keys = '`' }, | ||
| 294 | -- | ||
| 295 | -- -- Registers | ||
| 296 | -- { mode = 'n', keys = '"' }, | ||
| 297 | -- { mode = 'x', keys = '"' }, | ||
| 298 | -- { mode = 'i', keys = '<C-r>' }, | ||
| 299 | -- { mode = 'c', keys = '<C-r>' }, | ||
| 300 | -- | ||
| 301 | -- -- Window commands | ||
| 302 | -- { mode = 'n', keys = '<C-w>' }, | ||
| 303 | -- | ||
| 304 | -- -- `z` key | ||
| 305 | -- { mode = 'n', keys = 'z' }, | ||
| 306 | -- { mode = 'x', keys = 'z' }, | ||
| 307 | -- }, | ||
| 308 | -- | ||
| 309 | -- clues = { | ||
| 310 | -- -- Enhance this by adding descriptions for <Leader> mapping groups | ||
| 311 | -- miniclue.gen_clues.builtin_completion(), | ||
| 312 | -- miniclue.gen_clues.g(), | ||
| 313 | -- miniclue.gen_clues.marks(), | ||
| 314 | -- miniclue.gen_clues.registers(), | ||
| 315 | -- miniclue.gen_clues.windows(), | ||
| 316 | -- miniclue.gen_clues.z(), | ||
| 317 | -- }, | ||
| 318 | -- -- }}} | ||
| 319 | -- -- mini.bufremote {{{ | ||
| 320 | -- require('mini.bufremove') | ||
| 321 | --}}} | ||
| 322 | -- -- mini.animate --{{{ | ||
| 323 | -- require("mini.animate").setup() | ||
| 324 | -- -- }}} | ||
| 325 | -- -- suda {{{ | ||
| 326 | -- add { source = "lambdalisue/suda.vim" } | ||
| 327 | -- }}} | ||
| 328 | -- -- true-zen {{{ | ||
| 329 | -- Add({ | ||
| 330 | -- source = "Pocco81/true-zen.nvim", | ||
| 331 | -- }) | ||
| 332 | -- vim.keymap.set("n", "<leader>z", ":TZAtaraxis<CR>") | ||
| 333 | -- -- }}} | ||
| 334 | -- marks.nvim {{{ | ||
| 335 | Add { | ||
| 336 | source = "chentoast/marks.nvim" | ||
| 337 | } | ||
| 338 | require('marks').setup { | ||
| 339 | } | ||
| 340 | vim.cmd("hi MarkSignHL guifg=#f85e84 guibg=#37343a") | ||
| 341 | -- }}} | ||
| 342 | |||
| 6 | -- Install Lazy {{{ | 343 | -- Install Lazy {{{ |
| 7 | -- Bootstrap lazy.nvim | 344 | -- Bootstrap lazy.nvim |
| 8 | local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" | 345 | local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" |
| @@ -10,10 +347,172 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then | |||
| 10 | local lazyrepo = "https://github.com/folke/lazy.nvim.git" | 347 | local lazyrepo = "https://github.com/folke/lazy.nvim.git" |
| 11 | vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) | 348 | vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) |
| 12 | end | 349 | end |
| 13 | vim.opt.rtp:prepend(lazypath) | 350 | vim.cmd("set rtp+="..lazypath) |
| 14 | -- }}} | 351 | -- }}} |
| 15 | require("lazy").setup({ | 352 | require("lazy").setup({ |
| 16 | -- "tpope/vim-sleuth", | 353 | -- "tpope/vim-sleuth", |
| 354 | -- bufferline {{{ | ||
| 355 | { | ||
| 356 | "akinsho/bufferline.nvim", | ||
| 357 | lazy = false, | ||
| 358 | dependencies = { | ||
| 359 | "nvim-tree/nvim-web-devicons", | ||
| 360 | "tiagovla/scope.nvim", | ||
| 361 | }, | ||
| 362 | config = function() | ||
| 363 | require('bufferline').setup{ | ||
| 364 | options = { | ||
| 365 | numbers = 'ordinal', | ||
| 366 | tab_size = 14, | ||
| 367 | separator_style = { "", "" }, | ||
| 368 | themable = true, | ||
| 369 | buffer_close_icon = "", | ||
| 370 | close_icon = "", | ||
| 371 | groups = { | ||
| 372 | items = { | ||
| 373 | require("bufferline.groups").builtin.pinned:with({ icon = "" }), | ||
| 374 | }, | ||
| 375 | }, | ||
| 376 | enforce_regular_tabs = false, | ||
| 377 | diagnostics = "coc", | ||
| 378 | diagnostics_update_in_insert = true, | ||
| 379 | diagnostics_indicator = function(count, level) | ||
| 380 | local icon = level:match("error") and " " or " " | ||
| 381 | return " " .. icon .. count | ||
| 382 | end, | ||
| 383 | offsets = { | ||
| 384 | { | ||
| 385 | filetype = "NvimTree", | ||
| 386 | text = "File Explorer", | ||
| 387 | highlight = "Directory", | ||
| 388 | text_align = "left" | ||
| 389 | }, | ||
| 390 | { | ||
| 391 | filetype = "coc-explorer", | ||
| 392 | text = function() | ||
| 393 | return vim.fn.getcwd() | ||
| 394 | end, | ||
| 395 | highlight = "Directory", | ||
| 396 | text_align = "left" | ||
| 397 | }, | ||
| 398 | { | ||
| 399 | filetype = 'vista', | ||
| 400 | text = function() | ||
| 401 | return vim.fn.getcwd() | ||
| 402 | end, | ||
| 403 | highlight = "Tags", | ||
| 404 | text_align = "right" | ||
| 405 | } | ||
| 406 | }, | ||
| 407 | custom_filter = function (buf_number) | ||
| 408 | for _, p in ipairs(vim.t.bufs) do | ||
| 409 | if p == buf_number then | ||
| 410 | return true | ||
| 411 | end | ||
| 412 | end | ||
| 413 | return false | ||
| 414 | end | ||
| 415 | } | ||
| 416 | } | ||
| 417 | -- keymaps {{{ | ||
| 418 | for i = 1, 9, 1 do | ||
| 419 | vim.keymap.set("n", string.format("<A-%s>", i), function() | ||
| 420 | vim.cmd("BufferLineGoToBuffer " .. i) | ||
| 421 | end, { silent = true }) | ||
| 422 | end | ||
| 423 | local opts = { noremap = true, silent = true } | ||
| 424 | vim.keymap.set("n", "<TAB>", "<Cmd>BufferLineCyclePrev<CR>", opts) | ||
| 425 | vim.keymap.set("n", "<S-TAB>", "<Cmd>BufferLineCycleNext<CR>", opts) | ||
| 426 | vim.keymap.set("n", "<M-h>", "<Cmd>BufferLineMovePrev<CR>", opts) | ||
| 427 | vim.keymap.set("n", "<M-l>", "<Cmd>BufferLineMoveNext<CR>", opts) | ||
| 428 | vim.keymap.set("n", "<M-p>", "<Cmd>BufferLineTogglePin<CR>", opts) | ||
| 429 | -- }}} | ||
| 430 | end | ||
| 431 | }, | ||
| 432 | -- }}} | ||
| 433 | -- lualine {{{ | ||
| 434 | { | ||
| 435 | "nvim-lualine/lualine.nvim", | ||
| 436 | event = "VeryLazy", | ||
| 437 | init = function() | ||
| 438 | vim.g.lualine_laststatus = vim.o.laststatus | ||
| 439 | if vim.fn.argc(-1) > 0 then | ||
| 440 | -- set an empty statusline till lualine loads | ||
| 441 | vim.o.statusline = " " | ||
| 442 | else | ||
| 443 | -- hide the statusline on the starter page | ||
| 444 | vim.o.laststatus = 0 | ||
| 445 | end | ||
| 446 | end, | ||
| 447 | opts = function() | ||
| 448 | -- PERF: we don't need this lualine require madness 🤷 | ||
| 449 | local lualine_require = require("lualine_require") | ||
| 450 | lualine_require.require = require | ||
| 451 | |||
| 452 | vim.o.laststatus = vim.g.lualine_laststatus | ||
| 453 | |||
| 454 | local opts = { | ||
| 455 | options = { | ||
| 456 | theme = "auto", | ||
| 457 | globalstatus = vim.o.laststatus == 3, | ||
| 458 | disabled_filetypes = { statusline = { "dashboard", "alpha", "ministarter" } }, | ||
| 459 | }, | ||
| 460 | sections = { | ||
| 461 | lualine_a = { "mode" }, | ||
| 462 | lualine_b = { "branch" }, | ||
| 463 | |||
| 464 | lualine_x = { | ||
| 465 | -- stylua: ignore | ||
| 466 | { | ||
| 467 | function() return require("noice").api.status.command.get() end, | ||
| 468 | cond = function() return package.loaded["noice"] and require("noice").api.status.command.has() end, | ||
| 469 | }, | ||
| 470 | -- stylua: ignore | ||
| 471 | { | ||
| 472 | function() return require("noice").api.status.mode.get() end, | ||
| 473 | cond = function() return package.loaded["noice"] and require("noice").api.status.mode.has() end, | ||
| 474 | }, | ||
| 475 | -- stylua: ignore | ||
| 476 | { | ||
| 477 | function() return " " .. require("dap").status() end, | ||
| 478 | cond = function() return package.loaded["dap"] and require("dap").status() ~= "" end, | ||
| 479 | }, | ||
| 480 | -- stylua: ignore | ||
| 481 | { | ||
| 482 | require("lazy.status").updates, | ||
| 483 | cond = require("lazy.status").has_updates, | ||
| 484 | }, | ||
| 485 | { | ||
| 486 | "diff", | ||
| 487 | source = function() | ||
| 488 | local gitsigns = vim.b.gitsigns_status_dict | ||
| 489 | if gitsigns then | ||
| 490 | return { | ||
| 491 | added = gitsigns.added, | ||
| 492 | modified = gitsigns.changed, | ||
| 493 | removed = gitsigns.removed, | ||
| 494 | } | ||
| 495 | end | ||
| 496 | end, | ||
| 497 | }, | ||
| 498 | }, | ||
| 499 | lualine_y = { | ||
| 500 | { "progress", separator = " ", padding = { left = 1, right = 0 } }, | ||
| 501 | { "location", padding = { left = 0, right = 1 } }, | ||
| 502 | }, | ||
| 503 | lualine_z = { | ||
| 504 | function() | ||
| 505 | return " " .. os.date("%R") | ||
| 506 | end, | ||
| 507 | }, | ||
| 508 | }, | ||
| 509 | extensions = { "neo-tree", "lazy" }, | ||
| 510 | } | ||
| 511 | |||
| 512 | return opts | ||
| 513 | end, | ||
| 514 | }, | ||
| 515 | -- }}} | ||
| 17 | -- Telescope {{{ | 516 | -- Telescope {{{ |
| 18 | { | 517 | { |
| 19 | "nvim-telescope/telescope.nvim", | 518 | "nvim-telescope/telescope.nvim", |
| @@ -442,89 +941,6 @@ require("lazy").setup({ | |||
| 442 | end, | 941 | end, |
| 443 | }, | 942 | }, |
| 444 | -- }}} | 943 | -- }}} |
| 445 | -- lualine {{{ | ||
| 446 | { | ||
| 447 | "nvim-lualine/lualine.nvim", | ||
| 448 | event = "VeryLazy", | ||
| 449 | init = function() | ||
| 450 | vim.g.lualine_laststatus = vim.o.laststatus | ||
| 451 | if vim.fn.argc(-1) > 0 then | ||
| 452 | -- set an empty statusline till lualine loads | ||
| 453 | vim.o.statusline = " " | ||
| 454 | else | ||
| 455 | -- hide the statusline on the starter page | ||
| 456 | vim.o.laststatus = 0 | ||
| 457 | end | ||
| 458 | end, | ||
| 459 | opts = function() | ||
| 460 | -- PERF: we don't need this lualine require madness 🤷 | ||
| 461 | local lualine_require = require("lualine_require") | ||
| 462 | lualine_require.require = require | ||
| 463 | |||
| 464 | vim.o.laststatus = vim.g.lualine_laststatus | ||
| 465 | |||
| 466 | local opts = { | ||
| 467 | options = { | ||
| 468 | theme = "auto", | ||
| 469 | globalstatus = vim.o.laststatus == 3, | ||
| 470 | disabled_filetypes = { statusline = { "dashboard", "alpha", "ministarter" } }, | ||
| 471 | }, | ||
| 472 | sections = { | ||
| 473 | lualine_a = { "mode" }, | ||
| 474 | lualine_b = { "branch" }, | ||
| 475 | |||
| 476 | lualine_x = { | ||
| 477 | -- stylua: ignore | ||
| 478 | { | ||
| 479 | function() return require("noice").api.status.command.get() end, | ||
| 480 | cond = function() return package.loaded["noice"] and require("noice").api.status.command.has() end, | ||
| 481 | }, | ||
| 482 | -- stylua: ignore | ||
| 483 | { | ||
| 484 | function() return require("noice").api.status.mode.get() end, | ||
| 485 | cond = function() return package.loaded["noice"] and require("noice").api.status.mode.has() end, | ||
| 486 | }, | ||
| 487 | -- stylua: ignore | ||
| 488 | { | ||
| 489 | function() return " " .. require("dap").status() end, | ||
| 490 | cond = function() return package.loaded["dap"] and require("dap").status() ~= "" end, | ||
| 491 | }, | ||
| 492 | -- stylua: ignore | ||
| 493 | { | ||
| 494 | require("lazy.status").updates, | ||
| 495 | cond = require("lazy.status").has_updates, | ||
| 496 | }, | ||
| 497 | { | ||
| 498 | "diff", | ||
| 499 | source = function() | ||
| 500 | local gitsigns = vim.b.gitsigns_status_dict | ||
| 501 | if gitsigns then | ||
| 502 | return { | ||
| 503 | added = gitsigns.added, | ||
| 504 | modified = gitsigns.changed, | ||
| 505 | removed = gitsigns.removed, | ||
| 506 | } | ||
| 507 | end | ||
| 508 | end, | ||
| 509 | }, | ||
| 510 | }, | ||
| 511 | lualine_y = { | ||
| 512 | { "progress", separator = " ", padding = { left = 1, right = 0 } }, | ||
| 513 | { "location", padding = { left = 0, right = 1 } }, | ||
| 514 | }, | ||
| 515 | lualine_z = { | ||
| 516 | function() | ||
| 517 | return " " .. os.date("%R") | ||
| 518 | end, | ||
| 519 | }, | ||
| 520 | }, | ||
| 521 | extensions = { "neo-tree", "lazy" }, | ||
| 522 | } | ||
| 523 | |||
| 524 | return opts | ||
| 525 | end, | ||
| 526 | }, | ||
| 527 | -- }}} | ||
| 528 | 944 | ||
| 529 | -- -- lspconfig {{{ | 945 | -- -- lspconfig {{{ |
| 530 | -- -- Use :help lspconfig-all to check servers | 946 | -- -- Use :help lspconfig-all to check servers |
| @@ -748,416 +1164,6 @@ require("lazy").setup({ | |||
| 748 | -- -- }}} | 1164 | -- -- }}} |
| 749 | }) | 1165 | }) |
| 750 | 1166 | ||
| 751 | -- Install mini.nvim {{{ | ||
| 752 | -- Put this at the top of 'init.lua' | ||
| 753 | local path_package = vim.fn.stdpath("data") .. "/site" | ||
| 754 | vim.o.packpath = path_package | ||
| 755 | local mini_path = path_package .. "/pack/deps/start/mini.nvim" | ||
| 756 | -- | ||
| 757 | if not vim.loop.fs_stat(mini_path) then | ||
| 758 | vim.cmd('echo "Installing `mini.nvim`" | redraw') | ||
| 759 | local clone_cmd = { | ||
| 760 | "git", | ||
| 761 | "clone", | ||
| 762 | "--filter=blob:none", | ||
| 763 | -- Uncomment next line to use 'stable' branch | ||
| 764 | -- '--branch', 'stable', | ||
| 765 | "https://github.com/echasnovski/mini.nvim", | ||
| 766 | mini_path, | ||
| 767 | } | ||
| 768 | vim.fn.system(clone_cmd) | ||
| 769 | vim.cmd("packadd mini.nvim | helptags ALL") | ||
| 770 | end | ||
| 771 | -- | ||
| 772 | -- }}} | ||
| 773 | -- mini.deps {{{ | ||
| 774 | require("mini.deps").setup({ | ||
| 775 | path = { package = path_package }, | ||
| 776 | }) | ||
| 777 | Add, Now, Later = MiniDeps.add, MiniDeps.now, MiniDeps.later | ||
| 778 | -- }}} | ||
| 779 | -- -- mini.basics {{{ | ||
| 780 | -- require("mini.basics").setup() | ||
| 781 | -- -- }}} | ||
| 782 | -- mini.misc {{{ | ||
| 783 | require("mini.misc").setup({ | ||
| 784 | make_global = { "put", "put_text", "zoom" }, | ||
| 785 | }) | ||
| 786 | vim.keymap.set( 'n', '<leader>Z', function() | ||
| 787 | zoom() | ||
| 788 | vim.cmd("silent! call ToggleWinPadding()") | ||
| 789 | end, { buffer = bufnr, desc = 'zoom' }) | ||
| 790 | --}}} | ||
| 791 | -- mini.extra {{{ | ||
| 792 | require("mini.extra").setup() | ||
| 793 | -- }}} | ||
| 794 | -- mini.colors {{{ | ||
| 795 | require("mini.colors").setup() | ||
| 796 | vim.keymap.set("n", "<leader><leader>co", function() | ||
| 797 | require("mini.colors").interactive() | ||
| 798 | end) | ||
| 799 | -- }}} | ||
| 800 | -- mini.base16 {{{ | ||
| 801 | require("mini.base16").setup({ | ||
| 802 | palette = { | ||
| 803 | -- Default Background | ||
| 804 | base00 = "#2d2a2e", | ||
| 805 | -- Lighter Background (Used for status bars, line number and folding marks) | ||
| 806 | base01 = "#37343a", | ||
| 807 | -- Selection Background | ||
| 808 | base02 = "#423f46", | ||
| 809 | -- Comments, Invisible, Line Highlighting | ||
| 810 | base03 = "#848089", | ||
| 811 | -- Dark Foreground (Used for status bars) | ||
| 812 | base04 = "#66d9ef", | ||
| 813 | -- Default Foreground, Caret, Delimiters, Operators | ||
| 814 | base05 = "#e3e1e4", | ||
| 815 | -- Light Foreground (Not often used) | ||
| 816 | base06 = "#a1efe4", | ||
| 817 | -- Light Background (Not often used) | ||
| 818 | base07 = "#f8f8f2", | ||
| 819 | -- Variables, XML Tags, Markup Link Text, Markup Lists, Diff Deleted | ||
| 820 | base08 = "#f85e84", | ||
| 821 | -- Integers, Boolean, Constants, XML Attributes, Markup Link Url | ||
| 822 | base09 = "#ef9062", | ||
| 823 | -- Classes, Markup Bold, Search Text Background | ||
| 824 | base0A = "#a6e22e", | ||
| 825 | -- Strings, Inherited Class, Markup Code, Diff Inserted | ||
| 826 | base0B = "#e5c463", | ||
| 827 | -- Support, Regular Expressions, Escape Characters, Markup Quotes | ||
| 828 | base0C = "#66d9ef", | ||
| 829 | -- Functions, Methods, Attribute IDs, Headings | ||
| 830 | base0D = "#9ecd6f", | ||
| 831 | -- Keywords, Storage, Selector, Markup Italic, Diff Changed | ||
| 832 | base0E = "#a1efe4", | ||
| 833 | -- Deprecated, Opening/Closing Embedded Language Tags, e.g. <?php ?> | ||
| 834 | base0F = "#f9f8f5", | ||
| 835 | }, | ||
| 836 | use_cterm = false, | ||
| 837 | }) | ||
| 838 | -- | ||
| 839 | -- Override settings for search | ||
| 840 | vim.cmd("hi Search guibg=#e5c07b") | ||
| 841 | -- | ||
| 842 | -- Resume terminal color | ||
| 843 | for i = 1, 15, 1 do | ||
| 844 | vim.cmd("let terminal_color_" .. i .. " = ''") | ||
| 845 | end | ||
| 846 | -- | ||
| 847 | -- Override settings for bufferline | ||
| 848 | vim.cmd("hi BufferLineTabSelected guibg=#f85e84") | ||
| 849 | vim.cmd("hi BufferLineTab guibg=Gray") | ||
| 850 | -- | ||
| 851 | --}}} | ||
| 852 | -- mini.icons {{{ | ||
| 853 | require("mini.icons").setup({}) | ||
| 854 | --}}} | ||
| 855 | -- mini.comment {{{ | ||
| 856 | require("mini.comment").setup({ | ||
| 857 | -- Module mappings. Use `''` (empty string) to disable one. | ||
| 858 | mappings = { | ||
| 859 | -- Toggle comment (like `gcip` - comment inner paragraph) for both | ||
| 860 | -- Normal and Visual modes | ||
| 861 | comment = "gc", | ||
| 862 | -- | ||
| 863 | -- Toggle comment on current line | ||
| 864 | comment_line = "<C-/>", | ||
| 865 | -- | ||
| 866 | -- Toggle comment on visual selection | ||
| 867 | comment_visual = "<C-/>", | ||
| 868 | -- | ||
| 869 | -- Define 'comment' textobject (like `dgc` - delete whole comment block) | ||
| 870 | -- Works also in Visual mode if mapping differs from `comment_visual` | ||
| 871 | textobject = "gc", | ||
| 872 | }, | ||
| 873 | }) -- }}} | ||
| 874 | -- mini.cursorword {{{ | ||
| 875 | require("mini.cursorword").setup() | ||
| 876 | -- }}} | ||
| 877 | -- mini.diff {{{ | ||
| 878 | require("mini.diff").setup({ | ||
| 879 | -- Options for how hunks are visualized | ||
| 880 | view = { | ||
| 881 | -- Visualization style. Possible values are 'sign' and 'number'. | ||
| 882 | -- Default: 'number' if line numbers are enabled, 'sign' otherwise. | ||
| 883 | style = "sign", | ||
| 884 | -- | ||
| 885 | -- Signs used for hunks with 'sign' view | ||
| 886 | signs = { add = "+", change = "▒", delete = "-" }, | ||
| 887 | -- | ||
| 888 | -- Priority of used visualization extmarks | ||
| 889 | priority = 199, | ||
| 890 | }, | ||
| 891 | }) | ||
| 892 | -- | ||
| 893 | vim.keymap.set("n", "\\gh", function() | ||
| 894 | MiniDiff.toggle_overlay() | ||
| 895 | end, { buffer = bufnr, desc = "Toggle diff" }) | ||
| 896 | -- | ||
| 897 | -- }}} | ||
| 898 | -- mini.map {{{ | ||
| 899 | require("mini.map").setup() | ||
| 900 | vim.keymap.set("n", "\\m", function() | ||
| 901 | require("mini.map").toggle() | ||
| 902 | end, { desc = "Minimap", buffer = bufnr }) | ||
| 903 | -- }}} | ||
| 904 | -- mini.visits {{{ | ||
| 905 | |||
| 906 | require("mini.visits").setup() | ||
| 907 | -- vim.keymap.set("n", "<leader><leader>li", function() | ||
| 908 | -- MiniVisits.list_paths() | ||
| 909 | -- end, { buffer = bufnr, desc = "" }) | ||
| 910 | -- | ||
| 911 | -- }}} | ||
| 912 | -- mini.surround {{{ | ||
| 913 | require("mini.surround").setup { | ||
| 914 | mappings = { | ||
| 915 | add = 's' | ||
| 916 | } | ||
| 917 | } | ||
| 918 | -- }}} | ||
| 919 | -- mini.indentscope {{{ | ||
| 920 | require("mini.indentscope").setup() | ||
| 921 | -- }}} | ||
| 922 | -- mini.splitjoin {{{ | ||
| 923 | require("mini.splitjoin").setup() | ||
| 924 | -- }}} | ||
| 925 | -- mini.move {{{ | ||
| 926 | require("mini.move").setup() | ||
| 927 | -- }}} | ||
| 928 | -- mini.hipatterns {{{ | ||
| 929 | -- | ||
| 930 | local hipatterns = require("mini.hipatterns") | ||
| 931 | hipatterns.setup({ | ||
| 932 | highlighters = { | ||
| 933 | -- Highlight standalone 'FIXME', 'HACK', 'TODO', 'NOTE' | ||
| 934 | fixme = { pattern = "%f[%w]()FIXME()%f[%W]", group = "MiniHipatternsFixme" }, | ||
| 935 | hack = { pattern = "%f[%w]()HACK()%f[%W]", group = "MiniHipatternsHack" }, | ||
| 936 | todo = { pattern = "%f[%w]()TODO()%f[%W]", group = "MiniHipatternsTodo" }, | ||
| 937 | note = { pattern = "%f[%w]()NOTE()%f[%W]", group = "MiniHipatternsNote" }, | ||
| 938 | -- | ||
| 939 | -- Highlight hex color strings (`#rrggbb`) using that color | ||
| 940 | hex_color = hipatterns.gen_highlighter.hex_color(), | ||
| 941 | }, | ||
| 942 | }) | ||
| 943 | vim.keymap.set("n", "<leader><leader>hi", function() | ||
| 944 | MiniHipatterns.toggle() | ||
| 945 | end, { buffer = bufnr, desc = "Toggle hex color highlight" }) | ||
| 946 | -- | ||
| 947 | -- }}} | ||
| 948 | -- mini.pairs {{{ | ||
| 949 | require("mini.pairs").setup() | ||
| 950 | -- }}} | ||
| 951 | -- -- mini.statusline {{{ | ||
| 952 | -- -- | ||
| 953 | -- require("mini.statusline").setup({ | ||
| 954 | -- content = { | ||
| 955 | -- active = status_config, | ||
| 956 | -- }, | ||
| 957 | -- }) | ||
| 958 | -- local function diagnostics_table(args) | ||
| 959 | -- local info = vim.b.coc_diagnostic_info | ||
| 960 | -- if MiniStatusline.is_truncated(args.trunc_width) or info == nil then | ||
| 961 | -- return {} | ||
| 962 | -- end | ||
| 963 | -- local table = {} | ||
| 964 | -- table.e = (info["error"] or 0) > 0 and "E" .. info["error"] or "" | ||
| 965 | -- table.w = (info["warning"] or 0) > 0 and "W" .. info["warning"] or "" | ||
| 966 | -- table.h = (info["hint"] or 0) > 0 and "H" .. info["hint"] or "" | ||
| 967 | -- table.i = (info["information"] or 0) > 0 and "I" .. info["information"] or "" | ||
| 968 | -- table.s = vim.g.coc_status | ||
| 969 | -- return table | ||
| 970 | -- end | ||
| 971 | -- | ||
| 972 | -- function status_config() | ||
| 973 | -- local mode, mode_hl = MiniStatusline.section_mode({ trunc_width = 120 }) | ||
| 974 | -- local git = MiniStatusline.section_git({ trunc_width = 75 }) | ||
| 975 | -- local diagnostics = diagnostics_table({ trunc_width = 75 }) | ||
| 976 | -- local filename = MiniStatusline.section_filename({ trunc_width = 140 }) | ||
| 977 | -- local fileinfo = MiniStatusline.section_fileinfo({ trunc_width = 120 }) | ||
| 978 | -- local location = MiniStatusline.section_location({ trunc_width = 75 }) | ||
| 979 | -- | ||
| 980 | -- return MiniStatusline.combine_groups({ | ||
| 981 | -- { hl = mode_hl, strings = { mode } }, | ||
| 982 | -- { hl = "MiniStatuslineDevinfo", strings = { git, diagnostics["s"] } }, | ||
| 983 | -- { hl = "MiniStatuslineError", strings = { diagnostics["e"] } }, | ||
| 984 | -- { hl = "MiniStatuslineWarning", strings = { diagnostics["w"] } }, | ||
| 985 | -- { hl = "MiniStatuslineInfo", strings = { diagnostics["i"] } }, | ||
| 986 | -- { hl = "MiniStatuslineHint", strings = { diagnostics["h"] } }, | ||
| 987 | -- "%<", -- Mark general truncate point | ||
| 988 | -- { hl = "MiniStatuslineFilename", strings = { filename } }, | ||
| 989 | -- "%=", -- End left alignment | ||
| 990 | -- { hl = "MiniStatuslineFileinfo", strings = { fileinfo } }, | ||
| 991 | -- { hl = mode_hl, strings = { location } }, | ||
| 992 | -- }) | ||
| 993 | -- end | ||
| 994 | -- | ||
| 995 | -- -- }}} | ||
| 996 | -- -- mini.completion {{{ | ||
| 997 | -- require('mini.completion').setup() | ||
| 998 | -- -- }}} | ||
| 999 | -- -- mini.tabline {{{ | ||
| 1000 | -- | ||
| 1001 | -- require('mini.tabline').setup { | ||
| 1002 | -- format = function(buf_id, label) | ||
| 1003 | -- local suffix = vim.bo[buf_id].modified and '+ ' or '' | ||
| 1004 | -- return MiniTabline.default_format(buf_id, label) .. suffix | ||
| 1005 | -- end, | ||
| 1006 | -- tabpage_section = 'right' | ||
| 1007 | -- } | ||
| 1008 | -- | ||
| 1009 | -- for i = 1, 9, 1 do | ||
| 1010 | -- vim.keymap.set("n", string.format("<A-%s>", i), function() | ||
| 1011 | -- vim.api.nvim_set_current_buf(vim.fn.getbufinfo({ buflisted=true })[i].bufnr) | ||
| 1012 | -- end, {silent = true}) | ||
| 1013 | -- end | ||
| 1014 | -- | ||
| 1015 | -- -- }}} | ||
| 1016 | -- -- mini.clue {{{ | ||
| 1017 | -- local miniclue = require('mini.clue') | ||
| 1018 | -- miniclue.setup({ | ||
| 1019 | -- triggers = { | ||
| 1020 | -- -- Leader triggers | ||
| 1021 | -- { mode = 'n', keys = '<Leader>' }, | ||
| 1022 | -- { mode = 'x', keys = '<Leader>' }, | ||
| 1023 | -- | ||
| 1024 | -- -- Built-in completion | ||
| 1025 | -- { mode = 'i', keys = '<C-x>' }, | ||
| 1026 | -- | ||
| 1027 | -- -- `g` key | ||
| 1028 | -- { mode = 'n', keys = 'g' }, | ||
| 1029 | -- { mode = 'x', keys = 'g' }, | ||
| 1030 | -- | ||
| 1031 | -- -- Marks | ||
| 1032 | -- { mode = 'n', keys = "'" }, | ||
| 1033 | -- { mode = 'n', keys = '`' }, | ||
| 1034 | -- { mode = 'x', keys = "'" }, | ||
| 1035 | -- { mode = 'x', keys = '`' }, | ||
| 1036 | -- | ||
| 1037 | -- -- Registers | ||
| 1038 | -- { mode = 'n', keys = '"' }, | ||
| 1039 | -- { mode = 'x', keys = '"' }, | ||
| 1040 | -- { mode = 'i', keys = '<C-r>' }, | ||
| 1041 | -- { mode = 'c', keys = '<C-r>' }, | ||
| 1042 | -- | ||
| 1043 | -- -- Window commands | ||
| 1044 | -- { mode = 'n', keys = '<C-w>' }, | ||
| 1045 | -- | ||
| 1046 | -- -- `z` key | ||
| 1047 | -- { mode = 'n', keys = 'z' }, | ||
| 1048 | -- { mode = 'x', keys = 'z' }, | ||
| 1049 | -- }, | ||
| 1050 | -- | ||
| 1051 | -- clues = { | ||
| 1052 | -- -- Enhance this by adding descriptions for <Leader> mapping groups | ||
| 1053 | -- miniclue.gen_clues.builtin_completion(), | ||
| 1054 | -- miniclue.gen_clues.g(), | ||
| 1055 | -- miniclue.gen_clues.marks(), | ||
| 1056 | -- miniclue.gen_clues.registers(), | ||
| 1057 | -- miniclue.gen_clues.windows(), | ||
| 1058 | -- miniclue.gen_clues.z(), | ||
| 1059 | -- }, | ||
| 1060 | -- -- }}} | ||
| 1061 | -- -- mini.bufremote {{{ | ||
| 1062 | -- require('mini.bufremove') | ||
| 1063 | --}}} | ||
| 1064 | -- -- mini.animate --{{{ | ||
| 1065 | -- require("mini.animate").setup() | ||
| 1066 | -- -- }}} | ||
| 1067 | -- -- suda {{{ | ||
| 1068 | -- add { source = "lambdalisue/suda.vim" } | ||
| 1069 | -- }}} | ||
| 1070 | -- -- true-zen {{{ | ||
| 1071 | -- Add({ | ||
| 1072 | -- source = "Pocco81/true-zen.nvim", | ||
| 1073 | -- }) | ||
| 1074 | -- vim.keymap.set("n", "<leader>z", ":TZAtaraxis<CR>") | ||
| 1075 | -- -- }}} | ||
| 1076 | -- bufferline {{{ | ||
| 1077 | Add({ | ||
| 1078 | source = "akinsho/bufferline.nvim", | ||
| 1079 | depends = { | ||
| 1080 | "nvim-tree/nvim-web-devicons", | ||
| 1081 | "tiagovla/scope.nvim", | ||
| 1082 | }, | ||
| 1083 | }) | ||
| 1084 | require('bufferline').setup{ | ||
| 1085 | options = { | ||
| 1086 | numbers = 'ordinal', | ||
| 1087 | tab_size = 14, | ||
| 1088 | separator_style = { "", "" }, | ||
| 1089 | themable = true, | ||
| 1090 | buffer_close_icon = "", | ||
| 1091 | close_icon = "", | ||
| 1092 | groups = { | ||
| 1093 | items = { | ||
| 1094 | require("bufferline.groups").builtin.pinned:with({ icon = "" }), | ||
| 1095 | }, | ||
| 1096 | }, | ||
| 1097 | enforce_regular_tabs = false, | ||
| 1098 | diagnostics = "coc", | ||
| 1099 | diagnostics_update_in_insert = true, | ||
| 1100 | diagnostics_indicator = function(count, level) | ||
| 1101 | local icon = level:match("error") and " " or " " | ||
| 1102 | return " " .. icon .. count | ||
| 1103 | end, | ||
| 1104 | offsets = { | ||
| 1105 | { | ||
| 1106 | filetype = "NvimTree", | ||
| 1107 | text = "File Explorer", | ||
| 1108 | highlight = "Directory", | ||
| 1109 | text_align = "left" | ||
| 1110 | }, | ||
| 1111 | { | ||
| 1112 | filetype = "coc-explorer", | ||
| 1113 | text = function() | ||
| 1114 | return vim.fn.getcwd() | ||
| 1115 | end, | ||
| 1116 | highlight = "Directory", | ||
| 1117 | text_align = "left" | ||
| 1118 | }, | ||
| 1119 | { | ||
| 1120 | filetype = 'vista', | ||
| 1121 | text = function() | ||
| 1122 | return vim.fn.getcwd() | ||
| 1123 | end, | ||
| 1124 | highlight = "Tags", | ||
| 1125 | text_align = "right" | ||
| 1126 | } | ||
| 1127 | }, | ||
| 1128 | custom_filter = function (buf_number) | ||
| 1129 | for _, p in ipairs(vim.t.bufs) do | ||
| 1130 | if p == buf_number then | ||
| 1131 | return true | ||
| 1132 | end | ||
| 1133 | end | ||
| 1134 | return false | ||
| 1135 | end | ||
| 1136 | } | ||
| 1137 | }; | ||
| 1138 | -- keymaps {{{ | ||
| 1139 | for i = 1, 9, 1 do | ||
| 1140 | vim.keymap.set("n", string.format("<A-%s>", i), function() | ||
| 1141 | vim.cmd("BufferLineGoToBuffer " .. i) | ||
| 1142 | end, { silent = true }) | ||
| 1143 | end | ||
| 1144 | local opts = { noremap = true, silent = true } | ||
| 1145 | vim.keymap.set("n", "<TAB>", "<Cmd>BufferLineCyclePrev<CR>", opts) | ||
| 1146 | vim.keymap.set("n", "<S-TAB>", "<Cmd>BufferLineCycleNext<CR>", opts) | ||
| 1147 | vim.keymap.set("n", "<M-h>", "<Cmd>BufferLineMovePrev<CR>", opts) | ||
| 1148 | vim.keymap.set("n", "<M-l>", "<Cmd>BufferLineMoveNext<CR>", opts) | ||
| 1149 | vim.keymap.set("n", "<M-p>", "<Cmd>BufferLineTogglePin<CR>", opts) | ||
| 1150 | -- }}} | ||
| 1151 | -- -- TODO: tabpages | ||
| 1152 | -- -- }}} | ||
| 1153 | -- marks.nvim {{{ | ||
| 1154 | Add { | ||
| 1155 | source = "chentoast/marks.nvim" | ||
| 1156 | } | ||
| 1157 | require('marks').setup { | ||
| 1158 | } | ||
| 1159 | vim.cmd("hi MarkSignHL guifg=#f85e84 guibg=#37343a") | ||
| 1160 | -- }}} | ||
| 1161 | -- KEYMAPS {{{ | 1167 | -- KEYMAPS {{{ |
| 1162 | 1168 | ||
| 1163 | -- Use floating window for translation | 1169 | -- Use floating window for translation |