[feat] change nvim config from vimscript to lua

This commit is contained in:
jay 2023-08-28 02:22:29 +08:00
parent 009c896650
commit 4fd1b70a5c
19 changed files with 700 additions and 604 deletions

View File

@ -0,0 +1,9 @@
-- HELPERS ----------------------------------------------------
local cmd = vim.cmd -- to execute Vim commands e.g. cmd('pwd')
local fn = vim.fn -- to call Vim functions e.g. fn.bufnr()
local g = vim.g -- a table to access global variables
local scopes = {o = vim.o, b = vim.bo, w = vim.wo}
-- Set CMD ----------------------------------------------------
require("basic")
-- Load Plugins ------------------------------------------------
require("plugins")

View File

@ -1,604 +0,0 @@
" vim: set ft=vim:
"*****************************************************************************
""" Vim-Plug core
"*****************************************************************************
let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim')
let curl_exists=expand('curl')
if !filereadable(vimplug_exists)
if !executable(curl_exists)
echoerr "You have to install curl or first install vim-plug yourself!"
execute "q!"
endif
echo "Installing Vim-Plug..."
echo ""
silent exec "!"curl_exists" -fLo " . shellescape(vimplug_exists) . " --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
let g:not_finish_vimplug = "yes"
autocmd VimEnter * PlugInstall
endif
" Required:
call plug#begin(expand('~/.config/nvim/plugged'))
Plug 'neovim/nvim-lspconfig'
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/cmp-cmdline'
" For vsnip users.
Plug 'hrsh7th/cmp-vsnip'
Plug 'hrsh7th/vim-vsnip'
Plug 'ray-x/lsp_signature.nvim'
Plug 'tomasr/molokai'
Plug 'scrooloose/nerdcommenter'
Plug 'vim-scripts/DrawIt'
Plug 'easymotion/vim-easymotion'
Plug 'mattn/emmet-vim'
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
Plug 'pangloss/vim-javascript'
Plug 'w0rp/ale'
Plug 'godlygeek/tabular'
Plug 'plasticboy/vim-markdown'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'kyazdani42/nvim-web-devicons' " for file icons
Plug 'kyazdani42/nvim-tree.lua'
Plug 'kien/tabman.vim'
" for git
Plug 'tpope/vim-fugitive'
Plug 'christoomey/vim-conflicted'
" for neogit
Plug 'NeogitOrg/neogit'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
" for mark
Plug 'inkarkat/vim-ingo-library'
Plug 'inkarkat/vim-mark'
Plug 'rking/ag.vim'
Plug 'terryma/vim-multiple-cursors'
" Plug 'vim-airline/vim-airline'
Plug 'nvim-lualine/lualine.nvim'
Plug 'akinsho/bufferline.nvim', { 'tag': 'v3.*' }
Plug 'lukas-reineke/indent-blankline.nvim'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'bluz71/vim-nightfly-colors', { 'as': 'nightfly' }
Plug 'folke/tokyonight.nvim', { 'branch': 'main' }
Plug 'norcalli/nvim-colorizer.lua'
" code outline
Plug 'stevearc/aerial.nvim'
" temp plugin
Plug 'tpope/vim-surround'
Plug 'buoto/gotests-vim'
Plug 'chr4/nginx.vim'
Plug 'cespare/vim-toml'
Plug 'zah/nim.vim'
Plug 'rust-lang/rust.vim'
Plug 'danilo-augusto/vim-afterglow'
Plug 'vim-scripts/TaskList.vim'
Plug 'google/vim-jsonnet'
Plug 'terrastruct/d2-vim'
Plug 'elkowar/yuck.vim'
Plug 'github/copilot.vim'
call plug#end()
syntax on
set number
set tabstop=2
set shiftwidth=2
set expandtab
set nofoldenable
set pastetoggle=<F2>
" always show status
set laststatus=2
" show cursor position
set ruler
set cursorline
set cursorcolumn
set hlsearch
" no wrap line
set nowrap
" enable backspace
set backspace=indent,eol,start
set encoding=utf-8
set completeopt=menu,menuone,noselect
set noswapfile
set mouse=
" set guifont=Hack\ Nerd\ Font:h11
set background=dark
function! AdaptColorscheme()
highlight clear CursorLine
highlight Normal ctermbg=none
highlight LineNr ctermbg=none
highlight Folded ctermbg=none
highlight NonText ctermbg=none
highlight SpecialKey ctermbg=none
highlight VertSplit ctermbg=none
highlight SignColumn ctermbg=none
endfunction
autocmd ColorScheme * call AdaptColorscheme()
" for chezmoi after edit auto apply
autocmd BufWritePost ~/.local/share/chezmoi/* ! chezmoi apply --source-path "%"
" define leader key
let mapleader=";"
filetype indent on
" 開啟檔案類型偵測
filetype on
" 根據檔案類型載入plugin
filetype plugin on
" split window
nmap <leader>sw <c-w>
nmap <leader>sww <c-w>k
nmap <leader>sws <c-w>j
nmap <leader>swa <c-w>h
nmap <leader>swd <c-w>l
nnoremap <leader>fl :Lines
nnoremap <leader>fb :BLines
nnoremap <leader>ff :Files
nnoremap <leader>fg :GFiles
nnoremap <leader>f? :GFiles?
nnoremap <leader>ft :Tags<cr>
nnoremap <leader>fa :Ag
nnoremap <leader>fc :Commits
nmap <leader>aa gT
nmap <leader>dd gt
nnoremap <leader>me :NvimTreeToggle<CR>
nnoremap <F3> :NvimTreeToggle<CR>
function! TabCloseRight(bang)
let cur=tabpagenr()
while cur < tabpagenr('$')
exe 'tabclose' . a:bang . ' ' . (cur + 1)
endwhile
endfunction
function! TabCloseLeft(bang)
while tabpagenr() > 1
exe 'tabclose' . a:bang . ' 1'
endwhile
endfunction
command! -bang Tabcloseright call TabCloseRight('<bang>')
command! -bang Tabcloseleft call TabCloseLeft('<bang>')
" tagbar
nmap <F9> :%!jq .<CR>
" NeoComplete
let g:neocomplete#enable_at_startup = 1
let g:airline_powerline_fonts = 1
" <Leader>f{char} to move to {char}
map <Leader>f <Plug>(easymotion-bd-f)
nmap <Leader>f <Plug>(easymotion-overwin-f)
" s{char}{char} to move to {char}{char}
nmap s <Plug>(easymotion-overwin-f2)
" Move to line
map <Leader>L <Plug>(easymotion-bd-jk)
nmap <Leader>L <Plug>(easymotion-overwin-line)
" Move to word
map <Leader>w <Plug>(easymotion-bd-w)
nmap <Leader>w <Plug>(easymotion-overwin-w)
" lint
let g:ale_linters = {
\ 'javascript': ["{{ if .nvim.js_linter }}{{- .nvim.js_linter }}{{ else }}standard{{ end }}"],
\ 'typescript': ["{{ if .nvim.js_linter }}{{- .nvim.js_linter }}{{ else }}standard{{ end }}"],
\ 'go': ['gopls'],
\ 'rust': ['analyzer'],
\}
let g:ale_fixers = {
\'javascript': ["{{ if .nvim.js_fixer }}{{- .nvim.js_fixer }}{{ else }}standard{{ end }}"],
\'typescript': ["{{ if .nvim.js_fixer }}{{- .nvim.js_fixer }}{{ else }}standard{{ end }}"],
\}
let g:ale_linters_explicit = 1
let g:ale_lint_on_save = 1
let g:ale_fix_on_save = 1
nmap <leader>= <Plug>(ale_fix)
" NERDCommenter
let g:NERDSpaceDelims=1
let g:NERDDefaultAlign='left'
" copilot setup
imap <silent><script><expr> <C-J> copilot#Accept("\<CR>")
let g:copilot_no_tab_map = v:true
" vim-go setting
autocmd FileType go nmap <leader>err <Plug>(go-iferr)
let g:go_fmt_fail_silently = 1
let g:go_fmt_command = "goimports"
let g:go_def_mode = 'godef'
let g:go_decls_includes = "func,type"
let g:go_highlight_types = 1
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_function_calls = 1
let g:go_highlight_operators = 1
let g:go_highlight_extra_types = 1
" for rust-vim
let g:rust_recommended_style = 0
let g:rustfmt_autosave = 1
let g:syntastic_rust_checkers = ['cargo']
" let g:airline#extensions#tabline#enabled = 1
" let g:airline#extensions#tabline#show_buffers = 0
" let g:airline#extensions#tabline#show_splits = 0
" let g:airline#extensions#tabline#show_tabs = 1
" let g:airline#extensions#tabline#show_tab_nr = 0
" let g:airline#extensions#tabline#show_tab_type = 0
" let g:airline#extensions#tabline#close_symbol = '×'
" let g:airline#extensions#tabline#show_close_button = 0
let g:multi_cursor_use_default_mapping=0
" Default mapping
let g:multi_cursor_start_word_key = "<C-n>"
let g:multi_cursor_select_all_word_key = '<A-n>'
let g:multi_cursor_start_key = "g<C-n>"
let g:multi_cursor_select_all_key = 'g<A-n>'
let g:multi_cursor_next_key = "<C-n>"
" let g:multi_cursor_prev_key = '<C-p>'
let g:multi_cursor_skip_key = '<C-x>'
let g:multi_cursor_quit_key = '<Esc>'
let g:javascript_plugin_jsdoc = 1
" fzf settings
" This is the default extra key bindings
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
" Default fzf layout
" - down / up / left / right
let g:fzf_layout = { 'down': '~40%' }
" Customize fzf colors to match your color scheme
let g:fzf_colors =
\ { 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'Comment'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
" Enable per-command history.
" CTRL-N and CTRL-P will be automatically bound to next-history and
" previous-history instead of down and up. If you don't like the change,
" explicitly bind the keys to down and up in your $FZF_DEFAULT_OPTS.
let g:fzf_history_dir = '~/.local/share/fzf-history'
lua << EOF
vim.g.nightflyTransparent = true
vim.cmd[[colorscheme nightfly]]
require('lualine').setup {
options = {
icons_enabled = true,
theme = 'auto',
component_separators = { left = '', right = ''},
section_separators = { left = '', right = ''},
disabled_filetypes = {
statusline = {},
winbar = {},
},
ignore_focus = {},
always_divide_middle = true,
globalstatus = false,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
}
},
sections = {
lualine_a = {'mode'},
lualine_b = {'branch', 'diff', 'diagnostics'},
lualine_c = {
{
'filename',
file_status = true,
newfile_status = true,
path = 1,
},
},
lualine_x = {'encoding', 'fileformat', 'filetype'},
lualine_y = {'progress'},
lualine_z = {'location'}
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {'filename'},
lualine_x = {'location'},
lualine_y = {},
lualine_z = {}
},
winbar = {},
inactive_winbar = {},
extensions = {}
}
require("bufferline").setup{
options = {
mode = "tabs",
diagnostics = "nvim_lsp",
}
}
vim.opt.list = true
-- vim.opt.listchars:append "eol:↴"
require("indent_blankline").setup {
show_end_of_line = true,
show_current_context = true,
show_current_context_start = true,
}
require'colorizer'.setup()
local nvlsp = require'lspconfig'
local lspSig = require'lsp_signature'
lspSig.setup{
hint_enable = true,
}
-- Add additional capabilities supported by nvim-cmp
local capabilities = require('cmp_nvim_lsp').default_capabilities()
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
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
lspSig.on_attach()
-- Enable completion triggered by <c-x><c-o>
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
local opts = { noremap=true, silent=true }
-- See `:help vim.lsp.*` for documentation on any of the below functions
-- buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
buf_set_keymap('n', '<leader>gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
buf_set_keymap('n', '<leader>gt', '<cmd>tab split<CR><cmd>lua vim.lsp.buf.definition()<CR>', opts)
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
buf_set_keymap('n', '<leader>gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
-- buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
-- buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
-- buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
buf_set_keymap('n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
buf_set_keymap('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
buf_set_keymap('n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
buf_set_keymap('n', '<leader>gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
buf_set_keymap('n', '<leader>ge', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
-- buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
-- buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
-- buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
-- buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
end
nvlsp['gopls'].setup{
capabilities = capabilities,
on_attach = on_attach,
}
nvlsp['tsserver'].setup{
capabilities = capabilities,
on_attach = on_attach,
}
nvlsp['rust_analyzer'].setup{
capabilities = capabilities,
on_attach = on_attach,
}
nvlsp['bashls'].setup{
capabilities = capabilities,
on_attach = on_attach,
}
-- nvim-cmp setup
local cmp = require 'cmp'
cmp.setup {
mapping = cmp.mapping.preset.insert({
['<CR>'] = cmp.mapping.confirm({
-- behavior = cmp.ConfirmBehavior.Insert,
select = true,
}),
['<C-e>'] = cmp.mapping.abort(),
-- ['<Tab>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 's' }),
}),
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,
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
}, {
{name = 'buffer'},
}),
}
--vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
-- vim.lsp.diagnostic.on_publish_diagnostics, {
-- virtual_text = false
-- }
--)
vim.diagnostic.config({virtual_text = false, signs = false})
require'nvim-tree'.setup {
auto_reload_on_write = true,
disable_netrw = false,
hijack_cursor = false,
hijack_netrw = true,
hijack_unnamed_buffer_when_opening = false,
open_on_tab = false,
sort_by = "name",
update_cwd = false,
view = {
width = 40,
side = "left",
preserve_window_proportions = false,
number = false,
relativenumber = false,
signcolumn = "yes",
mappings = {
custom_only = false,
list = {
-- user mappings go here
},
},
},
renderer = {
indent_markers = {
enable = false,
icons = {
corner = "└ ",
edge = "│ ",
none = " ",
},
},
},
hijack_directories = {
enable = true,
auto_open = true,
},
update_focused_file = {
enable = false,
update_cwd = false,
ignore_list = {},
},
system_open = {
cmd = nil,
args = {},
},
filters = {
dotfiles = false,
custom = {},
exclude = {},
},
git = {
enable = true,
ignore = true,
timeout = 400,
},
actions = {
use_system_clipboard = true,
change_dir = {
enable = true,
global = false,
},
open_file = {
quit_on_open = false,
resize_window = false,
window_picker = {
enable = true,
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
exclude = {
filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" },
buftype = { "nofile", "terminal", "help" },
},
},
},
},
}
require('aerial').setup({
backends = {"lsp", "treesitter"},
-- optionally use on_attach to set keymaps when aerial has attached to a buffer
on_attach = function(bufnr)
-- Jump forwards/backwards with '{' and '}'
vim.keymap.set('n', '{', '<cmd>AerialPrev<CR>', {buffer = bufnr})
vim.keymap.set('n', '}', '<cmd>AerialNext<CR>', {buffer = bufnr})
end,
-- filter_kind = false,
filter_kind = {
"Class",
"Constructor",
"Enum",
"Function",
"Interface",
"Module",
"Method",
"Struct",
"Variable",
"Namespace",
"Package",
"Field",
"Constant",
},
--manage_folds = true,
link_tree_to_folds = false,
-- Show box drawing characters for the tree hierarchy
show_guides = true,
-- Customize the characters used when show_guides = true
guides = {
-- When the child item has a sibling below it
mid_item = "├─",
-- When the child item is the last in the list
last_item = "└─",
-- When there are nested child guides to the right
nested_top = "│ ",
-- Raw indentation
whitespace = " ",
},
})
-- You probably also want to set a keymap to toggle aerial
vim.keymap.set('n', '<F8>', '<cmd>AerialToggle!<CR>')
local neogit = require('neogit')
neogit.setup {}
EOF

View File

@ -0,0 +1,50 @@
{
"DrawIt": { "branch": "master", "commit": "4e824fc939cec81dc2a8f4d91aaeb6151d1cc140" },
"TaskList.vim": { "branch": "master", "commit": "8e2dfdcc6e13d8afab5b3f620ee06ebb29b786f9" },
"aerial.nvim": { "branch": "master", "commit": "dc17cfd401689337124c75270677fd3b7639cf23" },
"ag.vim": { "branch": "master", "commit": "4a0dd6e190f446e5a016b44fdaa2feafc582918e" },
"ale": { "branch": "master", "commit": "115ad17ace047cab20ccc67f79c943aaf3f0f291" },
"bufferline.nvim": { "branch": "main", "commit": "d24378edc14a675c820a303b4512af3bbc5761e9" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" },
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp-vsnip": { "branch": "main", "commit": "989a8a73c44e926199bfd05fa7a516d51f2d2752" },
"copilot.vim": { "branch": "release", "commit": "172955782814a49fbebca2d1a2ccce2059103329" },
"ctrlp.vim": { "branch": "master", "commit": "7c972cb19c8544c681ca345c64ec39e04f4651cc" },
"emmet-vim": { "branch": "master", "commit": "def5d57a1ae5afb1b96ebe83c4652d1c03640f4d" },
"fzf": { "branch": "master", "commit": "5f66786ef1e65074daabb33d78a09d1f94576f15" },
"fzf.vim": { "branch": "master", "commit": "811f34b70b60b4df2997e3ba8cd109e7d06d683b" },
"gotests-vim": { "branch": "master", "commit": "42abccb59e9889cd1ce427b11b2ffbb36f2a46a6" },
"hop.nvim": { "branch": "master", "commit": "03f0434869f1f38868618198b5f4f2ab6d39aef2" },
"indent-blankline.nvim": { "branch": "master", "commit": "9637670896b68805430e2f72cf5d16be5b97a22a" },
"lazy.nvim": { "branch": "main", "commit": "2a9354c7d2368d78cbd5575a51a2af5bd8a6ad01" },
"lsp_signature.nvim": { "branch": "master", "commit": "58d4e810801da74c29313da86075d6aea537501f" },
"lualine.nvim": { "branch": "master", "commit": "45e27ca739c7be6c49e5496d14fcf45a303c3a63" },
"molokai": { "branch": "master", "commit": "c67bdfcdb31415aa0ade7f8c003261700a885476" },
"nerdcommenter": { "branch": "master", "commit": "d2e21d417f6c788b11ae3b90d7ac478930dead36" },
"nvim-cmp": { "branch": "main", "commit": "5dce1b778b85c717f6614e3f4da45e9f19f54435" },
"nvim-colorizer.lua": { "branch": "master", "commit": "36c610a9717cc9ec426a07c8e6bf3b3abcb139d6" },
"nvim-lspconfig": { "branch": "master", "commit": "a27356f1ef9c11e1f459cc96a3fcac5c265e72d6" },
"nvim-tree.lua": { "branch": "master", "commit": "00741206c2df9c4b538055def19b99790f0c95c8" },
"nvim-treesitter": { "branch": "master", "commit": "d0b17cc0b9c8c3055530770a9dd4de659232c692" },
"nvim-web-devicons": { "branch": "master", "commit": "cfc8824cc1db316a276b36517f093baccb8e799a" },
"rust.vim": { "branch": "master", "commit": "889b9a7515db477f4cb6808bef1769e53493c578" },
"tabman.vim": { "branch": "master", "commit": "8f2ca9268a2ec1bcb29231b5b3f872101d169901" },
"tabular": { "branch": "master", "commit": "339091ac4dd1f17e225fe7d57b48aff55f99b23a" },
"tokyonight.nvim": { "branch": "main", "commit": "1ee11019f8a81dac989ae1db1a013e3d582e2033" },
"vim-conflicted": { "branch": "master", "commit": "068c320796f807ac4961618e3e62316773803996" },
"vim-fugitive": { "branch": "master", "commit": "b3b838d690f315a503ec4af8c634bdff3b200aaf" },
"vim-go": { "branch": "master", "commit": "ec8f05bb24eb8324253b97f75d99114ad6565231" },
"vim-ingo-library": { "branch": "master", "commit": "f53fe3fa631f2a54f726514d70727bab43c5480d" },
"vim-javascript": { "branch": "master", "commit": "c470ce1399a544fe587eab950f571c83cccfbbdc" },
"vim-jsonnet": { "branch": "master", "commit": "4ebc6619ddce5d032a985b42a9864154c3d20e4a" },
"vim-mark": { "branch": "master", "commit": "0afec1d5bb2547a9357eecca54fbc5c6c6d178a7" },
"vim-markdown": { "branch": "master", "commit": "cc82d88e2a791f54d2b6e2b26e41f743351ac947" },
"vim-multiple-cursors": { "branch": "master", "commit": "6456718e1d30b42c04b920c5413ca44f68f08759" },
"vim-nightfly-colors": { "branch": "master", "commit": "06eaaaa8717538a7ce96b13c137da8c9eaa84ec8" },
"vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" },
"vim-toml": { "branch": "main", "commit": "d36caa6b1cf508a4df1c691f915572fc02143258" },
"vim-vsnip": { "branch": "master", "commit": "7753ba9c10429c29d25abfd11b4c60b76718c438" },
"yuck.vim": { "branch": "master", "commit": "9b5e0370f70cc30383e1dabd6c215475915fe5c3" }
}

View File

@ -0,0 +1,2 @@
require("basic.setup")
require('basic.mapping')

View File

@ -0,0 +1,19 @@
-- HELPERS ----------------------------------------------------
local cmd = vim.cmd -- to execute Vim commands e.g. cmd('pwd')
local fn = vim.fn -- to call Vim functions e.g. fn.bufnr()
local g = vim.g -- a table to access global variables
local keymap = vim.keymap -- keymap
local scopes = {o = vim.o, b = vim.bo, w = vim.wo}
g.mapleader = ';'
keymap.set('n', '<leader>sw', '<c-w>')
keymap.set('n', '<leader>sww', '<c-w>k')
keymap.set('n', '<leader>sws', '<c-w>j')
keymap.set('n', '<leader>swa', '<c-w>h')
keymap.set('n', '<leader>swd', '<c-w>l')
keymap.set('n', '<leader>aa', 'gT')
keymap.set('n', '<leader>dd', 'gt')
keymap.set('n', '<F9>', ':%!jq .<CR>')

View File

@ -0,0 +1,63 @@
-- HELPERS ----------------------------------------------------
local cmd = vim.cmd -- to execute Vim commands e.g. cmd('pwd')
local fn = vim.fn -- to call Vim functions e.g. fn.bufnr()
local g = vim.g -- a table to access global variables
local scopes = {o = vim.o, b = vim.bo, w = vim.wo}
cmd "syntax on"
cmd "set number"
cmd "set tabstop=2"
cmd "set shiftwidth=2"
cmd "set expandtab"
cmd "set nofoldenable"
cmd "set pastetoggle=<F2>"
-- always show status
cmd "set laststatus=2"
-- show cursor position
cmd "set ruler"
cmd "set cursorline"
cmd "set cursorcolumn"
cmd "set hlsearch"
-- no wrap line
cmd "set nowrap"
-- enable backspace
cmd "set backspace=indent,eol,start"
cmd "set encoding=utf-8"
cmd "set completeopt=menu,menuone,noselect"
cmd "set noswapfile"
cmd "set mouse="
cmd "set background=dark"
cmd "filetype indent on"
cmd "filetype on"
cmd "filetype plugin on"
vim.api.nvim_create_autocmd("ColorScheme", {
pattern = "*",
callback = function()
cmd([[
highlight clear CursorLine
highlight Normal ctermbg=none
highlight LineNr ctermbg=none
highlight Folded ctermbg=none
highlight NonText ctermbg=none
highlight SpecialKey ctermbg=none
highlight VertSplit ctermbg=none
highlight SignColumn ctermbg=none
]])
end,
})
vim.api.nvim_create_autocmd("BufWritePost", {
pattern = "~/.local/share/chezmoi/*",
command = [[ ! chezmoi apply --source-path % ]],
})
vim.diagnostic.config({virtual_text = false, signs = false})

View File

@ -0,0 +1,48 @@
return {
"stevearc/aerial.nvim",
keys = {
{'<F8>', '<cmd>AerialToggle<CR>', desc = 'toggle aerial window', mode = 'n'},
},
opts = {
backends = {"lsp", "treesitter"},
-- optionally use on_attach to set keymaps when aerial has attached to a buffer
on_attach = function(bufnr)
-- Jump forwards/backwards with '{' and '}'
vim.keymap.set('n', '{', '<cmd>AerialPrev<CR>', {buffer = bufnr})
vim.keymap.set('n', '}', '<cmd>AerialNext<CR>', {buffer = bufnr})
end,
-- filter_kind = false,
filter_kind = {
"Class",
"Constructor",
"Enum",
"Function",
"Interface",
"Module",
"Method",
"Struct",
"Variable",
"Namespace",
"Package",
"Field",
"Constant",
},
--manage_folds = true,
link_tree_to_folds = false,
-- Show box drawing characters for the tree hierarchy
show_guides = true,
-- Customize the characters used when show_guides = true
guides = {
-- When the child item has a sibling below it
mid_item = "├─",
-- When the child item is the last in the list
last_item = "└─",
-- When there are nested child guides to the right
nested_top = "",
-- Raw indentation
whitespace = " ",
},
}
}

View File

@ -0,0 +1,26 @@
return {
"w0rp/ale",
lazy = false,
keys = {
{'<leader>=', '<Plug>(ale_fix)', mode = 'n'},
},
config = function ()
local g = vim.g
g.ale_linters = {
javascript = {'{{ if .nvim.js_linter }}{{ .nvim.js_linter }}{{ else }}eslint{{ end }}'},
typescript = {'{{ if .nvim.js_linter }}{{ .nvim.js_linter }}{{ else }}eslint{{ end }}'},
go = {'gopls'},
rust = {'analyzer'},
}
g.ale_fixers = {
javascript = {'{{ if .nvim.js_fixer }}{{ .nvim.js_fixer }}{{ else }}eslint{{ end }}'},
typescript = {'{{ if .nvim.js_fixer }}{{ .nvim.js_fixer }}{{ else }}eslint{{ end }}'},
}
g.ale_linters_explicit = 1
g.ale_lint_on_save = 1
g.ale_fix_on_save = 1
end
}

View File

@ -0,0 +1,10 @@
return {
"akinsho/bufferline.nvim",
version = "v4.*",
opts = {
options = {
mode = 'tabs',
diagnostics = 'nvim_lsp',
},
},
}

View File

@ -0,0 +1,42 @@
return {
"junegunn/fzf.vim",
dependencies = {
"junegunn/fzf",
},
config = function ()
local g = vim.g
local keymap = vim.keymap
g.fzf_action = {
['ctrl-t'] = 'tab split',
['ctrl-x'] = 'split',
['ctrl-v'] = 'vsplit',
}
g.fzf_colors = {
fg = {'fg', 'Normal'},
bg = {'bg', 'Normal'},
hl = {'fg', 'Comment'},
['fg+'] = {'fg', 'CursorLine', 'CursorColumn', 'Normal'},
['bg+'] = {'bg', 'CursorLine', 'CursorColumn'},
['hl+'] = {'fg', 'Statement'},
info = {'fg', 'PreProc'},
prompt = {'fg', 'Conditional'},
pointer = {'fg', 'Exception'},
marker = {'fg', 'Keyword'},
spinner = {'fg', 'Label'},
header = {'fg', 'Comment'},
}
g.fzf_history_dir = '~/.local/share/fzf-history'
keymap.set('n', '<leader>fl', ':Lines ')
keymap.set('n', '<leader>fb', ':BLines ')
keymap.set('n', '<leader>ff', ':Files ')
keymap.set('n', '<leader>fg', ':GFiles ')
keymap.set('n', '<leader>f?', ':GFiles? ')
keymap.set('n', '<leader>ft', ':Tags<cr>')
keymap.set('n', '<leader>fa', ':Ag ')
keymap.set('n', '<leader>fc', ':Commits ')
end
}

View File

@ -0,0 +1,26 @@
return {
"fatih/vim-go",
lazy = false,
keys = {},
config = function ()
vim.api.nvim_create_autocmd("FileType", {
pattern = 'go',
callback = function ()
vim.keymap.set('n', '<leader>err', '<Plug>(go-iferr)')
end
})
local g = vim.g
g.go_fmt_fail_silently = 1
g.go_fmt_command = "goimports"
g.go_def_mode = 'godef'
g.go_decls_includes = "func,type"
g.go_highlight_types = 1
g.go_highlight_fields = 1
g.go_highlight_functions = 1
g.go_highlight_function_calls = 1
g.go_highlight_operators = 1
g.go_highlight_extra_types = 1
end
}

View File

@ -0,0 +1,19 @@
return {
"phaazon/hop.nvim",
config = function ()
local hop = require('hop')
local keymap = vim.keymap
hop.setup()
-- keymap.set('', '<leader>f', function ()
-- hop.hint_char1()
-- end)
keymap.set('', '<leader>s', function ()
hop.hint_char2()
end)
keymap.set('', '<leader>w', function ()
hop.hint_words()
end)
end
}

View File

@ -0,0 +1,11 @@
return {
"lukas-reineke/indent-blankline.nvim",
opts = {
show_end_of_line = true,
show_current_context = true,
show_current_context_start = true,
},
config = function ()
vim.opt.list = true
end
}

View File

@ -0,0 +1,18 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require('lazy').setup("plugins.list", {
defaults = {
lazy = false
},
})

View File

@ -0,0 +1,127 @@
return {
require('plugins.nvim_cmp'),
require('plugins.lsp'),
{
"ray-x/lsp_signature.nvim",
opts = {
hint_enable = true,
},
},
{
"scrooloose/nerdcommenter",
config = function ()
vim.g.NERDSpaceDelims=1
vim.g.NERDDefaultAlign='left'
end
},
"vim-scripts/DrawIt",
-- easymotion alternative
require('plugins.hop'),
require('plugins.ale'),
"mattn/emmet-vim",
require('plugins.go'),
{
"pangloss/vim-javascript",
config = function ()
vim.g.javascript_plugin_jsdoc = 1
end
},
"godlygeek/tabular",
"plasticboy/vim-markdown",
"ctrlpvim/ctrlp.vim",
-- fzf
require('plugins.fzf'),
"kyazdani42/nvim-web-devicons",
require('plugins.nvim_tree'),
"kien/tabman.vim",
-- for git
"tpope/vim-fugitive",
"christoomey/vim-conflicted",
-- for mark
"inkarkat/vim-ingo-library",
"inkarkat/vim-mark",
"rking/ag.vim",
{
"terryma/vim-multiple-cursors",
config = function ()
local g = vim.g
g.multi_cursor_use_default_mapping=0
-- Default mapping
g.multi_cursor_start_word_key = "<C-n>"
g.multi_cursor_select_all_word_key = '<A-n>'
g.multi_cursor_start_key = "g<C-n>"
g.multi_cursor_select_all_key = 'g<A-n>'
g.multi_cursor_next_key = "<C-n>"
g.multi_cursor_skip_key = '<C-x>'
g.multi_cursor_quit_key = '<Esc>'
end
},
require('plugins.lualine'),
require('plugins.bufferline'),
require('plugins.indent_blankline'),
"nvim-treesitter/nvim-treesitter",
{
"bluz71/vim-nightfly-colors",
config = function ()
vim.g.nightflyTransparent = true
vim.cmd[[ colorscheme nightfly ]]
end
},
{
"folke/tokyonight.nvim",
branch = "main",
},
"norcalli/nvim-colorizer.lua",
-- code outline
require('plugins.aerial'),
"tpope/vim-surround",
"buoto/gotests-vim",
"cespare/vim-toml",
{
"rust-lang/rust.vim",
config = function ()
local g = vim.g
g.rust_recommended_style = 0
g.rustfmt_autosave = 1
g.syntastic_rust_checkers = {'cargo'}
end
},
"vim-scripts/TaskList.vim",
"google/vim-jsonnet",
{
"github/copilot.vim",
keys = {
{'<c-j>', 'copilot#Accept("<CR>")', mode = 'i', silent = true, expr = true, noremap = true, replace_keycodes = false},
},
lazy = false,
init = function ()
vim.g.copilot_no_tab_map = true
end
},
-- temp plugins
"elkowar/yuck.vim",
-- themes
"tomasr/molokai",
}

View File

@ -0,0 +1,64 @@
return {
"neovim/nvim-lspconfig",
dependencies = {
{
"hrsh7th/cmp-nvim-lsp",
},
},
config = function ()
local capabilities = require('cmp_nvim_lsp').default_capabilities()
local on_attach = function (client, bufnr)
local lspSig = require('lsp_signature')
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
lspSig.on_attach()
-- enable completion triggered by <c-x><c-o>
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- mappings
local opts = { noremap=true, silent=true }
-- See `:help vim.lsp.*` for documentation on any of the below functions
-- buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
buf_set_keymap('n', '<leader>gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
buf_set_keymap('n', '<leader>gt', '<cmd>tab split<CR><cmd>lua vim.lsp.buf.definition()<CR>', opts)
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
buf_set_keymap('n', '<leader>gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
-- buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
-- buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
-- buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
buf_set_keymap('n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
buf_set_keymap('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
buf_set_keymap('n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
buf_set_keymap('n', '<leader>gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
buf_set_keymap('n', '<leader>ge', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
-- buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
-- buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
-- buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
-- buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
end
local nvlsp = require('lspconfig')
nvlsp['gopls'].setup{
capabilities = capabilities,
on_attach = on_attach,
}
nvlsp['tsserver'].setup{
capabilities = capabilities,
on_attach = on_attach,
}
nvlsp['rust_analyzer'].setup{
capabilities = capabilities,
on_attach = on_attach,
}
nvlsp['bashls'].setup{
capabilities = capabilities,
on_attach = on_attach,
}
end
}

View File

@ -0,0 +1,49 @@
return {
"nvim-lualine/lualine.nvim",
opts = {
options = {
icons_enabled = true,
theme = 'auto',
component_separators = { left = '', right = ''},
section_separators = { left = '', right = ''},
disabled_filetypes = {
statusline = {},
winbar = {},
},
ignore_focus = {},
always_divide_middle = true,
globalstatus = false,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
}
},
sections = {
lualine_a = {'mode'},
lualine_b = {'branch', 'diff', 'diagnostics'},
lualine_c = {
{
'filename',
file_status = true,
newfile_status = true,
path = 1,
},
},
lualine_x = {'encoding', 'fileformat', 'filetype'},
lualine_y = {'progress'},
lualine_z = {'location'}
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {'filename'},
lualine_x = {'location'},
lualine_y = {},
lualine_z = {}
},
winbar = {},
inactive_winbar = {},
extensions = {}
}
}

View File

@ -0,0 +1,40 @@
return {
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
-- for vsnip users
"hrsh7th/cmp-vsnip",
"hrsh7th/vim-vsnip",
},
opts = function ()
local cmp = require('cmp')
return {
mapping = cmp.mapping.preset.insert({
['<CR>'] = cmp.mapping.confirm({
-- behavior = cmp.ConfirmBehavior.Insert,
select = true,
}),
['<C-e>'] = cmp.mapping.abort(),
-- ['<Tab>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 's' }),
}),
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,
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
}, {
{name = 'buffer'},
}),
}
end
}

View File

@ -0,0 +1,77 @@
return {
"kyazdani42/nvim-tree.lua",
keys = {
{"<leader>me", ':NvimTreeToggle<CR>', desc = 'open / close nvim tree', mode = 'n'},
{"<F3>", ':NvimTreeToggle<CR>', desc = 'open / close nvim tree', mode = 'n'}
},
opts = {
auto_reload_on_write = true,
disable_netrw = false,
hijack_cursor = false,
hijack_netrw = true,
hijack_unnamed_buffer_when_opening = false,
open_on_tab = false,
sort_by = "name",
update_cwd = false,
view = {
width = 40,
side = "left",
preserve_window_proportions = false,
number = false,
relativenumber = false,
signcolumn = "yes",
},
renderer = {
indent_markers = {
enable = false,
icons = {
corner = "",
edge = "",
none = " ",
},
},
},
hijack_directories = {
enable = true,
auto_open = true,
},
update_focused_file = {
enable = false,
update_cwd = false,
ignore_list = {},
},
system_open = {
cmd = nil,
args = {},
},
filters = {
dotfiles = false,
custom = {},
exclude = {},
},
git = {
enable = true,
ignore = true,
timeout = 400,
},
actions = {
use_system_clipboard = true,
change_dir = {
enable = true,
global = false,
},
open_file = {
quit_on_open = false,
resize_window = false,
window_picker = {
enable = true,
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
exclude = {
filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" },
buftype = { "nofile", "terminal", "help" },
},
},
},
},
}
}