From e9e1ab82b3315875ed57cf2fd1f5c45b99c15cf1 Mon Sep 17 00:00:00 2001 From: huyjaky Date: Sat, 2 Aug 2025 13:03:28 +0700 Subject: [PATCH] astro-nvim-v3 - Update: add context function for neo --- init.lua | 1 + lazy-lock.json | 5 +- lua/plugins/astrocore.lua | 2 +- lua/plugins/astrolsp.lua | 421 +++++++++++++------------- lua/plugins/colorschemes.lua | 27 -- lua/plugins/configs/ui/highlights.lua | 4 +- lua/plugins/disabled.lua | 85 +++--- lua/plugins/editor.lua | 13 - lua/plugins/nvim-context-vt.lua | 22 ++ lua/plugins/nvim-context.lua | 28 ++ lua/plugins/ui.lua | 83 ++--- 11 files changed, 360 insertions(+), 331 deletions(-) create mode 100644 lua/plugins/nvim-context-vt.lua create mode 100644 lua/plugins/nvim-context.lua diff --git a/init.lua b/init.lua index 3a5cdf7..75d7f27 100644 --- a/init.lua +++ b/init.lua @@ -18,6 +18,7 @@ if not pcall(require, "lazy") then vim.cmd.quit() end + -- NOTE: ENV -- Disable Copilot tab mapping vim.g.copilot_no_tab_map = true diff --git a/lazy-lock.json b/lazy-lock.json index d30543a..1f84e3b 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -15,7 +15,6 @@ "catppuccin": { "branch": "main", "commit": "0b5df9c9e641b1212b21a0762ccad4434fd41322" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" }, - "cmp-dap": { "branch": "master", "commit": "ea92773e84c0ad3288c3bc5e452ac91559669087" }, "cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, @@ -61,16 +60,16 @@ "nvim-highlight-colors": { "branch": "main", "commit": "b42a5ccec7457b44e89f7ed3b3afb1b375bb2093" }, "nvim-lsp-endhints": { "branch": "main", "commit": "7917c7af1ec345ca9b33e8dbcd3723fc15d023c0" }, "nvim-lspconfig": { "branch": "master", "commit": "185b2af444b27d6541c02d662b5b68190e5cf0c4" }, - "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, "nvim-notify": { "branch": "master", "commit": "a3020c2cf4dfc4c4f390c4a21e84e35e46cf5d17" }, "nvim-spider": { "branch": "main", "commit": "6da0307421bc4be6fe02815faabde51007c4ea1a" }, "nvim-treesitter": { "branch": "master", "commit": "f8aaf5ce4e27cd20de917946b2ae5c968a2c2858" }, + "nvim-treesitter-context": { "branch": "master", "commit": "6853ecb2cd8b062365da1cdd1a2e6f934ad55ed6" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "9937e5e356e5b227ec56d83d0a9d0a0f6bc9cad4" }, "nvim-ts-autotag": { "branch": "main", "commit": "1cca23c9da708047922d3895a71032bc0449c52d" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" }, "nvim-ufo": { "branch": "main", "commit": "a5390706f510d39951dd581f6d2a972741b3fa26" }, + "nvim_context_vt": { "branch": "master", "commit": "4ee3f8fe1b3aacacd31eaf77378dffcad0ff9465" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, - "rainbow-delimiters.nvim": { "branch": "master", "commit": "97bf4b8ef9298644a29fcd9dd41a0210cf08cac7" }, "resession.nvim": { "branch": "master", "commit": "cc819b0489938d03e4f3532a583354f0287c015b" }, "schemastore.nvim": { "branch": "main", "commit": "67d6c391e9a372d2d8701b5b8c9ae89455561fbf" }, "smart-splits.nvim": { "branch": "master", "commit": "ddb23c1a1cf1507bda487cda7f6e4690965ef9f5" }, diff --git a/lua/plugins/astrocore.lua b/lua/plugins/astrocore.lua index 3b73bfe..15c5f22 100644 --- a/lua/plugins/astrocore.lua +++ b/lua/plugins/astrocore.lua @@ -13,7 +13,7 @@ return { large_buf = { size = 1024 * 500, lines = 10000 }, -- set global limits for large files for disabling features like treesitter autopairs = false, -- enable autopairs at start cmp = true, -- enable completion at start - diagnostics_mode = 3, -- diagnostic mode on start (0 = off, 1 = no signs/virtual text, 2 = no virtual text, 3 = on) + diagnostics_mode = 2, -- diagnostic mode on start (0 = off, 1 = no signs/virtual text, 2 = no virtual text, 3 = on) highlighturl = false, -- highlight URLs at start notifications = true, -- enable notifications at start }, diff --git a/lua/plugins/astrolsp.lua b/lua/plugins/astrolsp.lua index 895f439..fdeab0c 100644 --- a/lua/plugins/astrolsp.lua +++ b/lua/plugins/astrolsp.lua @@ -4,219 +4,220 @@ ---@type LazySpec return { - "AstroNvim/astrolsp", - ---@type AstroLSPOpts - opts = { - -- Configuration table of features provided by AstroLSP - features = { - autoformat = false, -- enable or disable auto formatting on start - codelens = false, -- enable/disable codelens refresh on start - inlay_hints = false, -- enable/disable inlay hints on start - semantic_tokens = true, -- enable/disable semantic token highlighting - }, - -- customize lsp formatting options - formatting = require("plugins.configs.lsp.formatting"), - -- enable servers that you already have installed without mason - servers = {}, - -- customize language server configuration options passed to `lspconfig` - ---@diagnostic disable: missing-fields - config = { - -- clangd = require "plugins.configs.lsp.config.clangd", - basedpyright = require("plugins.configs.lsp.config.basedpyright"), + "AstroNvim/astrolsp", + ---@type AstroLSPOpts + opts = { + -- Configuration table of features provided by AstroLSP + features = { + autoformat = false, -- enable or disable auto formatting on start + codelens = false, -- enable/disable codelens refresh on start + inlay_hints = false, -- enable/disable inlay hints on start + semantic_tokens = true, -- enable/disable semantic token highlighting + }, + -- customize lsp formatting options + formatting = require("plugins.configs.lsp.formatting"), + -- enable servers that you already have installed without mason + servers = {}, + -- customize language server configuration options passed to `lspconfig` + ---@diagnostic disable: missing-fields + config = { + -- clangd = require "plugins.configs.lsp.config.clangd", + basedpyright = require("plugins.configs.lsp.config.basedpyright"), - jedi_language_server = { - init_options = { - completion = { - disableSnippets = true, - }, - diagnostics = { - enable = true, - }, - jediSettings = { - autoImportModules = { - "numpy", - "pandas", - "torch", - "sklearn", - }, - }, - workspace = { - environmentPath = "/home/duckq1u/miniconda3/envs/OCR3/bin/python" - } - }, - }, + jedi_language_server = { + init_options = { + completion = { + disableSnippets = true, + }, + diagnostics = { + enable = true, + }, + jediSettings = { + autoImportModules = { + "numpy", + "pandas", + "torch", + "sklearn", + }, + }, + workspace = { + environmentPath = "/home/duckq1u/miniconda3/envs/OCR3/bin/python", + ignore = { "/home/duckq1u/miniconda3/envs/OCR3/lib/python3.11/site-packages/transformers/mode ls/albert/configuration_albert.py" }, + }, + }, + }, - ruff = { - init_options = { - settings = { - lint = { - unfixable = { "F401" }, - select = { - "ALL", - }, - ignore = { - "ANN", - "COM", - "C90", - "DJ", - "EXE", - "T10", - "TID", - "D100", - "D101", - "D102", - "D103", - "D104", - "D105", - "D106", - "D107", - "D200", - "D205", - "D212", - "D400", - "D401", - "D415", - "E402", - "E501", - "ERA001", - "TRY003", - "TD002", - "TD003", - "T201", - "FIX002", - "N803", - "PD901", - -- "F401", - "I001", - "RET504", - "PLR2004", - "W291", - "PLW2901", - "D213", - "PLR0402", - }, - }, + ruff = { + init_options = { + settings = { + lint = { + unfixable = { "F401" }, + select = { + "ALL", + }, + ignore = { + "ANN", + "COM", + "C90", + "DJ", + "EXE", + "T10", + "TID", + "D100", + "D101", + "D102", + "D103", + "D104", + "D105", + "D106", + "D107", + "D200", + "D205", + "D212", + "D400", + "D401", + "D415", + "E402", + "E501", + "ERA001", + "TRY003", + "TD002", + "TD003", + "T201", + "FIX002", + "N803", + "PD901", + -- "F401", + "I001", + "RET504", + "PLR2004", + "W291", + "PLW2901", + "D213", + "PLR0402", + }, + }, - args = {}, - }, - }, - }, - }, - -- customize how language servers are attached - handlers = { - -- a function without a key is simply the default handler, functions take two parameters, the server name and the configured options table for that server - -- function(server, opts) require("lspconfig")[server].setup(opts) end + args = {}, + }, + }, + }, + }, + -- customize how language servers are attached + handlers = { + -- a function without a key is simply the default handler, functions take two parameters, the server name and the configured options table for that server + -- function(server, opts) require("lspconfig")[server].setup(opts) end - -- the key is the server that is being setup with `lspconfig` - -- rust_analyzer = false, -- setting a handler to false will disable the set up of that language server - -- pyright = function(_, opts) require("lspconfig").pyright.setup(opts) end -- or a custom handler function can be passed - }, - -- Configure buffer local auto commands to add when attaching a language server - autocmds = { - -- first key is the `augroup` to add the auto commands to (:h augroup) - lsp_document_highlight = { - -- Optional condition to create/delete auto command group - -- can either be a string of a client capability or a function of `fun(client, bufnr): boolean` - -- condition will be resolved for each client on each execution and if it ever fails for all clients, - -- the auto commands will be deleted for that buffer - cond = "textDocument/documentHighlight", - -- cond = function(client, bufnr) return client.name == "lua_ls" end, - -- list of auto commands to set - { - -- events to trigger - event = { "CursorHold", "CursorHoldI" }, - -- the rest of the autocmd options (:h nvim_create_autocmd) - desc = "Document Highlighting", - callback = function() - vim.lsp.buf.document_highlight() - end, - }, - { - event = { "CursorMoved", "CursorMovedI", "BufLeave" }, - desc = "Document Highlighting Clear", - callback = function() - vim.lsp.buf.clear_references() - end, - }, - }, - -- disable inlay hints in insert mode - disable_inlay_hints_on_insert = { - -- only create for language servers that support inlay hints - -- (and only if vim.lsp.inlay_hint is available) - cond = vim.lsp.inlay_hint and "textDocument/inlayHint" or false, - { - -- when going into insert mode - event = "InsertEnter", - desc = "disable inlay hints on insert", - callback = function(args) - local filter = { bufnr = args.buf } - -- if the inlay hints are currently enabled - if vim.lsp.inlay_hint.is_enabled(filter) then - -- disable the inlay hints - vim.lsp.inlay_hint.enable(false, filter) - -- create a single use autocommand to turn the inlay hints back on - -- when leaving insert mode - vim.api.nvim_create_autocmd("InsertLeave", { - buffer = args.buf, - once = true, - callback = function() - vim.lsp.inlay_hint.enable(true, filter) - end, - }) - end - end, - }, - }, - }, - -- mappings to be set up on attaching of a language server - mappings = { - n = { - gh = { - function() - vim.lsp.buf.hover() - end, - desc = "Hover symbol details", - cond = "textDocument/hover", - }, - gl = { - function() - vim.diagnostic.open_float() - end, - desc = "Hover diagnostics", - }, - -- a `cond` key can provided as the string of a server capability to be required to attach, or a function with `client` and `bufnr` parameters from the `on_attach` that returns a boolean - gD = { - function() - vim.lsp.buf.declaration() - end, - desc = "Declaration of current symbol", - cond = "textDocument/declaration", - }, - ["uY"] = { - function() - require("astrolsp.toggles").buffer_semantic_tokens() - end, - desc = "Toggle LSP semantic highlight (buffer)", - cond = function(client) - return client.server_capabilities.semanticTokensProvider and vim.lsp.semantic_tokens - end, - }, - }, - }, - -- A custom `on_attach` function to be run after the default `on_attach` function - -- takes two parameters `client` and `bufnr` (`:h lspconfig-setup`) - on_attach = function(client, bufnr) - -- this would disable semanticTokensProvider for all clients - -- client.server_capabilities.semanticTokensProvider = nil - -- Disable ruff_lsp hover in favor of pyright - if client.name == "ruff_lsp" then - client.server_capabilities.hoverProvider = false - end + -- the key is the server that is being setup with `lspconfig` + -- rust_analyzer = false, -- setting a handler to false will disable the set up of that language server + -- pyright = function(_, opts) require("lspconfig").pyright.setup(opts) end -- or a custom handler function can be passed + }, + -- Configure buffer local auto commands to add when attaching a language server + autocmds = { + -- first key is the `augroup` to add the auto commands to (:h augroup) + lsp_document_highlight = { + -- Optional condition to create/delete auto command group + -- can either be a string of a client capability or a function of `fun(client, bufnr): boolean` + -- condition will be resolved for each client on each execution and if it ever fails for all clients, + -- the auto commands will be deleted for that buffer + cond = "textDocument/documentHighlight", + -- cond = function(client, bufnr) return client.name == "lua_ls" end, + -- list of auto commands to set + { + -- events to trigger + event = { "CursorHold", "CursorHoldI" }, + -- the rest of the autocmd options (:h nvim_create_autocmd) + desc = "Document Highlighting", + callback = function() + vim.lsp.buf.document_highlight() + end, + }, + { + event = { "CursorMoved", "CursorMovedI", "BufLeave" }, + desc = "Document Highlighting Clear", + callback = function() + vim.lsp.buf.clear_references() + end, + }, + }, + -- disable inlay hints in insert mode + disable_inlay_hints_on_insert = { + -- only create for language servers that support inlay hints + -- (and only if vim.lsp.inlay_hint is available) + cond = vim.lsp.inlay_hint and "textDocument/inlayHint" or false, + { + -- when going into insert mode + event = "InsertEnter", + desc = "disable inlay hints on insert", + callback = function(args) + local filter = { bufnr = args.buf } + -- if the inlay hints are currently enabled + if vim.lsp.inlay_hint.is_enabled(filter) then + -- disable the inlay hints + vim.lsp.inlay_hint.enable(false, filter) + -- create a single use autocommand to turn the inlay hints back on + -- when leaving insert mode + vim.api.nvim_create_autocmd("InsertLeave", { + buffer = args.buf, + once = true, + callback = function() + vim.lsp.inlay_hint.enable(true, filter) + end, + }) + end + end, + }, + }, + }, + -- mappings to be set up on attaching of a language server + mappings = { + n = { + gh = { + function() + vim.lsp.buf.hover() + end, + desc = "Hover symbol details", + cond = "textDocument/hover", + }, + gl = { + function() + vim.diagnostic.open_float() + end, + desc = "Hover diagnostics", + }, + -- a `cond` key can provided as the string of a server capability to be required to attach, or a function with `client` and `bufnr` parameters from the `on_attach` that returns a boolean + gD = { + function() + vim.lsp.buf.declaration() + end, + desc = "Declaration of current symbol", + cond = "textDocument/declaration", + }, + ["uY"] = { + function() + require("astrolsp.toggles").buffer_semantic_tokens() + end, + desc = "Toggle LSP semantic highlight (buffer)", + cond = function(client) + return client.server_capabilities.semanticTokensProvider and vim.lsp.semantic_tokens + end, + }, + }, + }, + -- A custom `on_attach` function to be run after the default `on_attach` function + -- takes two parameters `client` and `bufnr` (`:h lspconfig-setup`) + on_attach = function(client, bufnr) + -- this would disable semanticTokensProvider for all clients + -- client.server_capabilities.semanticTokensProvider = nil + -- Disable ruff_lsp hover in favor of pyright + if client.name == "ruff_lsp" then + client.server_capabilities.hoverProvider = false + end - -- Disable completion feature of pyright - if client.name == "basedpyright" then - client.server_capabilities.completionProvider = false - end - end, - }, + -- Disable completion feature of pyright + if client.name == "basedpyright" then + client.server_capabilities.completionProvider = false + end + end, + }, } diff --git a/lua/plugins/colorschemes.lua b/lua/plugins/colorschemes.lua index bffcc5f..7f3a841 100644 --- a/lua/plugins/colorschemes.lua +++ b/lua/plugins/colorschemes.lua @@ -62,33 +62,6 @@ return { }, }, - { - "scottmckendry/cyberdream.nvim", - opts = { - transparent = true, - italic_comments = true, - hide_fillchars = true, - borderless_telescope = false, - terminal_colors = false, - integrations = { rainbow_delimiters = true }, - }, - }, - - { - "loctvl842/monokai-pro.nvim", - opts = { - terminal_colors = true, - devicons = true, -- highlight the icons of `nvim-web-devicons` - filter = "pro", -- classic | octagon | pro | machine | ristretto | spectrum - plugins = { - indent_blankline = { - context_highlight = "pro", -- default | pro - context_start_underline = false, - }, - }, - }, - }, - -- Using lazy.nvim { "ribru17/bamboo.nvim", diff --git a/lua/plugins/configs/ui/highlights.lua b/lua/plugins/configs/ui/highlights.lua index 3f84973..a21b1ab 100644 --- a/lua/plugins/configs/ui/highlights.lua +++ b/lua/plugins/configs/ui/highlights.lua @@ -1,8 +1,8 @@ return { init = function() -- this table overrides highlights in all themes local get_hlgroup = require("astroui").get_hlgroup - local ui = require "astroui" - local utils = require "astrocore" + local ui = require("astroui") + local utils = require("astrocore") local hl = { -- remove background of virtual texts diff --git a/lua/plugins/disabled.lua b/lua/plugins/disabled.lua index f9ce569..890ebbb 100644 --- a/lua/plugins/disabled.lua +++ b/lua/plugins/disabled.lua @@ -1,46 +1,55 @@ -- Plugins to disable return { - { "s1n7ax/nvim-window-picker", enabled = false }, - { "akinsho/toggleterm.nvim", enabled = false }, - { "NvChad/nvim-colorizer.lua", enabled = false }, - { "catppuccin/nvim", name = "catppuccin", enabled = false }, - { "rebelot/kanagawa.nvim", enabled = false }, - { "folke/tokyonight.nvim", enabled = false }, - { "f4z3r/gruvbox-material.nvim", name = "gruvbox-material", enabled = false }, - { "b0o/SchemaStore.nvim", enabled = false }, - { "ray-x/lsp_signature.nvim", enabled = false }, - { "kmontocam/nvim-conda", enabled = false }, - { "NMAC427/guess-indent.nvim", enabled = false }, - { "lukas-reineke/indent-blankline.nvim", enabled = false }, - { "AstroNvim/astrotheme", enabled = false }, - { "scottmckendry/cyberdream.nvim", enabled = false }, - { "xiyaowong/transparent.nvim", enabled = false }, - { "loctvl842/monokai-pro.nvim", enabled = false }, - { "xiyaowong/transparent.nvim", enabled = false }, - { "iamcco/markdown-preview.nvim", enabled = false }, - { "max397574/better-escape.nvim", enabled = false }, - { "hinell/duplicate.nvim", enabled = false }, - { "CRAG666/code_runner.nvim", enabled = false }, - { "RRethy/vim-illuminate", enabled = false }, - { "OXY2DEV/markview.nvim", enabled = false }, - { "kevinhwang91/nvim-ufo", enabled = false }, + { "s1n7ax/nvim-window-picker", enabled = false }, + { "akinsho/toggleterm.nvim", enabled = false }, + { "NvChad/nvim-colorizer.lua", enabled = false }, + { "catppuccin/nvim", name = "catppuccin", enabled = false }, + { "rebelot/kanagawa.nvim", enabled = false }, + { "folke/tokyonight.nvim", enabled = false }, + { "f4z3r/gruvbox-material.nvim", name = "gruvbox-material", enabled = false }, + { "b0o/SchemaStore.nvim", enabled = false }, + { "ray-x/lsp_signature.nvim", enabled = false }, + { "kmontocam/nvim-conda", enabled = false }, + { "NMAC427/guess-indent.nvim", enabled = false }, + { "lukas-reineke/indent-blankline.nvim", enabled = false }, + { "AstroNvim/astrotheme", enabled = false }, + { "scottmckendry/cyberdream.nvim", enabled = false }, + { "xiyaowong/transparent.nvim", enabled = false }, + { "loctvl842/monokai-pro.nvim", enabled = false }, + { "xiyaowong/transparent.nvim", enabled = false }, + { "iamcco/markdown-preview.nvim", enabled = false }, + { "max397574/better-escape.nvim", enabled = false }, + { "hinell/duplicate.nvim", enabled = false }, + { "CRAG666/code_runner.nvim", enabled = false }, + { "RRethy/vim-illuminate", enabled = false }, + { "OXY2DEV/markview.nvim", enabled = false }, + { "kevinhwang91/nvim-ufo", enabled = false }, + { "echasnovski/mini.bufremove", enabled = false }, - -- interface - -- { "HiPhish/rainbow-delimiters.nvim", enabled = true }, - { "ribru17/bamboo.nvim", enabled = true }, + -- System + { "nvim-treesitter/nvim-treesitter-textobjects", enabled = false }, + -- Disable Dap + { "mfussenegger/nvim-dap", enabled = false }, + { "theHamsta/nvim-dap-virtual-text", enabled = false }, + { "rcarriga/nvim-dap-ui", enabled = false }, + { "jay-babu/mason-nvim-dap.nvim", enabled = false }, - -- service - { "stevearc/resession.nvim", enabled = true }, - { "echasnovski/mini.move", enabled = true }, - { "nvim-neo-tree/neo-tree.nvim", enabled = true }, - { "folke/flash.nvim", enabled = true }, - { "github/copilot.vim", enabled = true }, + -- interface + -- { "HiPhish/rainbow-delimiters.nvim", enabled = true }, + { "ribru17/bamboo.nvim", enabled = true }, - { "rafamadriz/friendly-snippets", enabled = false }, - { "JoosepAlviste/nvim-ts-context-commentstring", enabled = false }, - { "windwp/nvim-ts-autotag", enabled = false }, - { "saadparwaiz1/cmp_luasnip", enabled = false }, - { "L3MON4D3/LuaSnip", enabled = true }, + -- service + { "stevearc/resession.nvim", enabled = true }, + { "echasnovski/mini.move", enabled = true }, + { "nvim-neo-tree/neo-tree.nvim", enabled = true }, + { "folke/flash.nvim", enabled = true }, + { "github/copilot.vim", enabled = true }, + + { "rafamadriz/friendly-snippets", enabled = false }, + { "JoosepAlviste/nvim-ts-context-commentstring", enabled = false }, + { "windwp/nvim-ts-autotag", enabled = false }, + { "saadparwaiz1/cmp_luasnip", enabled = false }, + { "L3MON4D3/LuaSnip", enabled = true }, } -- if true then return {} end diff --git a/lua/plugins/editor.lua b/lua/plugins/editor.lua index 751e28a..22ee2d4 100644 --- a/lua/plugins/editor.lua +++ b/lua/plugins/editor.lua @@ -250,17 +250,4 @@ return { -- }, -- }, -- Markdown preview support - { - "OXY2DEV/markview.nvim", - dependencies = { - { - "nvim-treesitter/nvim-treesitter", - opts = function(_, opts) - opts.ensure_installed = - require("astrocore").list_insert_unique(opts.ensure_installed, { "markdown", "markdown_inline" }) - end, - }, - }, - ft = { "markdown" }, - }, } diff --git a/lua/plugins/nvim-context-vt.lua b/lua/plugins/nvim-context-vt.lua new file mode 100644 index 0000000..c1e30e3 --- /dev/null +++ b/lua/plugins/nvim-context-vt.lua @@ -0,0 +1,22 @@ +---@type LazySpec +return { + "andersevenrud/nvim_context_vt", + event = "User AstroFile", + cmd = { "NvimContextVtToggle" }, + dependencies = { + "AstroNvim/astrocore", + ---@type AstroCoreOpts + opts = { + mappings = { + n = { + ["uv"] = { + function() + require("nvim_context_vt").toggle() + end, + desc = "Toggle virutal text context", + }, + }, + }, + }, + }, +} diff --git a/lua/plugins/nvim-context.lua b/lua/plugins/nvim-context.lua new file mode 100644 index 0000000..fae37b6 --- /dev/null +++ b/lua/plugins/nvim-context.lua @@ -0,0 +1,28 @@ +---@type LazySpec +return { + "nvim-treesitter/nvim-treesitter-context", + event = "User AstroFile", + cmd = { "TSContext" }, + opts = { + -- không có option trực tiếp cho border, nên ta set highlight ở đây + on_attach = function() + vim.api.nvim_set_hl(0, "TreesitterContext", { underline = true, sp = "Red", bg = "#1e1e3f" }) + end, + max_lines = 2, -- 0 means no limit + + }, + dependencies = { + "AstroNvim/astrocore", + ---@type AstroCoreOpts + opts = { + mappings = { + n = { + ["uT"] = { + "TSContext toggle", + desc = "Toggle treesitter context", + }, + }, + }, + }, + }, +} diff --git a/lua/plugins/ui.lua b/lua/plugins/ui.lua index 318d16e..b1de2dc 100644 --- a/lua/plugins/ui.lua +++ b/lua/plugins/ui.lua @@ -38,39 +38,39 @@ return { -- { "uT", "TransparentToggle", desc = "Toggle transparent" }, -- }, -- }, - { - { - "HiPhish/rainbow-delimiters.nvim", - dependencies = { - "nvim-treesitter/nvim-treesitter", - { - "AstroNvim/astrocore", - opts = { - mappings = { - n = { - ["u("] = { - function() - local bufnr = vim.api.nvim_get_current_buf() - require("rainbow-delimiters").toggle(bufnr) - require("astrocore").notify( - string.format( - "Buffer rainbow delimeters %s", - require("rainbow-delimiters").is_enabled(bufnr) and "on" or "off" - ) - ) - end, - desc = "Toggle rainbow delimeters (buffer)", - }, - }, - }, - }, - }, - }, - event = "User AstroFile", - main = "rainbow-delimiters.setup", - opts = {}, - }, - }, + -- { + -- { + -- "HiPhish/rainbow-delimiters.nvim", + -- dependencies = { + -- "nvim-treesitter/nvim-treesitter", + -- { + -- "AstroNvim/astrocore", + -- opts = { + -- mappings = { + -- n = { + -- ["u("] = { + -- function() + -- local bufnr = vim.api.nvim_get_current_buf() + -- require("rainbow-delimiters").toggle(bufnr) + -- require("astrocore").notify( + -- string.format( + -- "Buffer rainbow delimeters %s", + -- require("rainbow-delimiters").is_enabled(bufnr) and "on" or "off" + -- ) + -- ) + -- end, + -- desc = "Toggle rainbow delimeters (buffer)", + -- }, + -- }, + -- }, + -- }, + -- }, + -- }, + -- event = "User AstroFile", + -- main = "rainbow-delimiters.setup", + -- opts = {}, + -- }, + -- }, { "folke/todo-comments.nvim", dependencies = { "nvim-lua/plenary.nvim" }, @@ -108,7 +108,9 @@ return { -- disable in comments -- https://github.com/altermo/ultimate-autopair.nvim/blob/6fd0d6aa976a97dd6f1bed4d46be1b437613a52f/Q%26A.md?plain=1#L26 cond = { - function(fn) return not fn.in_node "comment" end, + function(fn) + return not fn.in_node("comment") + end, }, }, -- get fly mode working on strings: @@ -136,14 +138,21 @@ return { desc = "Toggle Ultimate Autopair", function() local notify = require("astrocore").notify - local function bool2str(bool) return bool and "on" or "off" end + local function bool2str(bool) + return bool and "on" or "off" + end local ok, ultimate_autopair = pcall(require, "ultimate-autopair") if ok then ultimate_autopair.toggle() vim.g.ultimate_autopair_enabled = require("ultimate-autopair.core").disable - notify(string.format("ultimate-autopair %s", bool2str(not vim.g.ultimate_autopair_enabled))) + notify( + string.format( + "ultimate-autopair %s", + bool2str(not vim.g.ultimate_autopair_enabled) + ) + ) else - notify "ultimate-autopair not available" + notify("ultimate-autopair not available") end end, },