From c1541c6e2e959d43254dd000ace092ef060a21a0 Mon Sep 17 00:00:00 2001 From: QQ Date: Sun, 1 Oct 2023 17:18:36 +0800 Subject: [PATCH] update --- lua/Plugin/Imchange.lua | 42 ------------------- lua/Plugin/NERDTree.lua | 1 - lua/Plugin/lualine.lua | 40 ------------------ lua/Plugin/treesitter.lua | 54 ------------------------ lua/neovim/neovim.lua | 2 +- lua/neovim/plug.lua | 31 ++++++++++++++ lua/neovim/plugsettings/lspconfig.lua | 3 ++ lua/neovim/plugsettings/lualine.lua | 45 ++++++++++++++++++++ lua/neovim/plugsettings/nvimtree.lua | 2 + lua/neovim/plugsettings/plug.lua | 34 --------------- lua/neovim/plugsettings/treesitter.lua | 58 ++++++++++++++++++++++++++ lua/normal/keymap.lua | 2 +- lua/normal/normal.lua | 2 - lua/normal/{plugsettings => }/plug.lua | 6 +-- lua/plugsettings.lua | 25 +++++++++++ lua/vscode/keymap.lua | 6 +++ lua/vscode/{plugsettings => }/plug.lua | 0 17 files changed, 174 insertions(+), 179 deletions(-) delete mode 100644 lua/Plugin/Imchange.lua delete mode 100644 lua/Plugin/NERDTree.lua delete mode 100644 lua/Plugin/lualine.lua delete mode 100644 lua/Plugin/treesitter.lua create mode 100644 lua/neovim/plug.lua create mode 100644 lua/neovim/plugsettings/lspconfig.lua create mode 100644 lua/neovim/plugsettings/lualine.lua create mode 100644 lua/neovim/plugsettings/nvimtree.lua delete mode 100644 lua/neovim/plugsettings/plug.lua create mode 100644 lua/neovim/plugsettings/treesitter.lua rename lua/normal/{plugsettings => }/plug.lua (89%) create mode 100644 lua/plugsettings.lua rename lua/vscode/{plugsettings => }/plug.lua (100%) diff --git a/lua/Plugin/Imchange.lua b/lua/Plugin/Imchange.lua deleted file mode 100644 index 2cd78b1..0000000 --- a/lua/Plugin/Imchange.lua +++ /dev/null @@ -1,42 +0,0 @@ -if package.config:sub(1,1) == "\\" then - return -end - -local G, im = require("G"), "keyboard-us" - -function InsertLeave() - local t = io.popen("fcitx5-remote -n") - im = t:read() - G.cmd(":silent !fcitx5-remote -c") -end - -function InsertEnter() - if im == 'pinyin' - then - G.cmd(":silent !fcitx5-remote -s pinyin") - end -end - -function Is_fcitx5_installed() - local cmd = "fcitx5 -v" - local status = os.execute(cmd) - return (status == 0) -end - -if Is_fcitx5_installed() then -G.api.nvim_create_autocmd( - {"InsertLeave"}, { - pattern = "*", - callback = InsertLeave - } -) - -G.api.nvim_create_autocmd( - {"InsertEnter"}, { - pattern = "*", - callback = InsertEnter - } -) -end - - diff --git a/lua/Plugin/NERDTree.lua b/lua/Plugin/NERDTree.lua deleted file mode 100644 index 8b13789..0000000 --- a/lua/Plugin/NERDTree.lua +++ /dev/null @@ -1 +0,0 @@ - diff --git a/lua/Plugin/lualine.lua b/lua/Plugin/lualine.lua deleted file mode 100644 index 56c426a..0000000 --- a/lua/Plugin/lualine.lua +++ /dev/null @@ -1,40 +0,0 @@ -require('lualine').setup { - options = { - icons_enabled = true, - theme = 'auto', - component_separators = { left = '', right = ''}, - section_separators = { left = '', right = ''}, - disabled_filetypes = { - statusline = {}, - winbar = {}, - }, - ignore_focus = {}, - always_divide_middle = true, - globalstatus = false, - refresh = { - statusline = 1000, - tabline = 1000, - winbar = 1000, - } - }, - sections = { - lualine_a = {'mode'}, - lualine_b = {'branch', 'diff', 'diagnostics'}, - lualine_c = {'filename'}, - lualine_x = {'encoding', 'fileformat', 'filetype'}, - lualine_y = {'progress'}, - lualine_z = {'location'} - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = {'filename'}, - lualine_x = {'location'}, - lualine_y = {}, - lualine_z = {} - }, - tabline = {}, - winbar = {}, - inactive_winbar = {}, - extensions = {} -} diff --git a/lua/Plugin/treesitter.lua b/lua/Plugin/treesitter.lua deleted file mode 100644 index caed80d..0000000 --- a/lua/Plugin/treesitter.lua +++ /dev/null @@ -1,54 +0,0 @@ -local G = require("G") -require'nvim-treesitter.configs'.setup { - -- A list of parser names, or "all" (the four listed parsers should always be installed) - ensure_installed = {}, - - indent = { enable = true }, - -- Install parsers synchronously (only applied to `ensure_installed`) - sync_install = false, - - -- Automatically install missing parsers when entering buffer - -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally - auto_install = true, - - -- List of parsers to ignore installing (for "all") - -- ignore_install = { "javascript" }, - - ---- If you need to change the installation directory of the parsers (see -> Advanced Setup) - -- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")! - - highlight = { - -- `false` will disable the whole extension - enable = true, - - -- NOTE: these are the names of the parsers and not the filetype. (for example if you want to - -- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is - -- the name of the parser) - -- list of language that will be disabled - -- disable = { "c", "rust" }, - -- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files - disable = function(lang, buf) - local max_filesize = 100 * 1024 -- 100 KB - local ok, stats = pcall(G.loop.fs_stat, G.api.nvim_buf_get_name(buf)) - if ok and stats and stats.size > max_filesize then - return true - end - end, - - -- Setting this to true will run `:h syntax` and tree-sitter at the same time. - -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). - -- Using this option may slow down your editor, and you may see some duplicate highlights. - -- Instead of true it can also be a list of languages - additional_vim_regex_highlighting = false, - }, - parsers = { - html = { - install_info = { - url = "https://github.com/ikatyang/tree-sitter-vue", - files = {"src/parser.c"}, - branch = "main" - } - } - } -} - diff --git a/lua/neovim/neovim.lua b/lua/neovim/neovim.lua index f446d54..28effcc 100644 --- a/lua/neovim/neovim.lua +++ b/lua/neovim/neovim.lua @@ -1,4 +1,4 @@ -require('neovim.plugsettings.plug') +-- require('neovim.plugsettings.plug') require('neovim.keymap') require('neovim.options') diff --git a/lua/neovim/plug.lua b/lua/neovim/plug.lua new file mode 100644 index 0000000..e317f0b --- /dev/null +++ b/lua/neovim/plug.lua @@ -0,0 +1,31 @@ +return { + + -- github copilot + 'github/copilot.vim', + + 'vijaymarupudi/nvim-fzf', -- fzf + + 'shaunsingh/nord.nvim', -- 主题插件 + + require('neovim.plugsettings.lualine'), -- lualine + require('neovim.plugsettings.nvimtree'), -- nvimtree + require('neovim.plugsettings.lspconfig'), -- lspconfig + require('neovim.plugsettings.treesitter'), -- treesitter + + -- nerdtree + { + 'preservim/nerdtree', + dependencies = { + 'Xuyuanp/nerdtree-git-plugin', + 'ryanoasis/vim-devicons', + }, + cmd = 'NERDTreeToggle', + }, + + --颜色识别 + { + 'lilydjwg/colorizer', + }, + + +} diff --git a/lua/neovim/plugsettings/lspconfig.lua b/lua/neovim/plugsettings/lspconfig.lua new file mode 100644 index 0000000..3a5a3ac --- /dev/null +++ b/lua/neovim/plugsettings/lspconfig.lua @@ -0,0 +1,3 @@ +return { + 'neovim/nvim-lspconfig', +} diff --git a/lua/neovim/plugsettings/lualine.lua b/lua/neovim/plugsettings/lualine.lua new file mode 100644 index 0000000..01ad920 --- /dev/null +++ b/lua/neovim/plugsettings/lualine.lua @@ -0,0 +1,45 @@ +return { + 'nvim-lualine/lualine.nvim', + config = function() + require('lualine').setup { + options = { + icons_enabled = true, + theme = 'auto', + component_separators = { left = '', right = ''}, + section_separators = { left = '', right = ''}, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = true, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + } + }, + sections = { + lualine_a = {'mode'}, + lualine_b = {'branch', 'diff', 'diagnostics'}, + lualine_c = {'filename'}, + lualine_x = {'encoding', 'fileformat', 'filetype'}, + lualine_y = {'progress'}, + lualine_z = {'location'} + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {'filename'}, + lualine_x = {'location'}, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = {} + } + end, +} diff --git a/lua/neovim/plugsettings/nvimtree.lua b/lua/neovim/plugsettings/nvimtree.lua new file mode 100644 index 0000000..97aeadd --- /dev/null +++ b/lua/neovim/plugsettings/nvimtree.lua @@ -0,0 +1,2 @@ +return { +} diff --git a/lua/neovim/plugsettings/plug.lua b/lua/neovim/plugsettings/plug.lua deleted file mode 100644 index 03d7025..0000000 --- a/lua/neovim/plugsettings/plug.lua +++ /dev/null @@ -1,34 +0,0 @@ -require("lazy").setup({ - - -- github copilot - -- 'github/copilot.vim', - - -- fzf - 'vijaymarupudi/nvim-fzf', - - -- lualine - 'nvim-lualine/lualine.nvim', - - -- 主题插件 - 'morhetz/gruvbox', - 'shaunsingh/nord.nvim', - - -- nerdtree - { - 'preservim/nerdtree', - dependencies = { - 'Xuyuanp/nerdtree-git-plugin', - 'ryanoasis/vim-devicons', - }, - cmd = 'NERDTreeToggle', - }, - - --颜色识别 - { - 'lilydjwg/colorizer', - }, - - -- 语法高亮 - 'nvim-treesitter/nvim-treesitter', - -}) diff --git a/lua/neovim/plugsettings/treesitter.lua b/lua/neovim/plugsettings/treesitter.lua new file mode 100644 index 0000000..d8a1fe2 --- /dev/null +++ b/lua/neovim/plugsettings/treesitter.lua @@ -0,0 +1,58 @@ +return { + -- 语法高亮 + 'nvim-treesitter/nvim-treesitter', + config = function() + require'nvim-treesitter.configs'.setup { + -- A list of parser names, or "all" (the four listed parsers should always be installed) + ensure_installed = {}, + + indent = { enable = true }, + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, + + -- Automatically install missing parsers when entering buffer + -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally + auto_install = true, + + -- List of parsers to ignore installing (for "all") + -- ignore_install = { "javascript" }, + + ---- If you need to change the installation directory of the parsers (see -> Advanced Setup) + -- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")! + + highlight = { + -- `false` will disable the whole extension + enable = true, + + -- NOTE: these are the names of the parsers and not the filetype. (for example if you want to + -- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is + -- the name of the parser) + -- list of language that will be disabled + -- disable = { "c", "rust" }, + -- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files + disable = function(lang, buf) + local max_filesize = 100 * 1024 -- 100 KB + local ok, stats = pcall(G.loop.fs_stat, G.api.nvim_buf_get_name(buf)) + if ok and stats and stats.size > max_filesize then + return true + end + end, + + -- Setting this to true will run `:h syntax` and tree-sitter at the same time. + -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). + -- Using this option may slow down your editor, and you may see some duplicate highlights. + -- Instead of true it can also be a list of languages + additional_vim_regex_highlighting = false, + }, + parsers = { + html = { + install_info = { + url = "https://github.com/ikatyang/tree-sitter-vue", + files = {"src/parser.c"}, + branch = "main" + } + } + } + } + end +} diff --git a/lua/normal/keymap.lua b/lua/normal/keymap.lua index 90ee7c7..1aefec1 100644 --- a/lua/normal/keymap.lua +++ b/lua/normal/keymap.lua @@ -1,4 +1,4 @@ -local G, opt = require('G'), {noremap = true} +local opt = {noremap = true} -- base G.map({ diff --git a/lua/normal/normal.lua b/lua/normal/normal.lua index 5a9e3aa..9649f89 100644 --- a/lua/normal/normal.lua +++ b/lua/normal/normal.lua @@ -1,5 +1,3 @@ -require('normal.plugsettings.plug') - require('normal.keymap') require('normal.options') diff --git a/lua/normal/plugsettings/plug.lua b/lua/normal/plug.lua similarity index 89% rename from lua/normal/plugsettings/plug.lua rename to lua/normal/plug.lua index cc2e2a2..317dd43 100644 --- a/lua/normal/plugsettings/plug.lua +++ b/lua/normal/plug.lua @@ -1,6 +1,4 @@ --- Example using a list of specs with the default options - -require("lazy").setup({ +return { -- 括号箭头 'yaocccc/nvim-hlchunk', @@ -40,7 +38,7 @@ require("lazy").setup({ -- lsp 补全以及语法高亮 -- {'neoclide/coc.nvim', branch = 'release'}, -}) +} diff --git a/lua/plugsettings.lua b/lua/plugsettings.lua new file mode 100644 index 0000000..90921a2 --- /dev/null +++ b/lua/plugsettings.lua @@ -0,0 +1,25 @@ +local lazypath = G.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not G.loop.fs_stat(lazypath) then + G.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end + +G.opt.rtp:prepend(lazypath) + +local normalplugs = require('normal.plug') +local vscodeplugs = require('vscode.plug') +local neovimplugs = require('neovim.plug') + +if G.g.vscode then + plugs = {vscodeplugs, normalplugs} +else + plugs = {neovimplugs, normalplugs} +end + +require("lazy").setup(plugs) diff --git a/lua/vscode/keymap.lua b/lua/vscode/keymap.lua index e69de29..bf3906a 100644 --- a/lua/vscode/keymap.lua +++ b/lua/vscode/keymap.lua @@ -0,0 +1,6 @@ +local opt = {noremap = true} + +G.map({ + {'n', 'j', 'gj', opt}, + {'n', 'k', 'gk', opt}, +}) diff --git a/lua/vscode/plugsettings/plug.lua b/lua/vscode/plug.lua similarity index 100% rename from lua/vscode/plugsettings/plug.lua rename to lua/vscode/plug.lua