aboutsummaryrefslogtreecommitdiffhomepage
path: root/vim/mini.lua
diff options
context:
space:
mode:
Diffstat (limited to 'vim/mini.lua')
-rw-r--r--vim/mini.lua659
1 files changed, 414 insertions, 245 deletions
diff --git a/vim/mini.lua b/vim/mini.lua
index e693db2..15f4c42 100644
--- a/vim/mini.lua
+++ b/vim/mini.lua
@@ -13,8 +13,7 @@ end
13vim.opt.rtp:prepend(lazypath) 13vim.opt.rtp:prepend(lazypath)
14-- }}} 14-- }}}
15require("lazy").setup({ 15require("lazy").setup({
16 16 -- "tpope/vim-sleuth",
17 "tpope/vim-sleuth",
18 -- Telescope {{{ 17 -- Telescope {{{
19 { 18 {
20 "nvim-telescope/telescope.nvim", 19 "nvim-telescope/telescope.nvim",
@@ -236,7 +235,6 @@ require("lazy").setup({
236 indent_markers = { 235 indent_markers = {
237 enable = true, 236 enable = true,
238 }, 237 },
239 --
240 icons = { 238 icons = {
241 show = { 239 show = {
242 file = true, 240 file = true,
@@ -244,7 +242,6 @@ require("lazy").setup({
244 folder_arrow = true, 242 folder_arrow = true,
245 git = true, 243 git = true,
246 }, 244 },
247 --
248 glyphs = { 245 glyphs = {
249 default = "󰈚", 246 default = "󰈚",
250 symlink = "", 247 symlink = "",
@@ -336,192 +333,278 @@ require("lazy").setup({
336 end, 333 end,
337 }, 334 },
338 --}}} 335 --}}}
336 -- lualine {{{
337 {
338 "nvim-lualine/lualine.nvim",
339 event = "VeryLazy",
340 init = function()
341 vim.g.lualine_laststatus = vim.o.laststatus
342 if vim.fn.argc(-1) > 0 then
343 -- set an empty statusline till lualine loads
344 vim.o.statusline = " "
345 else
346 -- hide the statusline on the starter page
347 vim.o.laststatus = 0
348 end
349 end,
350 opts = function()
351 -- PERF: we don't need this lualine require madness 🤷
352 local lualine_require = require("lualine_require")
353 lualine_require.require = require
339 354
340 -- -- lspconfig {{{ 355 vim.o.laststatus = vim.g.lualine_laststatus
341 -- -- Use :help lspconfig-all to check servers 356
342 -- { 357 local opts = {
343 -- "neovim/nvim-lspconfig", 358 options = {
344 -- lazy = false, 359 theme = "auto",
345 -- config = function() 360 globalstatus = vim.o.laststatus == 3,
346 -- local lspconfig = require "lspconfig" 361 disabled_filetypes = { statusline = { "dashboard", "alpha", "ministarter" } },
347 -- -- 362 },
348 -- -- typescript 363 sections = {
349 -- lspconfig.lua_ls.setup {} 364 lualine_a = { "mode" },
350 -- lspconfig.tsserver.setup {} 365 lualine_b = { "branch" },
351 -- lspconfig.vimls.setup {} 366
352 -- lspconfig.html.setup {} 367 lualine_x = {
353 -- -- 368 -- stylua: ignore
354 -- vim.keymap.set("n", "<leader>F", function() 369 {
355 -- vim.lsp.buf.format() 370 function() return require("noice").api.status.command.get() end,
356 -- end, { desc = "format files" }) 371 cond = function() return package.loaded["noice"] and require("noice").api.status.command.has() end,
357 -- end, 372 },
358 -- }, 373 -- stylua: ignore
359 -- -- }}} 374 {
360 -- -- Mason {{{ 375 function() return require("noice").api.status.mode.get() end,
361 -- { 376 cond = function() return package.loaded["noice"] and require("noice").api.status.mode.has() end,
362 -- "williamboman/mason.nvim", 377 },
363 -- config = function() 378 -- stylua: ignore
364 -- require('mason').setup { 379 {
365 -- automatically_installation = true, 380 function() return " " .. require("dap").status() end,
366 -- ensure_installed = { 381 cond = function() return package.loaded["dap"] and require("dap").status() ~= "" end,
367 -- "vim-language-server", 382 },
368 -- "lua-language-server", 383 -- stylua: ignore
369 -- "css-lsp", 384 {
370 -- "html-lsp", 385 require("lazy.status").updates,
371 -- "prettier", 386 cond = require("lazy.status").has_updates,
372 -- "stylua", 387 },
373 -- }, 388 {
374 -- } 389 "diff",
375 -- end 390 source = function()
376 -- }, 391 local gitsigns = vim.b.gitsigns_status_dict
377 -- -- }}} 392 if gitsigns then
378 -- -- treesitter {{{ 393 return {
379 -- { 394 added = gitsigns.added,
380 -- "nvim-treesitter/nvim-treesitter", 395 modified = gitsigns.changed,
381 -- event = { "BufReadPost", "BufNewFile" }, 396 removed = gitsigns.removed,
382 -- cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" }, 397 }
383 -- build = ":TSUpdate", 398 end
384 -- config = function() 399 end,
385 -- require("nvim-treesitter.configs").setup({ 400 },
386 -- ensure_installed = { "lua", "luadoc", "printf", "vim", "vimdoc" }, 401 },
387 -- -- 402 lualine_y = {
388 -- highlight = { 403 { "progress", separator = " ", padding = { left = 1, right = 0 } },
389 -- enable = true, 404 { "location", padding = { left = 0, right = 1 } },
390 -- use_languagetree = true, 405 },
391 -- }, 406 lualine_z = {
392 -- -- 407 function()
393 -- indent = { enable = true }, 408 return " " .. os.date("%R")
394 -- }) 409 end,
395 -- end, 410 },
396 -- }, 411 },
397 -- -- }}} 412 extensions = { "neo-tree", "lazy" },
398 -- -- nvim-cmp {{{ 413 }
399 -- { 414
400 -- "hrsh7th/nvim-cmp", 415 return opts
401 -- event = { 416 end,
402 -- "InsertEnter", 417 },
403 -- "CmdlineEnter" 418 -- }}}
404 -- }, 419
405 -- dependencies = { -- {{{ 420 -- lspconfig {{{
406 -- { 421 -- Use :help lspconfig-all to check servers
407 -- -- snippet plugin 422 {
408 -- "L3MON4D3/LuaSnip", 423 "neovim/nvim-lspconfig",
409 -- build = "make install_jsregexp", 424 lazy = false,
410 -- dependencies = { 425 config = function()
411 -- "rafamadriz/friendly-snippets", 426 local lspconfig = require "lspconfig"
412 -- "saadparwaiz1/cmp_luasnip", 427 --
413 -- "onsails/lspkind-nvim", 428 -- typescript
414 -- }, 429 lspconfig.lua_ls.setup {}
415 -- opts = { 430 lspconfig.tsserver.setup {}
416 -- history = true, 431 lspconfig.vimls.setup {}
417 -- updateevents = "TextChanged,TextChangedI" 432 lspconfig.html.setup {}
418 -- }, 433 --
419 -- config = function(_, opts) 434 vim.keymap.set("n", "<leader>F", function()
420 -- require("luasnip").config.set_config(opts) 435 vim.lsp.buf.format()
421 -- require("luasnip.loaders.from_vscode").lazy_load() 436 end, { desc = "format files" })
422 -- require("luasnip.loaders.from_lua").load() 437 end,
423 -- require("luasnip.loaders.from_lua").lazy_load { paths = vim.g.lua_snippets_path or "" } 438 },
424 -- -- 439 -- }}}
425 -- vim.api.nvim_create_autocmd("InsertLeave", { 440 -- Mason {{{
426 -- callback = function() 441 {
427 -- if 442 "williamboman/mason.nvim",
428 -- require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()] 443 dependencies = {
429 -- and not require("luasnip").session.jump_active 444 "williamboman/mason-lspconfig.nvim",
430 -- then 445 },
431 -- require("luasnip").unlink_current() 446 config = function()
432 -- end 447 require('mason').setup {
433 -- end, 448 automatically_installation = true,
434 -- }) 449 ensure_installed = {
435 -- end, 450 "vim-language-server",
436 -- }, 451 "lua-language-server",
437 -- -- 452 "css-lsp",
438 -- -- cmp sources plugins 453 "html-lsp",
439 -- { 454 "prettier",
440 -- "hrsh7th/cmp-nvim-lua", 455 "stylua",
441 -- "hrsh7th/cmp-nvim-lsp", 456 },
442 -- "hrsh7th/cmp-buffer", 457 }
443 -- "hrsh7th/cmp-path", 458 end
444 -- "hrsh7th/cmp-cmdline", 459 },
445 -- }, 460 -- }}}
446 -- }, -- }}} 461 -- treesitter {{{
447 -- config = function() 462 {
448 -- local cmp = require "cmp" 463 "nvim-treesitter/nvim-treesitter",
449 -- local default_mapping = { 464 event = { "BufReadPost", "BufNewFile" },
450 -- ["<S-TAB>"] = cmp.mapping.select_prev_item(), 465 cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" },
451 -- ["<TAB>"] = cmp.mapping.select_next_item(), 466 build = ":TSUpdate",
452 -- ["<C-p>"] = cmp.mapping.select_prev_item(), 467 config = function()
453 -- ["<C-n>"] = cmp.mapping.select_next_item(), 468 require("nvim-treesitter.configs").setup({
454 -- ["<C-d>"] = cmp.mapping.scroll_docs(-4), 469 ensure_installed = { "lua", "luadoc", "printf", "vim", "vimdoc" },
455 -- ["<C-f>"] = cmp.mapping.scroll_docs(4), 470 --
456 -- ["<C-Space>"] = cmp.mapping.complete(), 471 highlight = {
457 -- ["<C-e>"] = cmp.mapping.close(), 472 enable = true,
458 -- ['<CR>'] = cmp.mapping.confirm(), 473 use_languagetree = true,
459 -- ['<C-c>'] = cmp.mapping.abort(), 474 },
460 -- } 475 --
461 -- 476 indent = { enable = true },
462 -- require("cmp").setup({ 477 })
463 -- completion = { 478 end,
464 -- completeopt = "menu,menuone,noselect", 479 },
465 -- }, 480 -- }}}
466 -- window = { 481 -- nvim-cmp {{{
467 -- documentation = cmp.config.window.bordered(), 482 {
468 -- completion = cmp.config.window.bordered({ 483 "hrsh7th/nvim-cmp",
469 -- winhighlight = 'Normal:CmpPmenu,CursorLine:PmenuSel,Search:None' 484 event = {
470 -- }), 485 "InsertEnter",
471 -- }, 486 "CmdlineEnter"
472 -- snippet = { 487 },
473 -- expand = function(args) 488 dependencies = { -- {{{
474 -- require("luasnip").lsp_expand(args.body) 489 {
475 -- end, 490 -- snippet plugin
476 -- }, 491 "L3MON4D3/LuaSnip",
477 -- formatting = { 492 build = "make install_jsregexp",
478 -- format = require('lspkind').cmp_format({ 493 dependencies = {
479 -- with_text = true, -- do not show text alongside icons 494 "rafamadriz/friendly-snippets",
480 -- maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) 495 "saadparwaiz1/cmp_luasnip",
481 -- before = function(entry, vim_item) 496 "onsails/lspkind-nvim",
482 -- -- Source 显示提示来源 497 },
483 -- vim_item.menu = '<' .. entry.source.name .. '>' 498 opts = {
484 -- return vim_item 499 history = true,
485 -- end 500 updateevents = "TextChanged,TextChangedI"
486 -- }) 501 },
487 -- }, 502 config = function(_, opts)
488 -- mapping = default_mapping, 503 require("luasnip").config.set_config(opts)
489 -- sources = cmp.config.sources { 504 require("luasnip.loaders.from_vscode").lazy_load()
490 -- { name = "nvim_lsp" }, 505 require("luasnip.loaders.from_lua").load()
491 -- { name = "luasnip" }, 506 require("luasnip.loaders.from_lua").lazy_load { paths = vim.g.lua_snippets_path or "" }
492 -- { name = "buffer" }, 507 --
493 -- { name = "nvim_lua" }, 508 vim.api.nvim_create_autocmd("InsertLeave", {
494 -- { name = "path" }, 509 callback = function()
495 -- }, 510 if
496 -- experimental = { 511 require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()]
497 -- ghost_text = true, 512 and not require("luasnip").session.jump_active
498 -- } 513 then
499 -- }) 514 require("luasnip").unlink_current()
500 -- cmp.setup.cmdline(':', { 515 end
501 -- mapping = cmp.mapping.preset.cmdline { 516 end,
502 -- ['<C-n>'] = cmp.config.disable, 517 })
503 -- ['<C-p>'] = cmp.config.disable, 518 end,
504 -- ['<C-c>'] = cmp.mapping.abort(), 519 },
505 -- }, 520 --
506 -- sources = cmp.config.sources( 521 -- cmp sources plugins
507 -- { { name = 'path' } }, 522 {
508 -- { { name = 'cmdline' } } 523 "hrsh7th/cmp-nvim-lua",
509 -- ) 524 "hrsh7th/cmp-nvim-lsp",
510 -- }) 525 "hrsh7th/cmp-buffer",
511 -- cmp.setup.cmdline({ '/', '?' }, { 526 "hrsh7th/cmp-path",
512 -- mapping = cmp.mapping.preset.cmdline { 527 "hrsh7th/cmp-cmdline",
513 -- ['<C-n>'] = cmp.config.disable, 528 },
514 -- ['<C-p>'] = cmp.config.disable, 529 }, -- }}}
515 -- ['<C-c>'] = cmp.mapping.abort(), 530 config = function()
516 -- }, 531 local cmp = require "cmp"
517 -- sources = { { name = 'buffer' } } 532 local default_mapping = {
518 -- }) 533 ["<S-TAB>"] = cmp.mapping.select_prev_item(),
519 -- 534 ["<TAB>"] = cmp.mapping.select_next_item(),
520 -- vim.opt.complete = "" 535 ["<C-p>"] = cmp.mapping.select_prev_item(),
521 -- end, 536 ["<C-n>"] = cmp.mapping.select_next_item(),
522 -- }, 537 ["<C-d>"] = cmp.mapping.scroll_docs(-4),
523 -- 538 ["<C-f>"] = cmp.mapping.scroll_docs(4),
524 -- -- }}} 539 ["<C-Space>"] = cmp.mapping.complete(),
540 ["<C-e>"] = cmp.mapping.close(),
541 ['<CR>'] = cmp.mapping.confirm(),
542 ['<C-c>'] = cmp.mapping.abort(),
543 }
544
545 require("cmp").setup({
546 completion = {
547 completeopt = "menu,menuone,noselect",
548 },
549 window = {
550 documentation = cmp.config.window.bordered(),
551 completion = cmp.config.window.bordered({
552 winhighlight = 'Normal:CmpPmenu,CursorLine:PmenuSel,Search:None'
553 }),
554 },
555 snippet = {
556 expand = function(args)
557 require("luasnip").lsp_expand(args.body)
558 end,
559 },
560 formatting = {
561 format = require('lspkind').cmp_format({
562 with_text = true, -- do not show text alongside icons
563 maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
564 before = function(entry, vim_item)
565 -- Source 显示提示来源
566 vim_item.menu = '<' .. entry.source.name .. '>'
567 return vim_item
568 end
569 })
570 },
571 mapping = default_mapping,
572 sources = cmp.config.sources {
573 { name = "nvim_lsp" },
574 { name = "luasnip" },
575 { name = "buffer" },
576 { name = "nvim_lua" },
577 { name = "path" },
578 },
579 experimental = {
580 ghost_text = true,
581 }
582 })
583 cmp.setup.cmdline(':', {
584 mapping = cmp.mapping.preset.cmdline {
585 ['<C-n>'] = cmp.config.disable,
586 ['<C-p>'] = cmp.config.disable,
587 ['<C-c>'] = cmp.mapping.abort(),
588 },
589 sources = cmp.config.sources(
590 { { name = 'path' } },
591 { { name = 'cmdline' } }
592 )
593 })
594 cmp.setup.cmdline({ '/', '?' }, {
595 mapping = cmp.mapping.preset.cmdline {
596 ['<C-n>'] = cmp.config.disable,
597 ['<C-p>'] = cmp.config.disable,
598 ['<C-c>'] = cmp.mapping.abort(),
599 },
600 sources = { { name = 'buffer' } }
601 })
602
603 vim.opt.complete = ""
604 end,
605 },
606
607 -- }}}
525 -- -- lspsaga {{{ 608 -- -- lspsaga {{{
526 -- { 609 -- {
527 -- 'nvimdev/lspsaga.nvim', 610 -- 'nvimdev/lspsaga.nvim',
@@ -555,7 +638,6 @@ require("lazy").setup({
555 -- end, 638 -- end,
556 -- }, 639 -- },
557 -- -- }}} 640 -- -- }}}
558
559}) 641})
560 642
561-- Install mini.nvim {{{ 643-- Install mini.nvim {{{
@@ -658,52 +740,6 @@ vim.cmd("hi BufferLineTab guibg=Gray")
658-- mini.icons {{{ 740-- mini.icons {{{
659require("mini.icons").setup({}) 741require("mini.icons").setup({})
660--}}} 742--}}}
661-- mini.statusline {{{
662--
663require("mini.statusline").setup({
664 content = {
665 active = status_config,
666 },
667})
668local function diagnostics_table(args)
669 local info = vim.b.coc_diagnostic_info
670 if MiniStatusline.is_truncated(args.trunc_width) or info == nil then
671 return {}
672 end
673 local table = {}
674 table.e = (info["error"] or 0) > 0 and "E" .. info["error"] or ""
675 table.w = (info["warning"] or 0) > 0 and "W" .. info["warning"] or ""
676 table.h = (info["hint"] or 0) > 0 and "H" .. info["hint"] or ""
677 table.i = (info["information"] or 0) > 0 and "I" .. info["information"] or ""
678 table.s = vim.g.coc_status
679 return table
680end
681--
682function status_config()
683 local mode, mode_hl = MiniStatusline.section_mode({ trunc_width = 120 })
684 local git = MiniStatusline.section_git({ trunc_width = 75 })
685 local diagnostics = diagnostics_table({ trunc_width = 75 })
686 local filename = MiniStatusline.section_filename({ trunc_width = 140 })
687 local fileinfo = MiniStatusline.section_fileinfo({ trunc_width = 120 })
688 local location = MiniStatusline.section_location({ trunc_width = 75 })
689 --
690 return MiniStatusline.combine_groups({
691 { hl = mode_hl, strings = { mode } },
692 { hl = "MiniStatuslineDevinfo", strings = { git, diagnostics["s"] } },
693 { hl = "MiniStatuslineError", strings = { diagnostics["e"] } },
694 { hl = "MiniStatuslineWarning", strings = { diagnostics["w"] } },
695 { hl = "MiniStatuslineInfo", strings = { diagnostics["i"] } },
696 { hl = "MiniStatuslineHint", strings = { diagnostics["h"] } },
697 "%<", -- Mark general truncate point
698 { hl = "MiniStatuslineFilename", strings = { filename } },
699 "%=", -- End left alignment
700 { hl = "MiniStatuslineFileinfo", strings = { fileinfo } },
701 { hl = mode_hl, strings = { location } },
702 })
703end
704
705--
706-- }}}
707-- mini.comment {{{ 743-- mini.comment {{{
708require("mini.comment").setup({ 744require("mini.comment").setup({
709 -- Module mappings. Use `''` (empty string) to disable one. 745 -- Module mappings. Use `''` (empty string) to disable one.
@@ -754,17 +790,20 @@ vim.keymap.set("n", "\\m", function()
754end, { desc = "Minimap", buffer = bufnr }) 790end, { desc = "Minimap", buffer = bufnr })
755-- }}} 791-- }}}
756-- mini.visits {{{ 792-- mini.visits {{{
793
757require("mini.visits").setup() 794require("mini.visits").setup()
758-- vim.keymap.set("n", "<leader><leader>li", function() 795-- vim.keymap.set("n", "<leader><leader>li", function()
759-- MiniVisits.list_paths() 796-- MiniVisits.list_paths()
760-- end, { buffer = bufnr, desc = "" }) 797-- end, { buffer = bufnr, desc = "" })
798--
761-- }}} 799-- }}}
762-- mini.surround {{{ 800-- mini.surround {{{
763require("mini.surround").setup({ 801require("mini.surround").setup {
764 mappings = { 802 mappings = {
765 add = "s", 803 add = 'S'
766 }, 804 }
767}) 805}
806vim.keymap.set('v', 's', 'S', { remap = true })
768-- }}} 807-- }}}
769-- mini.indentscope {{{ 808-- mini.indentscope {{{
770require("mini.indentscope").setup() 809require("mini.indentscope").setup()
@@ -798,6 +837,51 @@ end, { buffer = bufnr, desc = "Toggle hex color highlight" })
798-- mini.pairs {{{ 837-- mini.pairs {{{
799require("mini.pairs").setup() 838require("mini.pairs").setup()
800-- }}} 839-- }}}
840-- -- mini.statusline {{{
841-- --
842-- require("mini.statusline").setup({
843-- content = {
844-- active = status_config,
845-- },
846-- })
847-- local function diagnostics_table(args)
848-- local info = vim.b.coc_diagnostic_info
849-- if MiniStatusline.is_truncated(args.trunc_width) or info == nil then
850-- return {}
851-- end
852-- local table = {}
853-- table.e = (info["error"] or 0) > 0 and "E" .. info["error"] or ""
854-- table.w = (info["warning"] or 0) > 0 and "W" .. info["warning"] or ""
855-- table.h = (info["hint"] or 0) > 0 and "H" .. info["hint"] or ""
856-- table.i = (info["information"] or 0) > 0 and "I" .. info["information"] or ""
857-- table.s = vim.g.coc_status
858-- return table
859-- end
860--
861-- function status_config()
862-- local mode, mode_hl = MiniStatusline.section_mode({ trunc_width = 120 })
863-- local git = MiniStatusline.section_git({ trunc_width = 75 })
864-- local diagnostics = diagnostics_table({ trunc_width = 75 })
865-- local filename = MiniStatusline.section_filename({ trunc_width = 140 })
866-- local fileinfo = MiniStatusline.section_fileinfo({ trunc_width = 120 })
867-- local location = MiniStatusline.section_location({ trunc_width = 75 })
868--
869-- return MiniStatusline.combine_groups({
870-- { hl = mode_hl, strings = { mode } },
871-- { hl = "MiniStatuslineDevinfo", strings = { git, diagnostics["s"] } },
872-- { hl = "MiniStatuslineError", strings = { diagnostics["e"] } },
873-- { hl = "MiniStatuslineWarning", strings = { diagnostics["w"] } },
874-- { hl = "MiniStatuslineInfo", strings = { diagnostics["i"] } },
875-- { hl = "MiniStatuslineHint", strings = { diagnostics["h"] } },
876-- "%<", -- Mark general truncate point
877-- { hl = "MiniStatuslineFilename", strings = { filename } },
878-- "%=", -- End left alignment
879-- { hl = "MiniStatuslineFileinfo", strings = { fileinfo } },
880-- { hl = mode_hl, strings = { location } },
881-- })
882-- end
883--
884-- -- }}}
801-- -- mini.completion {{{ 885-- -- mini.completion {{{
802-- require('mini.completion').setup() 886-- require('mini.completion').setup()
803-- -- }}} 887-- -- }}}
@@ -878,7 +962,7 @@ require("mini.pairs").setup()
878-- }) 962-- })
879-- vim.keymap.set("n", "<leader>z", ":TZAtaraxis<CR>") 963-- vim.keymap.set("n", "<leader>z", ":TZAtaraxis<CR>")
880-- -- }}} 964-- -- }}}
881-- bufferline {{{ 965-- -- bufferline {{{
882Add({ 966Add({
883 source = "akinsho/bufferline.nvim", 967 source = "akinsho/bufferline.nvim",
884 depends = { 968 depends = {
@@ -886,8 +970,9 @@ Add({
886 "tiagovla/scope.nvim", 970 "tiagovla/scope.nvim",
887 }, 971 },
888}) 972})
889require("bufferline").setup({ 973require('bufferline').setup{
890 options = { 974 options = {
975 numbers = 'ordinal',
891 tab_size = 14, 976 tab_size = 14,
892 separator_style = { "", "" }, 977 separator_style = { "", "" },
893 themable = true, 978 themable = true,
@@ -898,9 +983,66 @@ require("bufferline").setup({
898 require("bufferline.groups").builtin.pinned:with({ icon = "󰐃" }), 983 require("bufferline.groups").builtin.pinned:with({ icon = "󰐃" }),
899 }, 984 },
900 }, 985 },
901 }, 986 enforce_regular_tabs = false,
902}) 987 diagnostics = "coc",
903require("scope").setup({}) 988 diagnostics_update_in_insert = true,
989 diagnostics_indicator = function(count, level)
990 local icon = level:match("error") and " " or " "
991 return " " .. icon .. count
992 end,
993 offsets = {
994 {
995 filetype = "NvimTree",
996 text = "File Explorer",
997 highlight = "Directory",
998 text_align = "left"
999 },
1000 {
1001 filetype = "coc-explorer",
1002 text = function()
1003 return vim.fn.getcwd()
1004 end,
1005 highlight = "Directory",
1006 text_align = "left"
1007 },
1008 {
1009 filetype = 'vista',
1010 text = function()
1011 return vim.fn.getcwd()
1012 end,
1013 highlight = "Tags",
1014 text_align = "right"
1015 }
1016 },
1017 custom_filter = function (buf_number)
1018 local tabId = tostring(vim.fn.tabpagenr())
1019 if vim.g.tab_group[tabId] then
1020 for _, p in ipairs(vim.g.tab_group[tabId]) do
1021 if p == buf_number then
1022 return true
1023 end
1024 end
1025 end
1026 return false
1027 end
1028 }
1029};
1030
1031-- require("bufferline").setup({
1032-- options = {
1033-- custom_filter = function(buf_number)
1034-- local tabId = vim.fn.tabpagenr()
1035-- if vim.g.tab_group[tabId] then
1036-- for _, p in ipairs(vim.g.tab_group[tabId]) do
1037-- if p == buf_number then
1038-- return true
1039-- end
1040-- end
1041-- end
1042-- return false
1043-- end
1044-- },
1045-- })
904-- keymaps {{{ 1046-- keymaps {{{
905for i = 1, 9, 1 do 1047for i = 1, 9, 1 do
906 vim.keymap.set("n", string.format("<A-%s>", i), function() 1048 vim.keymap.set("n", string.format("<A-%s>", i), function()
@@ -914,4 +1056,31 @@ vim.keymap.set("n", "<M-h>", "<Cmd>BufferLineMovePrev<CR>", opts)
914vim.keymap.set("n", "<M-l>", "<Cmd>BufferLineMoveNext<CR>", opts) 1056vim.keymap.set("n", "<M-l>", "<Cmd>BufferLineMoveNext<CR>", opts)
915vim.keymap.set("n", "<M-p>", "<Cmd>BufferLineTogglePin<CR>", opts) 1057vim.keymap.set("n", "<M-p>", "<Cmd>BufferLineTogglePin<CR>", opts)
916-- }}} 1058-- }}}
1059-- -- TODO: tabpages
1060-- -- }}}
1061
1062-- KEYMAPS {{{
1063
1064-- Use floating window for translation
1065vim.keymap.set("v", "Tz", function()
1066 vim.cmd('norm o^zt"ty')
1067 local translated_text = vim.fn.system("trans -t zh-TW -b", vim.fn.getreg("t"))
1068 local lines = vim.split(translated_text, "\n")
1069 table.remove(lines)
1070
1071 local new_buf = vim.api.nvim_create_buf(false, true)
1072 vim.api.nvim_buf_set_lines(new_buf, 0, -1, true, lines)
1073
1074 vim.api.nvim_open_win(new_buf, true, {
1075 relative = "cursor",
1076 width = 80,
1077 height = #lines,
1078 row = #lines,
1079 col = 0,
1080 })
1081
1082 vim.cmd("setl nocul nonu nornu")
1083 vim.cmd("hi ActiveWindow guibg=#2a5a6a guifg=White | setl winhighlight=Normal:ActiveWindow")
1084 vim.cmd(":silent! %s/\\%x1b\\[[0-9;]*m//g")
1085end, { desc = "Description" })
917-- }}} 1086-- }}}