Xin.Chen
3 years ago
15 changed files with 422 additions and 0 deletions
@ -0,0 +1,4 @@ |
|||
.netrwhist |
|||
plugin |
|||
|
|||
|
@ -0,0 +1,24 @@ |
|||
" 基础设置 |
|||
lua require('basic') |
|||
lua require('plugins') |
|||
lua require('keybindings') |
|||
lua require('which-key-config') |
|||
|
|||
" theme |
|||
" https://github.com/ellisonleao/gruvbox.nvim |
|||
set background=dark " or light if you want light mode |
|||
colorscheme gruvbox |
|||
|
|||
" plugins confg |
|||
"----------------- |
|||
lua require('nvim-treesitter-config') |
|||
lua require('telescope-config') |
|||
lua require('nvim-autopairs-config') |
|||
lua require('nvim-tree-config') |
|||
lua require('bufferline-config') |
|||
lua require('surround-config') |
|||
lua require('comment-config') |
|||
|
|||
" lsp |
|||
"lua require('nvim-lspconfig-config') |
|||
lua require('nvim-cmp-config') |
@ -0,0 +1,81 @@ |
|||
-- utf8 |
|||
vim.g.encoding = "UTF-8" |
|||
vim.o.fileencoding = 'utf-8' |
|||
-- 光标下方保留8行 |
|||
vim.o.scrolloff = 8 |
|||
vim.o.sidescrolloff = 5 |
|||
-- 相对行号 |
|||
vim.wo.number = true |
|||
vim.wo.relativenumber = true |
|||
-- 高亮所在行 |
|||
vim.wo.cursorline = true |
|||
-- 显示指示列 |
|||
vim.wo.signcolumn = "yes" |
|||
-- 右侧参考线 |
|||
vim.wo.colorcolumn = "80" |
|||
-- 缩进2个空格等于一个Tab |
|||
vim.o.tabstop = 2 |
|||
vim.bo.tabstop = 2 |
|||
vim.o.softtabstop = 2 |
|||
vim.o.shiftround = true |
|||
-- >> << 时长度 |
|||
vim.o.shiftwidth = 2 |
|||
vim.bo.shiftwidth = 2 |
|||
-- 新行对齐当前行,适合空格替代tab |
|||
vim.o.expandtab = true |
|||
vim.bo.expandtab = true |
|||
vim.o.autoindent = true |
|||
vim.bo.autoindent = true |
|||
vim.o.smartindent = true |
|||
-- 搜索大小写不敏感,除非包含大小写 |
|||
vim.o.ignorecase = true |
|||
vim.o.smartcase = true |
|||
-- 搜索不要高亮 |
|||
vim.o.hlsearch = false |
|||
-- 边输入边搜索 |
|||
vim.o.incsearch = true |
|||
-- 使用增强状态栏后不再需要 vim 的模式提示 |
|||
vim.o.showmode = false |
|||
-- 命令行高为2,提供足够的显示空间 |
|||
vim.o.cmdheight = 2 |
|||
-- 当文件被外部程序修改时,自动加载 |
|||
vim.o.autoread = true |
|||
vim.bo.autoread = true |
|||
-- 禁止折行 |
|||
vim.o.wrap = false |
|||
vim.wo.wrap = false |
|||
-- 允许隐藏被修改过的buffer |
|||
vim.o.hidden = true |
|||
-- 鼠标支持 |
|||
vim.o.mouse = "a" |
|||
-- 行结尾可以跳到下一行 |
|||
vim.o.whichwrap = 'b,s,<,>,[,],h,l' |
|||
-- 禁止创建备份文件 |
|||
vim.o.backup = false |
|||
vim.o.writebackup = false |
|||
vim.o.swapfile = false |
|||
-- smaller updatetime |
|||
vim.o.updatetime = 300 |
|||
-- 等待mappings |
|||
vim.o.timeoutlen = 100 |
|||
-- split window 从下边和右边出现 |
|||
vim.o.splitbelow = true |
|||
vim.o.splitright = true |
|||
|
|||
--------------------------------------------- |
|||
vim.o.background = "dark" |
|||
vim.o.termguicolors = true |
|||
vim.opt.termguicolors = true |
|||
--? tab 字符显示 |
|||
vim.o.list = true |
|||
vim.o.listchars = "tab:>·" |
|||
-- 补全 |
|||
vim.o.wildmenu = true |
|||
-- Dont' pass messages to |ins-completin menu| |
|||
vim.o.shortmess = vim.o.shortmess .. 'c' |
|||
vim.o.pumheight = 10 |
|||
-- vim.o.conceallevel = 0 |
|||
vim.o.showtabline = 2 |
|||
-- vim.o.clipboard = "unnamedplus" |
|||
|
|||
|
@ -0,0 +1,5 @@ |
|||
vim.opt.termguicolors = true |
|||
require("bufferline").setup{ |
|||
diagnostics = "nvim_lsp" |
|||
} |
|||
|
@ -0,0 +1 @@ |
|||
require('Comment').setup() |
@ -0,0 +1,34 @@ |
|||
-- leader |
|||
vim.g.mapleader = " " |
|||
vim.g.maplocalleader = " " |
|||
local map = vim.api.nvim_set_keymap |
|||
|
|||
map('v', '<', '<gv', {noremap = true, silent = false}) |
|||
map('v', '>', '>gv', {noremap = true, silent = false}) |
|||
|
|||
-- 分屏 |
|||
map("n", "<A-h>", "<C-w>h", {noremap = true, silent = false }) |
|||
map("n", "<A-j>", "<C-w>j", {noremap = true, silent = false }) |
|||
map("n", "<A-k>", "<C-w>k", {noremap = true, silent = false }) |
|||
map("n", "<A-l>", "<C-w>l", {noremap = true, silent = false }) |
|||
map("n", "<A-o>", "<C-w>o", {noremap = true, silent = false }) -- close others |
|||
|
|||
-- map("n", "<C-l>", "<C-w>>", {noremap = true, silent = false }) |
|||
-- map("n", "<C-h>", "<cmd>vertical resize -2<CR>", {noremap = true, silent = false }) |
|||
map("n", "<A-=>", "<C-w>=", {noremap = true, silent = false }) |
|||
|
|||
-- Telescope |
|||
map("n", "<C-p>", "<cmd>Telescope find_files<cr>", {noremap = true, silent = false }) |
|||
map("n", "<leader>f", "<cmd>Telescope find_files<cr>", {noremap = true, silent = false }) |
|||
map("n", "<leader>g", "<cmd>Telescope live_grep<cr>", {noremap = true, silent = false }) |
|||
|
|||
-- nvimTree |
|||
map('n', '<C-n>', ':NvimTreeToggle<CR>', {noremap = true, silent = true}) |
|||
|
|||
-- bufferline |
|||
map("n", "<C-h>", "<cmd>BufferLineCyclePrev<CR>", {noremap = true, silent = true }) |
|||
map("n", "<C-l>", "<cmd>BufferLineCycleNext<CR>", {noremap = true, silent = true }) |
|||
|
|||
-- comment |
|||
map("n", "<C-_>", "gcc", {noremap = true, silent = true }) |
|||
map("v", "<C-_>", "gc", {noremap = true, silent = true }) |
@ -0,0 +1,6 @@ |
|||
require('nvim-autopairs').setup{} |
|||
-- If you want insert `(` after select function or method item |
|||
local cmp_autopairs = require('nvim-autopairs.completion.cmp') |
|||
local cmp = require('cmp') |
|||
cmp.event:on( 'confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } })) |
|||
|
@ -0,0 +1,83 @@ |
|||
-- https://gitub.com/hrsh7th/nvim-cmph |
|||
-- |
|||
vim.g.completeopt = "menu,menuone,noselect,noinsert" |
|||
|
|||
local cmp = require'cmp' |
|||
cmp.setup({ |
|||
snippet = { |
|||
-- REQUIRED - you must specify a snippet engine |
|||
expand = function(args) |
|||
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. |
|||
-- require('luasnip').lsp_expand(args.body) -- For `luasnip` users. |
|||
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. |
|||
-- require'snippy'.expand_snippet(args.body) -- For `snippy` users. |
|||
end, |
|||
}, |
|||
mapping = { |
|||
['<C-d>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), |
|||
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), |
|||
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), |
|||
['<C-y>'] = cmp.config.disable, -- If you want to remove the default `<C-y>` mapping, You can specify `cmp.config.disable` value. |
|||
['<C-e>'] = cmp.mapping({ |
|||
i = cmp.mapping.abort(), |
|||
c = cmp.mapping.close(), |
|||
}), |
|||
['<CR>'] = cmp.mapping.confirm({ select = true }), |
|||
}, |
|||
sources = cmp.config.sources({ |
|||
{ name = 'nvim_lsp' }, |
|||
{ name = 'vsnip' }, -- For vsnip users. |
|||
-- { name = 'luasnip' }, -- For luasnip users. |
|||
-- { name = 'ultisnips' }, -- For ultisnips users. |
|||
-- { name = 'snippy' }, -- For snippy users. |
|||
}, { |
|||
{ name = 'buffer' }, |
|||
}) |
|||
}) |
|||
|
|||
-- Use buffer source for `/`. |
|||
cmp.setup.cmdline('/', { |
|||
sources = { |
|||
{ name = 'buffer' } |
|||
} |
|||
}) |
|||
|
|||
-- Use cmdline & path source for ':'. |
|||
cmp.setup.cmdline(':', { |
|||
sources = cmp.config.sources({ |
|||
{ name = 'path' } |
|||
}, { |
|||
{ name = 'cmdline' } |
|||
}) |
|||
}) |
|||
|
|||
-- Setup lspconfig. |
|||
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) |
|||
local nvim_lsp = require('lspconfig') |
|||
local on_attach = function(client, buffer) |
|||
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end |
|||
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end |
|||
|
|||
--- Mappings. |
|||
local opts = { noremap=true, silent=true } |
|||
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts) |
|||
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts) |
|||
buf_set_keymap('n', 'gh', '<cmd>lua vim.lsp.buf.hover()<CR>', opts) |
|||
-- buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts) |
|||
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts) |
|||
buf_set_keymap('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<CR>', opts) |
|||
buf_set_keymap('n', '<leader>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts) |
|||
|
|||
end |
|||
|
|||
-- Use a lop to conveniently call 'setup' on multiple servers and |
|||
-- map buffer local keybindings when the language server attaches |
|||
local servers = {'rust_analyzer', 'tsserver' } |
|||
for _, lsp in ipairs(servers) do |
|||
nvim_lsp[lsp].setup { |
|||
on_attach = on_attach, |
|||
flags = { |
|||
debounce_text_changes = 150, |
|||
} |
|||
} |
|||
end |
@ -0,0 +1,2 @@ |
|||
require'lspconfig'.tsserver.setup{} |
|||
|
@ -0,0 +1,88 @@ |
|||
vim.g.nvim_tree_width = 10 |
|||
-- following options are the default |
|||
-- each of these are documented in `:help nvim-tree.OPTION_NAME` |
|||
require'nvim-tree'.setup { |
|||
disable_netrw = true, |
|||
hijack_netrw = true, |
|||
open_on_setup = false, |
|||
ignore_ft_on_setup = {}, |
|||
auto_close = true, |
|||
open_on_tab = false, |
|||
hijack_cursor = false, |
|||
update_cwd = false, |
|||
update_to_buf_dir = { |
|||
enable = true, |
|||
auto_open = true, |
|||
}, |
|||
diagnostics = { |
|||
enable = false, |
|||
icons = { |
|||
hint = "", |
|||
info = "", |
|||
warning = "", |
|||
error = "", |
|||
} |
|||
}, |
|||
update_focused_file = { |
|||
enable = false, |
|||
update_cwd = false, |
|||
ignore_list = {} |
|||
}, |
|||
system_open = { |
|||
cmd = nil, |
|||
args = {} |
|||
}, |
|||
filters = { |
|||
dotfiles = false, |
|||
custom = {} |
|||
}, |
|||
view = { |
|||
width = "50%", |
|||
height = 30, |
|||
hide_root_folder = false, |
|||
side = 'right', |
|||
auto_resize = false, |
|||
mappings = { |
|||
custom_only = false, |
|||
list = {} |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
local tree_cb = require'nvim-tree.config'.nvim_tree_callback |
|||
-- default mappings |
|||
local list = { |
|||
{ key = {"<CR>", "o", "<2-LeftMouse>"}, cb = tree_cb("edit") }, |
|||
{ key = {"<2-RightMouse>", "<C-]>"}, cb = tree_cb("cd") }, |
|||
{ key = "<C-v>", cb = tree_cb("vsplit") }, |
|||
{ key = "<C-x>", cb = tree_cb("split") }, |
|||
{ key = "<C-t>", cb = tree_cb("tabnew") }, |
|||
{ key = "<", cb = tree_cb("prev_sibling") }, |
|||
{ key = ">", cb = tree_cb("next_sibling") }, |
|||
{ key = "P", cb = tree_cb("parent_node") }, |
|||
{ key = "<BS>", cb = tree_cb("close_node") }, |
|||
{ key = "<S-CR>", cb = tree_cb("close_node") }, |
|||
{ key = "<Tab>", cb = tree_cb("preview") }, |
|||
{ key = "K", cb = tree_cb("first_sibling") }, |
|||
{ key = "J", cb = tree_cb("last_sibling") }, |
|||
{ key = "I", cb = tree_cb("toggle_ignored") }, |
|||
{ key = "H", cb = tree_cb("toggle_dotfiles") }, |
|||
{ key = "R", cb = tree_cb("refresh") }, |
|||
{ key = "a", cb = tree_cb("create") }, |
|||
{ key = "d", cb = tree_cb("remove") }, |
|||
{ key = "r", cb = tree_cb("rename") }, |
|||
{ key = "<C-r>", cb = tree_cb("full_rename") }, |
|||
{ key = "x", cb = tree_cb("cut") }, |
|||
{ key = "c", cb = tree_cb("copy") }, |
|||
{ key = "p", cb = tree_cb("paste") }, |
|||
{ key = "y", cb = tree_cb("copy_name") }, |
|||
{ key = "Y", cb = tree_cb("copy_path") }, |
|||
{ key = "gy", cb = tree_cb("copy_absolute_path") }, |
|||
{ key = "[c", cb = tree_cb("prev_git_item") }, |
|||
{ key = "]c", cb = tree_cb("next_git_item") }, |
|||
{ key = "-", cb = tree_cb("dir_up") }, |
|||
{ key = "s", cb = tree_cb("system_open") }, |
|||
{ key = "q", cb = tree_cb("close") }, |
|||
{ key = "g?", cb = tree_cb("toggle_help") }, |
|||
} |
@ -0,0 +1,7 @@ |
|||
require'nvim-treesitter.configs'.setup { |
|||
ensure_installed = {"html", "javascript", "lua", "typescript"}, |
|||
highlight = { |
|||
enable = true, |
|||
additional_vim_regex_highlighting = false, |
|||
}, |
|||
} |
@ -0,0 +1,37 @@ |
|||
return require('packer').startup(function() |
|||
-- Packer can manage itself |
|||
use 'wbthomason/packer.nvim' |
|||
-- treesitter |
|||
use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' } |
|||
-- which-key |
|||
use 'folke/which-key.nvim' |
|||
-- telescope |
|||
use { 'nvim-telescope/telescope.nvim', requires = { {'nvim-lua/plenary.nvim'} } } |
|||
-- lspconfig |
|||
use 'neovim/nvim-lspconfig' |
|||
-- nvim-cmp |
|||
use 'hrsh7th/cmp-nvim-lsp' |
|||
use 'hrsh7th/cmp-buffer' |
|||
use 'hrsh7th/cmp-path' |
|||
use 'hrsh7th/cmp-cmdline' |
|||
use 'hrsh7th/nvim-cmp' |
|||
use 'hrsh7th/cmp-vsnip' |
|||
use 'hrsh7th/vim-vsnip' |
|||
-- use 'nvim-autopairs' |
|||
use "windwp/nvim-autopairs" |
|||
-- nvim-tree |
|||
use { |
|||
'kyazdani42/nvim-tree.lua', |
|||
requires = 'kyazdani42/nvim-web-devicons', |
|||
} |
|||
-- bufferline |
|||
use {'akinsho/bufferline.nvim', requires = 'kyazdani42/nvim-web-devicons'} |
|||
-- surround |
|||
use "blackCauldron7/surround.nvim" |
|||
-- Comment |
|||
use 'numToStr/Comment.nvim' |
|||
-- gruvbox theme |
|||
use {"ellisonleao/gruvbox.nvim", requires = {"rktjmp/lush.nvim"}} |
|||
|
|||
end) |
|||
|
@ -0,0 +1,3 @@ |
|||
require"surround".setup { |
|||
mappings_style = "surround" |
|||
} |
@ -0,0 +1,31 @@ |
|||
require('telescope').setup{ |
|||
defaults = { |
|||
-- Default configuration for telescope goes here: |
|||
-- config_key = value, |
|||
mappings = { |
|||
i = { |
|||
-- map actions.which_key to <C-h> (default: <C-/>) |
|||
-- actions.which_key shows the mappings for your picker, |
|||
-- e.g. git_{create, delete, ...}_branch for the git_branches picker |
|||
["<C-h>"] = "which_key" |
|||
} |
|||
} |
|||
}, |
|||
pickers = { |
|||
-- Default configuration for builtin pickers goes here: |
|||
-- picker_name = { |
|||
-- picker_config_key = value, |
|||
-- ... |
|||
-- |
|||
-- Now the picker_config_key will be applied every time you call this |
|||
-- builtin picker |
|||
}, |
|||
extensions = { |
|||
-- Your extension configuration goes here: |
|||
-- extension_name = { |
|||
-- extension_config_key = value, |
|||
-- } |
|||
-- please take a look at the readme of the extension you want to configure |
|||
} |
|||
} |
|||
|
@ -0,0 +1,16 @@ |
|||
-- https://github.com/folke/which-key.nvim |
|||
|
|||
local wk = require("which-key") |
|||
local mappings = { |
|||
q = {":q<CR>", "QUit"}, |
|||
Q = {":wq<CR>", "Save & Quit"}, |
|||
w = {":w<CR>", "Save"}, |
|||
E = {":e ~/.config/nvim/init.vim<CR>" , "Edit config"}, |
|||
f = {":Telescope find_files<CR>","Telescope Find Files"}, |
|||
r = {":Telescope live_grep<CR>","Telescope Live Grep"} |
|||
|
|||
} |
|||
wk.register(mappings, { prefix = "<leader>" }) |
|||
|
|||
|
|||
|
Loading…
Reference in new issue