first commit
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
vim.o.background = "dark" -- or "light" for light mode
|
||||
vim.cmd('colorscheme gruvbox')
|
||||
vim.g.airline_theme = 'base16_gruvbox_dark_pale'
|
||||
-- vim.base16colorspace = 256
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
-- define common options
|
||||
local opt = {
|
||||
noremap = true, -- non-recursive
|
||||
silent = true, -- do not show message
|
||||
}
|
||||
local map = vim.api.nvim_set_keymap
|
||||
|
||||
vim.g.mapleader = "z"
|
||||
-- vim.g.maplocalleader = "\\"
|
||||
|
||||
map('n', '<F5>', '<Esc>:tabnew<CR>', opt)
|
||||
map('n', 'ff', '<Esc>:FloatermToggle<CR>', opt)
|
||||
map('t', 'ff', ':FloatermToggle<CR>', opt)
|
||||
map('n', '<leader>g', '<Esc>:CocCommand git.showBlameDoc<CR>', opt)
|
||||
map('v', '<C-S-c>', '"+y', opt)
|
||||
map('n', '<C-S-v>', '"*p', opt)
|
||||
|
||||
map("t", "<A-h>", "<C-w>h", opt)
|
||||
map("t", "<A-j>", "<C-w>j", opt)
|
||||
map("t", "<A-k>", "<C-w>k", opt)
|
||||
map("t", "<A-l>", "<C-w>l", opt)
|
||||
|
||||
--tag
|
||||
map("n", "wn", ":tabnew<CR>", opt)
|
||||
map("n", "ww", ":tabclose<CR>", opt)
|
||||
map("n", "wl", ":tabnext<CR>", opt)
|
||||
map("n", "wh", ":tabprevious<CR>", opt)
|
||||
|
||||
-- 取消 s 默认功能
|
||||
map("n", "s", "", opt)
|
||||
-- windows 分屏快捷键
|
||||
map("n", "sv", ":vsp<CR>", opt)
|
||||
map("n", "sh", ":sp<CR>", opt)
|
||||
-- 关闭当前
|
||||
map("n", "sc", "<C-w>c", opt)
|
||||
-- 关闭其他
|
||||
map("n", "so", "<C-w>o", opt)
|
||||
-- Alt + hjkl 窗口之间跳转
|
||||
map("n", "<A-h>", "<C-w>h", opt)
|
||||
map("n", "<A-j>", "<C-w>j", opt)
|
||||
map("n", "<A-k>", "<C-w>k", opt)
|
||||
map("n", "<A-l>", "<C-w>l", opt)
|
||||
|
||||
-- 左右比例控制
|
||||
map("n", "<C-Left>", ":vertical resize -2<CR>", opt)
|
||||
map("n", "<C-Right>", ":vertical resize +2<CR>", opt)
|
||||
map("n", "s,", ":vertical resize -20<CR>", opt)
|
||||
map("n", "s.", ":vertical resize +20<CR>", opt)
|
||||
-- 上下比例
|
||||
map("n", "sj", ":resize +10<CR>", opt)
|
||||
map("n", "sk", ":resize -10<CR>", opt)
|
||||
map("n", "<C-Down>", ":resize +2<CR>", opt)
|
||||
map("n", "<C-Up>", ":resize -2<CR>", opt)
|
||||
-- 等比例
|
||||
map("n", "s=", "<C-w>=", opt)
|
||||
|
||||
|
||||
-- 上下滚动浏览
|
||||
map("n", "<C-j>", "4j", opt)
|
||||
map("n", "<C-k>", "4k", opt)
|
||||
-- ctrl u / ctrl + d 只移动9行,默认移动半屏
|
||||
map("n", "<C-u>", "9k", opt)
|
||||
map("n", "<C-d>", "9j", opt)
|
||||
|
||||
-- 退出
|
||||
map("n", "q", ":q<CR>", opt)
|
||||
map("n", "qq", ":q!<CR>", opt)
|
||||
map("n", "Q", ":qa!<CR>", opt)
|
||||
|
||||
-- insert 模式下,跳到行首行尾
|
||||
map("i", "<C-h>", "<ESC>I", opt)
|
||||
map("i", "<C-l>", "<ESC>A", opt)
|
||||
|
||||
-- 插件快捷键
|
||||
local pluginKeys = {}
|
||||
|
||||
-- nvim-tree
|
||||
-- alt + m 键打开关闭tree
|
||||
map("n", "<A-m>", ":NvimTreeToggle<CR>", opt)
|
||||
-- 列表快捷键
|
||||
pluginKeys.nvimTreeList = {
|
||||
-- 打开文件或文件夹
|
||||
{ key = {"<CR>", "o", "<2-LeftMouse>"}, action = "edit" },
|
||||
-- 分屏打开文件
|
||||
{ key = "v", action = "vsplit" },
|
||||
{ key = "h", action = "split" },
|
||||
-- 显示隐藏文件
|
||||
{ key = "i", action = "toggle_custom" }, -- 对应 filters 中的 custom (node_modules)
|
||||
{ key = ".", action = "toggle_dotfiles" }, -- Hide (dotfiles)
|
||||
-- 文件操作
|
||||
{ key = "<F5>", action = "refresh" },
|
||||
{ key = "a", action = "create" },
|
||||
{ key = "d", action = "remove" },
|
||||
{ key = "r", action = "rename" },
|
||||
{ key = "x", action = "cut" },
|
||||
{ key = "c", action = "copy" },
|
||||
{ key = "p", action = "paste" },
|
||||
{ key = "s", action = "system_open" },
|
||||
}
|
||||
return pluginKeys
|
||||
@@ -0,0 +1,81 @@
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
-- 安装 language parser
|
||||
-- :TSInstallInfo 命令查看支持的语言
|
||||
ensure_installed = {"vim", "lua", "javascript", "go"},
|
||||
-- 启用代码高亮功能
|
||||
highlight = {
|
||||
enable = true,
|
||||
additional_vim_regex_highlighting = false
|
||||
},
|
||||
-- 启用增量选择
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
init_selection = '<CR>',
|
||||
node_incremental = '<CR>',
|
||||
node_decremental = '<BS>',
|
||||
scope_incremental = '<TAB>',
|
||||
}
|
||||
},
|
||||
-- 启用基于Treesitter的代码格式化(=) . NOTE: This is an experimental feature.
|
||||
indent = {
|
||||
enable = true
|
||||
}
|
||||
}
|
||||
-- 开启 Folding
|
||||
vim.wo.foldmethod = 'expr'
|
||||
vim.wo.foldexpr = 'nvim_treesitter#foldexpr()'
|
||||
-- 默认不要折叠
|
||||
-- https://stackoverflow.com/questions/8316139/how-to-set-the-default-to-unfolded-when-you-open-a-file
|
||||
vim.wo.foldlevel = 99
|
||||
|
||||
-- Some servers have issues with backup files, see #649
|
||||
vim.opt.backup = false
|
||||
vim.opt.writebackup = false
|
||||
|
||||
-- Having longer updatetime (default is 4000 ms = 4s) leads to noticeable
|
||||
-- delays and poor user experience
|
||||
vim.opt.updatetime = 300
|
||||
|
||||
-- Always show the signcolumn, otherwise it would shift the text each time
|
||||
-- diagnostics appeared/became resolved
|
||||
vim.opt.signcolumn = "yes"
|
||||
|
||||
local keyset = vim.keymap.set
|
||||
-- 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 <tab>' 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", "<TAB>", 'coc#pum#visible() ? coc#pum#next(1) : v:lua.check_back_space() ? "<TAB>" : coc#refresh()', opts)
|
||||
keyset("i", "<S-TAB>", [[coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"]], opts)
|
||||
|
||||
-- GoTo code navigation
|
||||
keyset("n", "<c-]>", "<Plug>(coc-definition)", {silent = true})
|
||||
keyset("n", "<c-t>", "<Plug>(coc-type-definition)", {silent = true})
|
||||
keyset("n", "gi", "<Plug>(coc-implementation)", {silent = true})
|
||||
keyset("n", "gr", "<Plug>(coc-references)", {silent = true})
|
||||
|
||||
-- Use K to show documentation in preview window
|
||||
function _G.show_docs()
|
||||
local cw = vim.fn.expand('<cword>')
|
||||
if vim.fn.index({'vim', 'help'}, vim.bo.filetype) >= 0 then
|
||||
vim.api.nvim_command('h ' .. cw)
|
||||
elseif vim.api.nvim_eval('coc#rpc#ready()') then
|
||||
vim.fn.CocActionAsync('doHover')
|
||||
else
|
||||
vim.api.nvim_command('!' .. vim.o.keywordprg .. ' ' .. cw)
|
||||
end
|
||||
end
|
||||
keyset("n", "K", '<CMD>lua _G.show_docs()<CR>', {silent = true})
|
||||
-- Use <c-j> to trigger snippets
|
||||
keyset("i", "<c-j>", "<Plug>(coc-snippets-expand-jump)")
|
||||
-- Use <c-space> to trigger completion
|
||||
keyset("i", "<c-space>", "coc#refresh()", {silent = true, expr = true})
|
||||
@@ -0,0 +1,33 @@
|
||||
-- Hint: use `:h <option>` to figure out the meaning if needed
|
||||
vim.opt.clipboard = 'unnamedplus' -- use system clipboard
|
||||
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
|
||||
vim.opt.mouse = 'a' -- allow the mouse to be used in Nvim
|
||||
|
||||
-- Tab
|
||||
vim.opt.tabstop = 4 -- number of visual spaces per TAB
|
||||
vim.opt.softtabstop = 4 -- number of spacesin tab when editing
|
||||
vim.opt.shiftwidth = 4 -- insert 4 spaces on a tab
|
||||
vim.opt.expandtab = true -- tabs are spaces, mainly because of python
|
||||
|
||||
-- UI config
|
||||
vim.opt.number = true -- show absolute number
|
||||
vim.opt.cursorline = true -- highlight cursor line underneath the cursor horizontally
|
||||
vim.opt.splitbelow = true -- open new vertical split bottom
|
||||
vim.opt.splitright = true -- open new horizontal splits right
|
||||
vim.opt.termguicolors = true -- enabl 24-bit RGB color in the TUI
|
||||
vim.opt.showmode = false -- we are experienced, wo don't need the "-- INSERT --" mode hint
|
||||
|
||||
-- Searching
|
||||
vim.opt.incsearch = true -- search as characters are entered
|
||||
vim.opt.ignorecase = true -- ignore case in searches by default
|
||||
vim.opt.smartcase = true -- but make it case sensitive if an uppercase is entered
|
||||
|
||||
-- disable netrw at the very start of your init.lua
|
||||
vim.g.loaded_netrw = 1
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
|
||||
vim.cmd([[
|
||||
if has("autocmd")
|
||||
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
|
||||
endif
|
||||
]])
|
||||
@@ -0,0 +1,72 @@
|
||||
-- Install Packer automatically if it's not installed(Bootstraping)
|
||||
-- Hint: string concatenation is done by `..`
|
||||
local ensure_packer = function()
|
||||
local fn = vim.fn
|
||||
local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
|
||||
if fn.empty(fn.glob(install_path)) > 0 then
|
||||
fn.system({ 'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path })
|
||||
vim.cmd [[packadd packer.nvim]]
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
local packer_bootstrap = ensure_packer()
|
||||
|
||||
|
||||
-- Reload configurations if we modify plugins.lua
|
||||
-- Hint
|
||||
-- <afile> - replaced with the filename of the buffer being manipulated
|
||||
vim.cmd([[
|
||||
augroup packer_user_config
|
||||
autocmd!
|
||||
autocmd BufWritePost plugins.lua source <afile> | PackerSync
|
||||
augroup end
|
||||
]])
|
||||
|
||||
|
||||
-- Install plugins here - `use ...`
|
||||
-- Packer.nvim hints
|
||||
-- after = string or list, -- Specifies plugins to load before this plugin. See "sequencing" below
|
||||
-- config = string or function, -- Specifies code to run after this plugin is loaded
|
||||
-- requires = string or list, -- Specifies plugin dependencies. See "dependencies".
|
||||
-- ft = string or list, -- Specifies filetypes which load this plugin.
|
||||
-- run = string, function, or table, -- Specify operations to be run after successful installs/updates of a plugin
|
||||
return require('packer').startup(function(use)
|
||||
-- Packer can manage itself
|
||||
use 'wbthomason/packer.nvim'
|
||||
|
||||
---------------------------------------
|
||||
-- NOTE: PUT YOUR THIRD PLUGIN HERE --
|
||||
---------------------------------------
|
||||
use { "ellisonleao/gruvbox.nvim" }
|
||||
use 'vim-airline/vim-airline'
|
||||
use 'vim-airline/vim-airline-themes'
|
||||
use {
|
||||
'nvim-tree/nvim-tree.lua',
|
||||
requires = {
|
||||
'nvim-tree/nvim-web-devicons', -- optional
|
||||
},
|
||||
}
|
||||
use {
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
run = function()
|
||||
local ts_update = require('nvim-treesitter.install').update({ with_sync = true })
|
||||
ts_update()
|
||||
end,
|
||||
}
|
||||
use {'neoclide/coc.nvim', branch = 'release'}
|
||||
--use 'voldikss/vim-floaterm'
|
||||
use 'jiangmiao/auto-pairs'
|
||||
use({
|
||||
"iamcco/markdown-preview.nvim",
|
||||
run = function() vim.fn["mkdp#util#install"]() end,
|
||||
})
|
||||
use 'fatih/vim-go'
|
||||
use 'mhinz/vim-startify'
|
||||
|
||||
-- Automatically set up your configuration after cloning packer.nvim
|
||||
-- Put this at the end after all plugins
|
||||
if packer_bootstrap then
|
||||
require('packer').sync()
|
||||
end
|
||||
end)
|
||||
Reference in New Issue
Block a user