From f249120097e66fac328630cabdde4dd9ba44a23b Mon Sep 17 00:00:00 2001 From: QQ <1770362456@qq.com> Date: Thu, 19 Jan 2023 18:14:43 +0800 Subject: [PATCH] init --- .gitignore | 1 + coc-settings.json | 3 +++ init.lua | 7 +++++++ lazy-lock.json | 15 ++++++++++++++ lua/coc.lua | 50 +++++++++++++++++++++++++++++++++++++++++++++++ lua/keymap.lua | 43 ++++++++++++++++++++++++++++++++++++++++ lua/options.lua | 40 +++++++++++++++++++++++++++++++++++++ lua/plug.lua | 47 ++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 206 insertions(+) create mode 100644 .gitignore create mode 100644 coc-settings.json create mode 100644 init.lua create mode 100644 lazy-lock.json create mode 100644 lua/coc.lua create mode 100644 lua/keymap.lua create mode 100644 lua/options.lua create mode 100644 lua/plug.lua diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f43e13 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +lua/lazy/* diff --git a/coc-settings.json b/coc-settings.json new file mode 100644 index 0000000..2f72303 --- /dev/null +++ b/coc-settings.json @@ -0,0 +1,3 @@ +{ + "snippets.ultisnips.pythonPrompt": false +} diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..defb0b3 --- /dev/null +++ b/init.lua @@ -0,0 +1,7 @@ +vim.g.mapleader = ' ' + +require('plug') +require('options') +require('keymap') +require('coc') + diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..24a8591 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,15 @@ +{ + "auto-pairs": { "branch": "master", "commit": "39f06b873a8449af8ff6a3eee716d3da14d63a76" }, + "bullets.vim": { "branch": "master", "commit": "746f92ae05cdcc988857d8e76418326f07af9494" }, + "coc.nvim": { "branch": "release", "commit": "95b43f67147391cf2c69e550bd001b742781d226" }, + "colorizer": { "branch": "master", "commit": "72790a003d5a706c287486a1a81e3a6b32158b54" }, + "gruvbox": { "branch": "master", "commit": "bf2885a95efdad7bd5e4794dd0213917770d79b7" }, + "nerdcommenter": { "branch": "master", "commit": "98cc4a2d64ca67cccbf5b5cf47c682ebadaaff58" }, + "vim-airline": { "branch": "master", "commit": "1d9ae3f972e76a1d36384da7a2890f6402d07d6c" }, + "vim-easy-align": { "branch": "master", "commit": "12dd6316974f71ce333e360c0260b4e1f81169c3" }, + "vim-instant-markdown": { "branch": "master", "commit": "383aa2900f855eddc42ffbe9d636c54e2f2939d5" }, + "vim-markdown-toc": { "branch": "master", "commit": "7ec05df27b4922830ace2246de36ac7e53bea1db" }, + "vim-surround": { "branch": "master", "commit": "6c5e229e85e3248b9db27a2e6276583c586bf3dd" }, + "vim-table-mode": { "branch": "master", "commit": "9555a3e6e5bcf285ec181b7fc983eea90500feb4" }, + "wildfire.vim": { "branch": "master", "commit": "b371e2b1d938ae0e164146136051de164ecb9aa5" } +} \ No newline at end of file diff --git a/lua/coc.lua b/lua/coc.lua new file mode 100644 index 0000000..6cde4ff --- /dev/null +++ b/lua/coc.lua @@ -0,0 +1,50 @@ +vim.cmd([[ + let g:coc_global_extensions = [ + \ 'coc-clangd', + \ 'coc-lua', + \ 'coc-python', + \ + \ 'coc-explorer', + \ 'coc-translator', + \ ] +]]) + +local map = vim.api.nvim_set_keymap +-- coc 设置 +-- Autocomplete +function _G.check_back_space() + local col = vim.fn.col('.') - 1 + return col == 0 or vim.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} +map("i", "", [[ coc#pum#visible() ? coc#pum#next(1) : v:lua.check_back_space() ? "" : coc#refresh() ]] , opts) +map("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 +map("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 +map("n", "[g", "(coc-diagnostic-prev)", {silent = true}) +map("n", "]g", "(coc-diagnostic-next)", {silent = true}) + +-- GoTo code navigation +map("n", "gd", "(coc-definition)", {silent = true}) +map("n", "gy", "(coc-type-definition)", {silent = true}) +map("n", "gi", "(coc-implementation)", {silent = true}) +map("n", "gr", "(coc-references)", {silent = true}) + +-- Symbol renaming +map("n", "rn", "(coc-rename)", {silent = true}) + +-- Formatting selected code +map("x", "i", "(coc-format-selected)", {silent = true}) +map("n", "i", "(coc-format-selected)", {silent = true}) + diff --git a/lua/keymap.lua b/lua/keymap.lua new file mode 100644 index 0000000..4716e33 --- /dev/null +++ b/lua/keymap.lua @@ -0,0 +1,43 @@ +local map = vim.api.nvim_set_keymap + +map('n', 'y', '"+y', {noremap = true}) +map('n', 'p', '"+p', {noremap = true}) +map('n', 'd', '"+d', {noremap = true}) + +map('n', 'L', '$', {noremap = true}) +map('n', 'H', '^', {noremap = true}) +map('n', '>', '>>', {noremap = true}) +map('n', '<', '<<', {noremap = true}) +map('n', 'Q', ':q!', {noremap = true}) +map('n', '?', 'set hlsearch?', {noremap = true}) +map('n', '/', 'set hlsearch/', {noremap = true}) +map('n', '', '5j', {noremap = true}) +map('n', '', '5k', {noremap = true}) + + +map('n', '', ':nohlsearch', {noremap = true}) +map('n', '', ':wj', {noremap = true}) +map('n', '', ':wh', {noremap = true}) +map('n', '', ':wk', {noremap = true}) +map('n', '', ':wl', {noremap = true}) +map('n', '', ':wq', {noremap = true}) + + +map('n', 'y', 'ggyG', {noremap = true}) +map('n', 'p', 'ggpG', {noremap = true}) +map('n', 'v', 'ggVG', {noremap = true}) + +map('n', '', ':res -5', {noremap = true}) +map('n', '', ':res +5', {noremap = true}) +map('n', '', ':vertical resize -5', {noremap = true}) +map('n', '', ':vertical resize +5', {noremap = true}) + + + + + + + + + + diff --git a/lua/options.lua b/lua/options.lua new file mode 100644 index 0000000..7348f2b --- /dev/null +++ b/lua/options.lua @@ -0,0 +1,40 @@ +-- 行号 +vim.o.nu = true +vim.o.rnu = true +vim.o.scrolloff = 999 + +-- 自动保存 +vim.o.autowrite = true +vim.o.autowriteall = true + +-- tab键 +vim.o.sw = 2 +vim.o.ts = 2 +vim.o.softtabstop = 2 +vim.o.smarttab = true +vim.o.expandtab = true +vim.o.autoindent = true + +-- 光标 +vim.o.cursorline = true + +-- 分屏 +vim.o.splitright = true +vim.o.splitbelow = true + +-- 搜索 +vim.o.ignorecase = true +vim.o.incsearch = true + +-- 不换行 +vim.o.textwidth = 999 +vim.o.wrap = false + +-- 背景 +vim.g.bg = dark +vim.cmd([[colorscheme gruvbox]]) + +-- 输入法自动根据模式自动切换 +vim.cmd([[ +au InsertLeave * :silent !fcitx5-remote -c +]]) diff --git a/lua/plug.lua b/lua/plug.lua new file mode 100644 index 0000000..0fb8c0d --- /dev/null +++ b/lua/plug.lua @@ -0,0 +1,47 @@ +local lazypath = '~/.config/nvim/lua/lazy/lazy.lua' + +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--depin=1", + "https://github.com/newbieQQ/lazy.nvim.git", + lazypath, + }) +end + +vim.opt.rtp:prepend(lazypath) + +require("lazy").setup({ + -- 主题插件 + 'vim-airline/vim-airline', + 'morhetz/gruvbox', + + {'neoclide/coc.nvim', branch = 'release'}, + 'jiangmiao/auto-pairs', + + -- surround 和 wildfire 配合有神奇的效果 + 'yaocccc/vim-surround', + 'gcmt/wildfire.vim', + + -- 格式整理 + 'junegunn/vim-easy-align', + 'scrooloose/nerdcommenter', + + --颜色识别 + 'lilydjwg/colorizer', + + --markdown + 'suan/vim-instant-markdown', + 'dhruvasagar/vim-table-mode', + 'mzlogin/vim-markdown-toc', + 'dkarter/bullets.vim' +}) + + + + + + + +