diff --git a/README.md b/README.md index 10e70a3..576e998 100644 --- a/README.md +++ b/README.md @@ -17,4 +17,26 @@ sudo apt-get install neovim ## 文件结构 ``` +. +├── init.lua +├── install.sh +├── lua +│   ├── Filetype +│   │   ├── c.lua +│   │   ├── markdown.lua +│   │   └── vue.lua +│   ├── G.lua +│   ├── normal +│   │   ├── keymap.lua +│   │   ├── normal.lua +│   │   ├── options.lua +│   │   └── plug.lua +│   └── Plugin +│   ├── coc.lua +│   ├── coc-settings.json +│   ├── Imchange.lua +│   ├── lualine.lua +│   ├── NERDTree.lua +│   └── treesitter.lua +└── README.md ``` diff --git a/init.lua b/init.lua index d053fce..dc8926c 100644 --- a/init.lua +++ b/init.lua @@ -1,4 +1,28 @@ -require ('normal.normal') +local G = require('G') + +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) + + +if vim.g.vscode then + require('Plugin.Imchange') +else + require('neovim.neovim') +end + +require('normal.normal') + -- require('vscode') -- require('Plugin.coc') diff --git a/lua/Filetype/c.lua b/lua/Filetype/c.lua deleted file mode 100644 index e69de29..0000000 diff --git a/lua/Filetype/markdown.lua b/lua/Filetype/markdown.lua deleted file mode 100644 index 83108f2..0000000 --- a/lua/Filetype/markdown.lua +++ /dev/null @@ -1,105 +0,0 @@ -local G = require("G") - -G.cmd("au VimEnter * :MarkdownPreviewToggle") - ---set to 1, nvim will open the preview window after entering the markdown buffer ---default: 0 -G.g.mkdp_auto_start = 1 - ---set to 1, the nvim will auto close current preview window when change ---from markdown buffer to another buffer ---default: 1 -G.g.mkdp_auto_close = 1 - ---set to 1, the vim will refresh markdown when save the buffer or ---leave from insert mode, default 0 is auto refresh markdown as you edit or ---move the cursor ---default: 0 -G.g.mkdp_refresh_slow = 0 - ---set to 1, the MarkdownPreview command can be use for all files, ---by default it can be use in markdown file ---default: 0 -G.g.mkdp_command_for_global = 0 - ---set to 1, preview server available to others in your network ---by default, the server listens on localhost (127.0.0.1) ---default: 0 -G.g.mkdp_open_to_the_world = 0 - ---use custom IP to open preview page ---useful when you work in remote vim and preview on local browser ---more detail see: https://github.com/iamcco/markdown-preview.nvim/pull/9 ---default empty -G.g.mkdp_open_ip = '' - ---specify browser to open preview page ---for path with space ---valid: `/path/with\ space/xxx` ---invalid: `/path/with\\ space/xxx` ---default: '' -G.g.mkdp_browser = 'wyeb' - ---set to 1, echo preview page url in command line when open preview page ---default is 0 -G.g.mkdp_echo_preview_url = 0 - ---a custom vim function name to open preview page ---this function will receive url as param ---default is empty -G.g.mkdp_browserfunc = '' - ---options for markdown render ---mkit: markdown-it options for render ---katex: katex options for math ---uml: markdown-it-plantuml options ---maid: mermaid options ---disable_sync_scroll: if disable sync scroll, default 0 ---sync_scroll_type: 'middle', 'top' or 'relative', default value is 'middle' --- middle: mean the cursor position alway show at the middle of the preview page --- top: mean the vim top viewport alway show at the top of the preview page --- relative: mean the cursor position alway show at the relative positon of the preview page ---hide_yaml_meta: if hide yaml metadata, default is 1 ---sequence_diagrams: js-sequence-diagrams options ---content_editable: if enable content editable for preview page, default: v:false ---disable_filename: if disable filename header for preview page, default: 0 - ---G.cmd([[ --- let g:mkdp_preview_options = { --- \'mkit': {}, --- \'katex': {}, --- \'uml': {}, --- \'maid': {}, --- \'disable_sync_scroll': 0, --- \'sync_scroll_type': 'middle', --- \'hide_yaml_meta': 1, --- \'sequence_diagrams': {}, --- \'flowchart_diagrams': {}, --- \'content_editable': v:false, --- \'disable_filename': 0, --- \'toc': {} --- \} --- ]]) ---use a custom markdown style must be absolute path ---like '/Users/username/markdown.css' or expand('~/markdown.css') - -G.g.mkdp_markdown_css = '' - ---use a custom highlight style must absolute path ---like '/Users/username/highlight.css' or expand('~/highlight.css') -G.g.mkdp_highlight_css = '' - ---use a custom port to start server or empty for random -G.g.mkdp_port = '12345' - ---preview page title ---${name} will be replace with the file name -G.g.mkdp_page_title = '「${name}」' - ---recognized filetypes ---these filetypes will have MarkdownPreview... commands -G.g.mkdp_filetypes = {'markdown'} - ---set default theme (dark or light) ---By default the theme is define according to the preferences of the system -G.g.mkdp_theme = 'dark' diff --git a/lua/Filetype/vue.lua b/lua/Filetype/vue.lua deleted file mode 100644 index d3c76ab..0000000 --- a/lua/Filetype/vue.lua +++ /dev/null @@ -1 +0,0 @@ -require('Plugin.ale') diff --git a/lua/Plugin/coc-settings.json b/lua/Plugin/coc-settings.json deleted file mode 100644 index 954df77..0000000 --- a/lua/Plugin/coc-settings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "snippets.ultisnips.pythonPrompt": false, - "explorer.icon.enableNerdfont": true, - "explorer.toggle": true, - "outline.autoWidth": true, - "outline.autoPreview": true, - "data.home": "~", -} diff --git a/lua/Plugin/coc.lua b/lua/Plugin/coc.lua deleted file mode 100644 index b62f79a..0000000 --- a/lua/Plugin/coc.lua +++ /dev/null @@ -1,139 +0,0 @@ -local G = require('G') - -G.g.coc_user_config = G.fn.stdpath('config') .. 'lua/Plugin/coc-settings.json' - -G.g['coc_global_extensions'] = { - "coc-clangd", - "coc-python", - "coc-lua", - "coc-json", - - "coc-translator", - "coc-yank", - "coc-pairs", -} - --- Having longer updatetime (default is 4000 ms = 4s) leads to noticeable --- delays and poor user experience -G.opt.updatetime = 300 - --- Always show the signcolumn, otherwise it would shift the text each time --- diagnostics appeared/became resolved -G.opt.signcolumn = "yes" - -local keyset = vim.keymap.set --- Autocomplete -function _G.check_back_leader() - local col = G.fn.col('.') - 1 - return col == 0 or G.fn.getline('.'):sub(col, col):match('%s') ~= nil -end - --- Use Tab for trigger completion with characters ahead and navigate --- NOTE: There's always a completion item selected by default, you may want to enable --- no select by setting `"suggest.noselect": true` in your configuration file --- NOTE: Use command ':verbose imap ' to make sure Tab is not mapped by --- other plugins before putting this into your config -local opts = {silent = true, noremap = true, expr = true, replace_keycodes = false} -keyset("i", "", 'coc#pum#visible() ? coc#pum#next(1) : v:lua.check_back_leader() ? "" : coc#refresh()', opts) -keyset("i", "", [[coc#pum#visible() ? coc#pum#prev(1) : "\"]], opts) - --- Make to accept selected completion item or notify coc.nvim to format --- u breaks current undo, please make your own choice -keyset("i", "", [[coc#pum#visible() ? coc#pum#confirm() : "\u\\=coc#on_enter()\"]], opts) - --- Use `[g` and `]g` to navigate diagnostics --- Use `:CocDiagnostics` to get all diagnostics of current buffer in location list -keyset("n", "[g", "(coc-diagnostic-prev)", {silent = true}) -keyset("n", "]g", "(coc-diagnostic-next)", {silent = true}) - --- GoTo code navigation -keyset("n", "gd", "(coc-definition)", {silent = true}) -keyset("n", "gy", "(coc-type-definition)", {silent = true}) -keyset("n", "gi", "(coc-implementation)", {silent = true}) -keyset("n", "gr", "(coc-references)", {silent = true}) - --- Symbol renaming -keyset("n", "rn", "(coc-rename)", {silent = true}) - --- Formatting selected code -keyset("x", "i", "(coc-format-selected)", {silent = true}) -keyset("n", "i", "(coc-format-selected)", {silent = true}) - --- Apply codeAction to the selected region --- Example: `aap` for current paragraph -local opts = {silent = true, nowait = true} - --- Map function and class text objects --- NOTE: Requires 'textDocument.documentSymbol' support from the language server -keyset("x", "if", "(coc-funcobj-i)", opts) -keyset("o", "if", "(coc-funcobj-i)", opts) -keyset("x", "af", "(coc-funcobj-a)", opts) -keyset("o", "af", "(coc-funcobj-a)", opts) -keyset("x", "ic", "(coc-classobj-i)", opts) -keyset("o", "ic", "(coc-classobj-i)", opts) -keyset("x", "ac", "(coc-classobj-a)", opts) -keyset("o", "ac", "(coc-classobj-a)", opts) - --- translator -keyset("n", "tt", "(coc-translator-p)") -keyset("v", "tt", "(coc-translator-pv)") - --- translator-releader -keyset("n", "tr", "(coc-translator-r)") -keyset("v", "tr", "(coc-translator-rv)") -keyset("n", "ol", ":CocOutline") - - --- Highlight the symbol and its references on a CursorHold event(cursor is idle) -G.api.nvim_create_augroup("CocGroup", {}) -G.api.nvim_create_autocmd("CursorHold", { - group = "CocGroup", - command = "silent call CocActionAsync('highlight')", - desc = "Highlight symbol under cursor on CursorHold" -}) - --- Setup formatexpr specified filetype(s) -G.api.nvim_create_autocmd("FileType", { - group = "CocGroup", - pattern = "typescript,json", - command = "setl formatexpr=CocAction('formatSelected')", - desc = "Setup formatexpr specified filetype(s)." -}) - --- Update signature help on jump placeholder -G.api.nvim_create_autocmd("User", { - group = "CocGroup", - pattern = "CocJumpPlaceholder", - command = "call CocActionAsync('showSignatureHelp')", - desc = "Update signature help on jump placeholder" -}) - --- Remap and to scroll float windows/popups ----@diagnostic disable-next-line: redefined-local -local opts = {silent = true, nowait = true, expr = true} -keyset("n", "", 'coc#float#has_scroll() ? coc#float#scroll(1) : ""', opts) -keyset("n", "", 'coc#float#has_scroll() ? coc#float#scroll(0) : ""', opts) -keyset("i", "", - 'coc#float#has_scroll() ? "=coc#float#scroll(1)" : ""', opts) -keyset("i", "", - 'coc#float#has_scroll() ? "=coc#float#scroll(0)" : ""', opts) -keyset("v", "", 'coc#float#has_scroll() ? coc#float#scroll(1) : ""', opts) -keyset("v", "", 'coc#float#has_scroll() ? coc#float#scroll(0) : ""', opts) - --- Add `:Format` command to format current buffer -G.api.nvim_create_user_command("Format", "call CocAction('format')", {}) - --- " Add `:Fold` command to fold current buffer -G.api.nvim_create_user_command("Fold", "call CocAction('fold', )", {nargs = '?'}) - --- Add `:OR` command for organize imports of the current buffer -G.api.nvim_create_user_command("OR", "call CocActionAsync('runCommand', 'editor.action.organizeImport')", {}) - --- Add (Neo)Vim's native statusline support --- NOTE: Please see `:h coc-status` for integrations with external plugins that --- provide custom statusline: lightline.vim, vim-airline -G.opt.statusline:prepend("%{coc#status()}%{get(b:,'coc_current_function','')}") - - - - diff --git a/lua/neovim/keymap.lua b/lua/neovim/keymap.lua new file mode 100644 index 0000000..221d3c6 --- /dev/null +++ b/lua/neovim/keymap.lua @@ -0,0 +1,6 @@ +local G, opt = require('G'), {noremap = true} + +--NvimTree +G.map({ + {"n", "", ":NERDTreeToggle", opt}, +}) diff --git a/lua/neovim/neovim.lua b/lua/neovim/neovim.lua new file mode 100644 index 0000000..94609b3 --- /dev/null +++ b/lua/neovim/neovim.lua @@ -0,0 +1,3 @@ +require('neovim.plugsettings.plug') + +require('neovim.keymap') diff --git a/lua/neovim/plugsettings/plug.lua b/lua/neovim/plugsettings/plug.lua new file mode 100644 index 0000000..0a77e39 --- /dev/null +++ b/lua/neovim/plugsettings/plug.lua @@ -0,0 +1,21 @@ +require("lazy").setup({ + + -- nerdtree + { + 'preservim/nerdtree', + dependencies = { + 'Xuyuanp/nerdtree-git-plugin', + 'ryanoasis/vim-devicons', + }, + cmd = 'NERDTreeToggle', + }, + + --颜色识别 + { + 'lilydjwg/colorizer', + }, + + -- 语法高亮 + 'nvim-treesitter/nvim-treesitter', + +}) diff --git a/lua/normal/keymap.lua b/lua/normal/keymap.lua index 306def5..90ee7c7 100644 --- a/lua/normal/keymap.lua +++ b/lua/normal/keymap.lua @@ -1,4 +1,3 @@ - local G, opt = require('G'), {noremap = true} -- base @@ -56,11 +55,6 @@ G.map({ {"v", "ga", ":EasyAlign", opt}, }) ---NvimTree -G.map({ - {"n", "", ":NERDTreeToggle", opt}, -}) - diff --git a/lua/normal/normal.lua b/lua/normal/normal.lua index 92e0295..5a9e3aa 100644 --- a/lua/normal/normal.lua +++ b/lua/normal/normal.lua @@ -1,4 +1,6 @@ -require('normal.plug') +require('normal.plugsettings.plug') + require('normal.keymap') require('normal.options') + diff --git a/lua/normal/plug.lua b/lua/normal/plugsettings/plug.lua similarity index 53% rename from lua/normal/plug.lua rename to lua/normal/plugsettings/plug.lua index b3f40e2..910ff9c 100644 --- a/lua/normal/plug.lua +++ b/lua/normal/plugsettings/plug.lua @@ -1,24 +1,6 @@ - -local G = require('G') - -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) - -- Example using a list of specs with the default options require("lazy").setup({ -lockfile = false, -- 主题插件 'nvim-lualine/lualine.nvim', @@ -26,10 +8,6 @@ lockfile = false, 'shaunsingh/nord.nvim', 'yaocccc/nvim-hlchunk', - -- lsp 补全以及语法高亮 - -- {'neoclide/coc.nvim', branch = 'release'}, - -- 'nvim-treesitter/nvim-treesitter', - -- surround 和 wildfire 配合有神奇的效果 'tpope/vim-surround', 'gcmt/wildfire.vim', @@ -38,41 +16,18 @@ lockfile = false, 'junegunn/vim-easy-align', 'tpope/vim-commentary', - --颜色识别 - 'lilydjwg/colorizer', - - --markdown - { - 'iamcco/markdown-preview.nvim', - ft = { - 'markdown', - } - }, - - -- 文件搜索 - -- 'junegunn/fzf', - -- 多光标 - -- 'terryma/vim-multiple-cursors', - - -- github copilot - -- 'github/copilot.vim', + 'terryma/vim-multiple-cursors', -- fzf 'vijaymarupudi/nvim-fzf', - -- nerdtree - { - 'preservim/nerdtree', - dependencies = { - 'Xuyuanp/nerdtree-git-plugin', - 'ryanoasis/vim-devicons', - }, - cmd = 'NERDTreeToggle', - }, - -- 项目管理 - -- { + + -- github copilot + -- 'github/copilot.vim', + + -- 项目管理 { -- 'Shatur/neovim-session-manager', -- dependencies = { -- 'nvim-lua/plenary.nvim' @@ -89,6 +44,8 @@ lockfile = false, -- end, -- dependencies = { {'nvim-tree/nvim-web-devicons'}} -- } + -- lsp 补全以及语法高亮 + -- {'neoclide/coc.nvim', branch = 'release'}, })