From fa9018d3b59d4d853cac0f609af28eceb65cb837 Mon Sep 17 00:00:00 2001 From: Yuan Chiu Date: Mon, 28 Apr 2025 20:22:22 +0800 Subject: [PATCH] feat nvim: listchars & o-plugin framework --- dot_config/nvim/lua/config/lazy.lua | 5 ++++- dot_config/nvim/lua/config/listchars.lua | 14 +++++++++++++ dot_config/nvim/lua/config/options.lua | 7 +------ .../nvim/lua/o-plugins/nvim-listchars.lua | 20 +++++++++++++++++++ 4 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 dot_config/nvim/lua/config/listchars.lua create mode 100644 dot_config/nvim/lua/o-plugins/nvim-listchars.lua diff --git a/dot_config/nvim/lua/config/lazy.lua b/dot_config/nvim/lua/config/lazy.lua index 528353b..d017db7 100644 --- a/dot_config/nvim/lua/config/lazy.lua +++ b/dot_config/nvim/lua/config/lazy.lua @@ -24,8 +24,11 @@ vim.opt.rtp:prepend(lazypath) -- Setup lazy.nvim require("lazy").setup({ spec = { - -- import your plugins + -- 自動載入 plugins 資料夾中的所有插件 { import = "plugins" }, + + -- 手動引入 o-plugins 資料夾中的插件 + -- require("o-plugins.nvim-listchars"), }, -- Configure any other settings here. See the documentation for more details. -- colorscheme that will be used when installing plugins. diff --git a/dot_config/nvim/lua/config/listchars.lua b/dot_config/nvim/lua/config/listchars.lua new file mode 100644 index 0000000..d13fa9a --- /dev/null +++ b/dot_config/nvim/lua/config/listchars.lua @@ -0,0 +1,14 @@ +-- vim.opt.listchars = { +-- eol = "¬", +-- tab = "→→", +-- trail = ".", +-- extends = ">", +-- precedes = "<" +-- } + +vim.opt.listchars = { + trail = "-", + eol = "↲", + tab = "» ", + space = "·", +} diff --git a/dot_config/nvim/lua/config/options.lua b/dot_config/nvim/lua/config/options.lua index 25f9a26..36b68e5 100644 --- a/dot_config/nvim/lua/config/options.lua +++ b/dot_config/nvim/lua/config/options.lua @@ -19,12 +19,7 @@ vim.opt.expandtab = true -- 使用空格代替tab vim.opt.termguicolors = true -- 支持真彩色 vim.opt.colorcolumn = "80,120" -- 顯示編輯器建議寬度 vim.opt.scrolloff = 3 -- 捲動時保留 n 行彈性 -vim.opt.listchars = { - eol = "¬", - tab = "→→", - trail = ".", - extends = ">", - precedes = "<" } +require("config.listchars") -- 顯示行尾符號 vim.opt.list = true -- 整行移動的快速鍵 diff --git a/dot_config/nvim/lua/o-plugins/nvim-listchars.lua b/dot_config/nvim/lua/o-plugins/nvim-listchars.lua new file mode 100644 index 0000000..902c357 --- /dev/null +++ b/dot_config/nvim/lua/o-plugins/nvim-listchars.lua @@ -0,0 +1,20 @@ +return { + { + "fraso-dev/nvim-listchars", + opts = true, + event = "BufEnter", + config = function() + require("nvim-listchars").setup({ + save_state = true, -- If enabled, save toggled state in a cache file. Will overwrite current `vim.opt.list` value. + listchars = { -- `listchars` to be displayed. See available options by running `:help listchars` + tab = "> ", + trail = "-", + nbsp = "+", + }, + notifications = true, -- Enable or disable listchars notifications + exclude_filetypes = {}, -- List of filetypes where `listchars` is disabled + lighten_step = 5, -- Amount to add/remove from base color + }) + end, + } +}