2022-10-16 03:20:55 +00:00
|
|
|
" {{{ plugins
|
2022-02-15 21:07:11 +00:00
|
|
|
call plug#begin(stdpath('data') . '/plugged')
|
|
|
|
|
|
|
|
" misc
|
2022-05-25 18:25:59 +00:00
|
|
|
Plug 'nvim-lua/plenary.nvim'
|
2022-04-04 03:02:21 +00:00
|
|
|
Plug 'tpope/vim-sensible'
|
2022-02-15 21:07:11 +00:00
|
|
|
Plug 'itchyny/vim-gitbranch'
|
|
|
|
Plug 'andweeb/presence.nvim'
|
|
|
|
Plug 'ntpeters/vim-better-whitespace'
|
|
|
|
Plug 'airblade/vim-gitgutter'
|
|
|
|
Plug 'tpope/vim-fugitive'
|
|
|
|
Plug 'mg979/vim-visual-multi'
|
|
|
|
Plug 'rhysd/committia.vim'
|
2022-04-04 03:02:21 +00:00
|
|
|
Plug 'tpope/vim-sleuth'
|
2022-05-25 18:25:59 +00:00
|
|
|
Plug 'm-demare/hlargs.nvim'
|
2022-08-08 16:52:23 +00:00
|
|
|
Plug 'nvim-treesitter/nvim-treesitter'
|
2022-07-07 15:57:41 +00:00
|
|
|
Plug 'windwp/nvim-ts-autotag'
|
2022-11-08 16:36:46 +00:00
|
|
|
Plug 'mileszs/ack.vim'
|
2022-02-15 21:07:11 +00:00
|
|
|
|
|
|
|
" interface
|
|
|
|
Plug 'romgrk/barbar.nvim'
|
2022-05-25 18:25:59 +00:00
|
|
|
Plug 'lukas-reineke/indent-blankline.nvim'
|
|
|
|
Plug 'folke/lsp-colors.nvim'
|
|
|
|
Plug 'nacro90/numb.nvim'
|
|
|
|
Plug 'xiyaowong/nvim-cursorword'
|
|
|
|
Plug 'kevinhwang91/nvim-hlslens'
|
2022-02-15 21:07:11 +00:00
|
|
|
|
|
|
|
" language specific
|
|
|
|
Plug 'sheerun/vim-polyglot'
|
|
|
|
Plug 'dense-analysis/ale'
|
|
|
|
Plug 'neovim/nvim-lspconfig'
|
2022-05-25 18:25:59 +00:00
|
|
|
|
2022-11-08 16:36:46 +00:00
|
|
|
" autocomplete
|
2022-05-25 18:25:59 +00:00
|
|
|
Plug 'hrsh7th/nvim-cmp'
|
|
|
|
Plug 'hrsh7th/cmp-nvim-lsp'
|
|
|
|
Plug 'hrsh7th/cmp-cmdline'
|
|
|
|
Plug 'hrsh7th/cmp-buffer'
|
|
|
|
Plug 'dmitmel/cmp-cmdline-history'
|
|
|
|
Plug 'hrsh7th/cmp-nvim-lsp-signature-help'
|
|
|
|
Plug 'hrsh7th/cmp-path'
|
|
|
|
|
|
|
|
Plug 'hrsh7th/cmp-vsnip'
|
|
|
|
Plug 'hrsh7th/vim-vsnip'
|
2022-02-15 21:07:11 +00:00
|
|
|
|
|
|
|
call plug#end()
|
2022-10-16 03:20:55 +00:00
|
|
|
" }}}
|
2022-02-15 21:07:11 +00:00
|
|
|
|
2022-10-16 03:20:55 +00:00
|
|
|
" {{{ options
|
2022-04-04 03:02:21 +00:00
|
|
|
set notermguicolors
|
|
|
|
colorscheme lena
|
|
|
|
|
2022-02-15 21:07:11 +00:00
|
|
|
set fileformat=unix
|
|
|
|
set fileformats=unix,dos
|
|
|
|
|
|
|
|
set number
|
|
|
|
set cul
|
|
|
|
|
|
|
|
set tabstop=2
|
|
|
|
set shiftwidth=2
|
|
|
|
set expandtab
|
|
|
|
|
|
|
|
set mouse+=nia
|
|
|
|
|
|
|
|
au WinEnter * set cul
|
|
|
|
au WinLeave * set nocul
|
|
|
|
|
|
|
|
let g:better_whitespace_enabled = 1
|
|
|
|
|
|
|
|
let bufferline = get(g:, 'bufferline', {})
|
|
|
|
let bufferline.icons = v:false
|
|
|
|
let bufferline.icon_separator_active = '▎'
|
|
|
|
let bufferline.icon_separator_inactive = '▎'
|
|
|
|
let bufferline.icon_close_tab = 'x'
|
|
|
|
let bufferline.icon_close_tab_modified = '●'
|
|
|
|
let bufferline.icon_pinned = '▲'
|
|
|
|
|
|
|
|
let g:presence_buttons = 0
|
|
|
|
|
2022-10-16 03:20:55 +00:00
|
|
|
let g:ale_linters = {
|
|
|
|
\ 'javascript': ['eslint'],
|
|
|
|
\ 'typescript': ['eslint', 'tsserver'],
|
2022-11-08 16:36:46 +00:00
|
|
|
\ 'rust': ['rust-analyzer'],
|
2022-10-16 03:20:55 +00:00
|
|
|
\}
|
2022-02-15 21:07:11 +00:00
|
|
|
let g:ale_fixers = {
|
|
|
|
\ '*': ['trim_whitespace'],
|
|
|
|
\ 'vim': [],
|
2022-10-16 03:20:55 +00:00
|
|
|
\ 'javascript': ['prettier', 'eslint'],
|
|
|
|
\ 'typescript': ['prettier', 'eslint'],
|
2022-02-15 21:07:11 +00:00
|
|
|
\ 'json': ['prettier'],
|
|
|
|
\ 'css': ['prettier'],
|
2022-11-08 16:36:46 +00:00
|
|
|
\ 'rust': ['rustfmt'],
|
2022-02-15 21:07:11 +00:00
|
|
|
\}
|
|
|
|
let g:ale_fix_on_save = 1
|
|
|
|
|
|
|
|
set fillchars+=vert:▎
|
|
|
|
|
2022-07-17 16:32:37 +00:00
|
|
|
set completeopt=menu,menuone,noselect
|
2022-11-08 16:36:46 +00:00
|
|
|
|
|
|
|
let g:ackprg = 'ag --vimgrep'
|
2022-10-16 03:20:55 +00:00
|
|
|
" }}}
|
2022-05-25 18:25:59 +00:00
|
|
|
|
2022-10-16 03:20:55 +00:00
|
|
|
" {{{ scripts
|
2022-02-15 21:07:11 +00:00
|
|
|
lua << EOF
|
2022-05-25 18:25:59 +00:00
|
|
|
vim.cmd("highlight IndentBlanklineIndent1 ctermfg=11 cterm=nocombine")
|
|
|
|
vim.cmd("highlight IndentBlanklineIndent2 ctermfg=10 cterm=nocombine")
|
|
|
|
vim.cmd("highlight IndentBlanklineIndent3 ctermfg=13 cterm=nocombine")
|
|
|
|
vim.cmd("highlight IndentBlanklineIndent4 ctermfg=12 cterm=nocombine")
|
|
|
|
|
|
|
|
vim.opt.list = true
|
|
|
|
vim.opt.listchars:append("space:⋅")
|
|
|
|
vim.opt.listchars:append("eol:↴")
|
|
|
|
|
|
|
|
require("indent_blankline").setup(
|
|
|
|
{
|
|
|
|
char = "▎",
|
|
|
|
space_char_blankline = " ",
|
|
|
|
char_blankline = " ",
|
|
|
|
char_highlight_list = {
|
|
|
|
"IndentBlanklineIndent1",
|
|
|
|
"IndentBlanklineIndent2",
|
|
|
|
"IndentBlanklineIndent3",
|
|
|
|
"IndentBlanklineIndent4",
|
|
|
|
},
|
|
|
|
show_current_context = true,
|
|
|
|
show_current_context_start = true,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
EOF
|
|
|
|
|
|
|
|
:lua require("numb").setup()
|
|
|
|
:lua require("nvim-ts-autotag").setup()
|
2022-02-15 21:07:11 +00:00
|
|
|
|
2022-05-25 18:25:59 +00:00
|
|
|
lua << EOF
|
|
|
|
require("hlslens").setup(
|
|
|
|
{
|
|
|
|
calm_down = true,
|
|
|
|
nearest_only = true,
|
|
|
|
nearest_float_when = "auto",
|
|
|
|
}
|
|
|
|
)
|
2022-02-15 21:07:11 +00:00
|
|
|
EOF
|
|
|
|
|
2022-05-25 18:25:59 +00:00
|
|
|
lua <<EOF
|
|
|
|
local cmp = require("cmp")
|
|
|
|
|
|
|
|
local has_words_before = function()
|
|
|
|
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
|
|
|
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
|
|
|
end
|
|
|
|
|
|
|
|
local feedkey = function(key, mode)
|
|
|
|
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
|
|
|
end
|
|
|
|
|
|
|
|
local mapping = {
|
2022-08-08 16:52:23 +00:00
|
|
|
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), {"i", "s", "c"}),
|
|
|
|
["<CR>"] = cmp.mapping(function(fallback)
|
|
|
|
local entry = cmp.get_selected_entry()
|
|
|
|
if entry then
|
|
|
|
cmp.confirm({behavior = cmp.ConfirmBehavior.Insert, select = true})
|
|
|
|
else
|
|
|
|
fallback()
|
|
|
|
end
|
|
|
|
end, {"i", "s", "c"}),
|
|
|
|
["<C-f>"] = cmp.mapping(function(fallback)
|
2022-07-07 15:57:41 +00:00
|
|
|
-- This little snippet will confirm with tab, and if no entry is selected, will confirm the first item
|
2022-05-25 18:25:59 +00:00
|
|
|
if cmp.visible() then
|
2022-07-07 15:57:41 +00:00
|
|
|
local entry = cmp.get_selected_entry()
|
2022-07-17 16:32:37 +00:00
|
|
|
if not entry then
|
|
|
|
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
|
|
|
|
else
|
|
|
|
cmp.confirm()
|
|
|
|
end
|
2022-05-25 18:25:59 +00:00
|
|
|
else
|
2022-07-07 15:57:41 +00:00
|
|
|
fallback()
|
2022-05-25 18:25:59 +00:00
|
|
|
end
|
2022-08-08 16:52:23 +00:00
|
|
|
end, {"i", "s", "c"}),
|
|
|
|
["<Tab>"] = cmp.mapping(cmp.mapping.abort(), {"i", "s", "c"}),
|
|
|
|
["<Esc>"] = cmp.mapping(cmp.mapping.abort(), {"i", "s", "c"}),
|
|
|
|
["<Down>"] = cmp.mapping(cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), {"i", "s", "c"}),
|
|
|
|
["<Up>"] = cmp.mapping(cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), {"i", "s", "c"}),
|
2022-05-25 18:25:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cmp.setup(
|
|
|
|
{
|
|
|
|
snippet = {
|
|
|
|
expand = function(args)
|
|
|
|
vim.fn["vsnip#anonymous"](args.body)
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
mapping = cmp.mapping.preset.insert(mapping),
|
|
|
|
sources = cmp.config.sources(
|
|
|
|
{
|
2022-07-17 16:32:37 +00:00
|
|
|
{name = "nvim_lsp", priority = 1},
|
2022-05-25 18:25:59 +00:00
|
|
|
{name = "vsnip"},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{name = "buffer"},
|
2022-08-08 16:52:23 +00:00
|
|
|
{name = "path"},
|
2022-05-25 18:25:59 +00:00
|
|
|
}
|
|
|
|
),
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
cmp.setup.cmdline(
|
|
|
|
":",
|
|
|
|
{
|
|
|
|
sources = {
|
|
|
|
{name = "cmdline", group_index = 1},
|
|
|
|
{name = "cmdline_history", group_index = 2},
|
|
|
|
},
|
2022-11-08 16:36:46 +00:00
|
|
|
mapping = cmp.mapping.preset.cmdline(mapping),
|
2022-05-25 18:25:59 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
cmp.setup.cmdline(
|
2022-11-08 16:36:46 +00:00
|
|
|
{"/", "?"},
|
2022-05-25 18:25:59 +00:00
|
|
|
{
|
|
|
|
sources = {
|
2022-08-08 16:52:23 +00:00
|
|
|
{name = "buffer"}
|
2022-05-25 18:25:59 +00:00
|
|
|
},
|
2022-11-08 16:36:46 +00:00
|
|
|
mapping = cmp.mapping.preset.cmdline(mapping),
|
2022-05-25 18:25:59 +00:00
|
|
|
}
|
|
|
|
)
|
2022-02-15 21:07:11 +00:00
|
|
|
|
2022-05-25 18:25:59 +00:00
|
|
|
local lspconfig = require("lspconfig")
|
2022-10-24 01:11:02 +00:00
|
|
|
local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
2022-05-25 18:25:59 +00:00
|
|
|
|
2022-11-08 16:36:46 +00:00
|
|
|
local servers = {"eslint", "tsserver", "rust_analyzer"}
|
|
|
|
for _, lsp in ipairs(servers) do
|
|
|
|
lspconfig[lsp].setup(
|
|
|
|
{
|
|
|
|
capabilities = capabilities,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
2022-05-25 18:25:59 +00:00
|
|
|
EOF
|
2022-10-16 03:20:55 +00:00
|
|
|
" }}}
|
2022-05-25 18:25:59 +00:00
|
|
|
|
2022-10-16 03:20:55 +00:00
|
|
|
" {{{ keys
|
2022-02-15 21:07:11 +00:00
|
|
|
tnoremap <Esc> <C-\><C-n>
|
|
|
|
|
2022-08-12 18:36:38 +00:00
|
|
|
inoremap <silent> <C-f> <C-i>
|
2022-11-08 16:36:46 +00:00
|
|
|
cnoremap <silent> <C-f> <C-i>
|
2022-08-08 16:52:23 +00:00
|
|
|
map! <silent> <Tab> <Esc>
|
|
|
|
cnoremap <silent> <Tab> <C-c>
|
|
|
|
|
2022-03-24 03:26:10 +00:00
|
|
|
nnoremap <silent> <S-Up> :m-2<CR>
|
|
|
|
nnoremap <silent> <S-Down> :m+<CR>
|
|
|
|
inoremap <silent> <S-Up> <Esc>:m-2<CR>
|
|
|
|
inoremap <silent> <S-Down> <Esc>:m+<CR>
|
2022-02-15 21:07:11 +00:00
|
|
|
|
2022-08-08 16:52:23 +00:00
|
|
|
"nnoremap <silent> <C-b> :NERDTreeToggle<CR>
|
|
|
|
"nnoremap <silent> <C-t> :SymbolsOutline<CR>
|
2022-03-19 03:38:59 +00:00
|
|
|
":lua require'bufferline.state'.set_offset(require'nvim-tree.view'.win_open() and 30 or 0)<CR>
|
2022-02-15 21:07:11 +00:00
|
|
|
|
2022-08-08 16:52:23 +00:00
|
|
|
"inoremap <expr> <C-f> pumvisible() ? "\<C-n>" : "\<Tab>"
|
|
|
|
"inoremap <expr> <C-S-f> pumvisible() ? "\<C-p>": "\<S-Tab>"
|
2022-02-15 21:07:11 +00:00
|
|
|
|
|
|
|
" barbar keys
|
|
|
|
" Move to previous/next
|
|
|
|
nnoremap <silent> <A-,> :BufferPrevious<CR>
|
|
|
|
nnoremap <silent> <A-.> :BufferNext<CR>
|
|
|
|
" Re-order to previous/next
|
|
|
|
nnoremap <silent> <A-<> :BufferMovePrevious<CR>
|
|
|
|
nnoremap <silent> <A->> :BufferMoveNext<CR>
|
|
|
|
" Goto buffer in position...
|
|
|
|
nnoremap <silent> <A-1> :BufferGoto 1<CR>
|
|
|
|
nnoremap <silent> <A-2> :BufferGoto 2<CR>
|
|
|
|
nnoremap <silent> <A-3> :BufferGoto 3<CR>
|
|
|
|
nnoremap <silent> <A-4> :BufferGoto 4<CR>
|
|
|
|
nnoremap <silent> <A-5> :BufferGoto 5<CR>
|
|
|
|
nnoremap <silent> <A-6> :BufferGoto 6<CR>
|
|
|
|
nnoremap <silent> <A-7> :BufferGoto 7<CR>
|
|
|
|
nnoremap <silent> <A-8> :BufferGoto 8<CR>
|
|
|
|
nnoremap <silent> <A-9> :BufferLast<CR>
|
|
|
|
" Pin/unpin buffer
|
|
|
|
nnoremap <silent> <A-p> :BufferPin<CR>
|
|
|
|
" Close buffer
|
|
|
|
nnoremap <silent> <A-c> :BufferClose<CR>
|
|
|
|
|
2022-10-16 03:20:55 +00:00
|
|
|
" }}}
|
|
|
|
|
|
|
|
" {{{ colors
|
2022-02-15 21:07:11 +00:00
|
|
|
hi Normal ctermbg=NONE
|
|
|
|
hi LineNr ctermfg=7
|
2022-03-24 03:26:10 +00:00
|
|
|
hi CursorLineNr ctermfg=1 ctermbg=0
|
|
|
|
hi CursorLine cterm=NONE ctermfg=NONE ctermbg=0
|
2022-08-08 16:52:23 +00:00
|
|
|
hi StatusLine ctermfg=2 ctermbg=8 cterm=NONE
|
|
|
|
hi StatusLineNC ctermfg=7 ctermbg=0 cterm=NONE
|
2022-02-15 21:07:11 +00:00
|
|
|
hi VertSplit ctermbg=0 ctermfg=0
|
|
|
|
hi ExtraWhitespace ctermbg=1
|
|
|
|
hi SignColumn ctermbg=8
|
|
|
|
|
|
|
|
hi BufferCurrent ctermfg=5 ctermbg=NONE
|
|
|
|
hi BufferCurrentIndex ctermfg=5 ctermbg=NONE
|
|
|
|
hi BufferCurrentMod ctermfg=9 ctermbg=NONE
|
|
|
|
hi BufferCurrentSign ctermfg=5 ctermbg=NONE
|
|
|
|
hi BufferCurrentTarget ctermfg=5 ctermbg=NONE
|
|
|
|
hi BufferVisible ctermfg=7 ctermbg=NONE
|
|
|
|
hi BufferVisibleIndex ctermfg=7 ctermbg=NONE
|
|
|
|
hi BufferVisibleMod ctermfg=9 ctermbg=NONE
|
|
|
|
hi BufferVisibleSign ctermfg=7 ctermbg=NONE
|
|
|
|
hi BufferVisibleTarget ctermfg=7 ctermbg=NONE
|
|
|
|
hi BufferInactive ctermfg=7 ctermbg=0
|
|
|
|
hi BufferInactiveIndex ctermfg=5 ctermbg=0
|
|
|
|
hi BufferInactiveMod ctermfg=1 ctermbg=0
|
|
|
|
hi BufferInactiveSign ctermfg=10 ctermbg=0
|
|
|
|
hi BufferInactiveTarget ctermfg=11 ctermbg=0
|
|
|
|
hi BufferTabpages ctermfg=7 ctermbg=0
|
|
|
|
hi BufferTabpageFill ctermfg=7 ctermbg=0
|
|
|
|
hi BufferOffset ctermfg=0 ctermbg=0
|
|
|
|
|
2022-04-04 03:02:21 +00:00
|
|
|
hi! link SignColumn LineNr
|
|
|
|
|
|
|
|
hi LspDiagnosticsDefaultHint ctermfg=6
|
|
|
|
hi LspDiagnosticsDefaultError ctermfg=1
|
|
|
|
hi LspDiagnosticsDefaultWarning ctermfg=3
|
|
|
|
hi LspDiagnosticsDefaultInformation ctermfg=7
|
|
|
|
|
|
|
|
hi ALEErrorSign ctermfg=1
|
|
|
|
hi ALEWarningSign ctermfg=3
|
2022-02-15 21:07:11 +00:00
|
|
|
|
|
|
|
hi StatusLineMode ctermbg=1 ctermfg=0
|
|
|
|
hi StatusLineGitBranch ctermbg=5 ctermfg=0
|
|
|
|
hi StatusLineChar ctermbg=4 ctermfg=0
|
|
|
|
hi StatusLineFormat ctermbg=3 ctermfg=0
|
|
|
|
hi StatusLineFileType ctermbg=7 ctermfg=0
|
2022-10-16 03:20:55 +00:00
|
|
|
" }}}
|
2022-02-15 21:07:11 +00:00
|
|
|
|
2022-10-16 03:20:55 +00:00
|
|
|
" {{{ statusline
|
2022-02-15 21:07:11 +00:00
|
|
|
function! GetMode()
|
|
|
|
let l:m = mode(1)
|
|
|
|
|
|
|
|
if l:m ==# "i"
|
2022-04-04 03:02:21 +00:00
|
|
|
let l:mode = "INS"
|
2022-02-15 21:07:11 +00:00
|
|
|
elseif l:m ==# "c"
|
2022-04-04 03:02:21 +00:00
|
|
|
let l:mode = "CMD"
|
2022-02-15 21:07:11 +00:00
|
|
|
elseif l:m[0] ==# "R"
|
2022-04-04 03:02:21 +00:00
|
|
|
let l:mode = "REP"
|
2022-02-15 21:07:11 +00:00
|
|
|
elseif l:m ==# "Rv"
|
2022-04-04 03:02:21 +00:00
|
|
|
let l:mode = "REP"
|
2022-02-15 21:07:11 +00:00
|
|
|
elseif l:m =~# '\v(v|V| |s|S| )'
|
2022-04-04 03:02:21 +00:00
|
|
|
let l:mode = "VIS"
|
2022-02-15 21:07:11 +00:00
|
|
|
else
|
2022-04-04 03:02:21 +00:00
|
|
|
return ""
|
2022-02-15 21:07:11 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
return ' '.l:mode.' '
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! GitBranch()
|
|
|
|
let l:branch = gitbranch#name()
|
|
|
|
return strlen(l:branch) ? ' ' . l:branch . ' ' : ''
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
set statusline=
|
|
|
|
set statusline+=%#StatusLineMode#
|
|
|
|
set statusline+=%{GetMode()}
|
|
|
|
set statusline+=%#StatusLineGitBranch#
|
|
|
|
set statusline+=%{GitBranch()}
|
|
|
|
set statusline+=%*
|
|
|
|
set statusline+=\ %f
|
|
|
|
set statusline+=\ %m%r
|
|
|
|
set statusline+=%=
|
|
|
|
set statusline+=%#StatusLineChar#
|
|
|
|
set statusline+=\ %l,\ %c\
|
|
|
|
set statusline+=%#StatusLineFormat#
|
|
|
|
set statusline+=\ %{&fileencoding?&fileencoding:&encoding}\ %{&fileformat}\
|
|
|
|
set statusline+=%#StatusLineFileType#
|
|
|
|
set statusline+=\ %{&filetype}\
|
2022-10-16 03:20:55 +00:00
|
|
|
" }}}
|