init
This commit is contained in:
commit
f470e78d1c
35
after/ftplugin/cpp.vim
Normal file
35
after/ftplugin/cpp.vim
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
set commentstring=//\ %s
|
||||||
|
|
||||||
|
" Disable inserting comment leader after hitting o or O or <Enter>
|
||||||
|
set formatoptions-=o
|
||||||
|
set formatoptions-=r
|
||||||
|
|
||||||
|
nnoremap <silent> <buffer> <F9> :call <SID>compile_run_cpp()<CR>
|
||||||
|
|
||||||
|
function! s:compile_run_cpp() abort
|
||||||
|
let src_path = expand('%:p:~')
|
||||||
|
let src_noext = expand('%:p:~:r')
|
||||||
|
let _flag = '-Wall -Wextra -std=c++11 -O2'
|
||||||
|
|
||||||
|
if executable('clang++')
|
||||||
|
let prog = 'clang++'
|
||||||
|
elseif executable('g++')
|
||||||
|
let prog = 'g++'
|
||||||
|
else
|
||||||
|
echoerr 'No C++ compiler found on the system!'
|
||||||
|
endif
|
||||||
|
call s:create_term_buf('h', 20)
|
||||||
|
execute printf('term %s %s %s -o %s && %s', prog, _flag, src_path, src_noext, src_noext)
|
||||||
|
startinsert
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function s:create_term_buf(_type, size) abort
|
||||||
|
set splitbelow
|
||||||
|
set splitright
|
||||||
|
if a:_type ==# 'v'
|
||||||
|
vnew
|
||||||
|
else
|
||||||
|
new
|
||||||
|
endif
|
||||||
|
execute 'resize ' . a:size
|
||||||
|
endfunction
|
1
after/ftplugin/gitconfig.vim
Normal file
1
after/ftplugin/gitconfig.vim
Normal file
@ -0,0 +1 @@
|
|||||||
|
set commentstring=#\ %s
|
3
after/ftplugin/javascript.vim
Normal file
3
after/ftplugin/javascript.vim
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
" Disable inserting comment leader after hitting o or O or <Enter>
|
||||||
|
set formatoptions-=o
|
||||||
|
set formatoptions-=r
|
6
after/ftplugin/lua.vim
Normal file
6
after/ftplugin/lua.vim
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
" Disable inserting comment leader after hitting o or O or <Enter>
|
||||||
|
set formatoptions-=o
|
||||||
|
set formatoptions-=r
|
||||||
|
|
||||||
|
nnoremap <buffer><silent> <F9> :luafile %<CR>
|
||||||
|
nnoremap <buffer><silent> <space>f <cmd>silent !stylua %<CR>
|
97
after/ftplugin/markdown.lua
Normal file
97
after/ftplugin/markdown.lua
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
local function add_reference_at_end(label, url, title)
|
||||||
|
vim.schedule(function()
|
||||||
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
|
local line_count = vim.api.nvim_buf_line_count(bufnr)
|
||||||
|
|
||||||
|
local ref_def = "[" .. label .. "]: " .. url
|
||||||
|
if title and title ~= "" then
|
||||||
|
ref_def = ref_def .. ' "' .. title .. '"'
|
||||||
|
end
|
||||||
|
|
||||||
|
local buffer_lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false)
|
||||||
|
local has_ref_section = false
|
||||||
|
for _, line in ipairs(buffer_lines) do
|
||||||
|
if line:match("^%s*<!%-%-.*[Rr]eferences.*%-%->[%s]*$") then
|
||||||
|
has_ref_section = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local lines_to_add = {}
|
||||||
|
if not has_ref_section then
|
||||||
|
if #lines_to_add == 0 then
|
||||||
|
table.insert(lines_to_add, "")
|
||||||
|
end
|
||||||
|
table.insert(lines_to_add, "<!-- References -->")
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(lines_to_add, ref_def)
|
||||||
|
|
||||||
|
vim.api.nvim_buf_set_lines(bufnr, line_count, line_count, false, lines_to_add)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_ref_link_labels()
|
||||||
|
local labels = {}
|
||||||
|
local seen = {}
|
||||||
|
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false)
|
||||||
|
|
||||||
|
for _, line in ipairs(lines) do
|
||||||
|
-- %[.-%] matches [link text] (non-greedy)
|
||||||
|
-- %[(.-)%] matches [label] and captures the label content
|
||||||
|
local start_pos = 1
|
||||||
|
while start_pos <= #line do
|
||||||
|
local match_start, match_end, label = string.find(line, "%[.-%]%[(.-)%]", start_pos)
|
||||||
|
if not match_start then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
|
if label and label ~= "" and not seen[label] then
|
||||||
|
table.insert(labels, label)
|
||||||
|
seen[label] = true
|
||||||
|
end
|
||||||
|
|
||||||
|
start_pos = match_end + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return labels
|
||||||
|
end
|
||||||
|
|
||||||
|
local function count_consecutive_spaces(str)
|
||||||
|
-- Remove leading spaces first
|
||||||
|
local trimmed = str:match("^%s*(.*)")
|
||||||
|
local count = 0
|
||||||
|
|
||||||
|
-- Count each sequence of one or more consecutive spaces
|
||||||
|
for spaces in trimmed:gmatch("%s+") do
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
return count
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_buf_create_user_command(0, "AddRef", function(opts)
|
||||||
|
local args = vim.split(opts.args, " ", { trimempty = true })
|
||||||
|
if #args < 2 then
|
||||||
|
vim.print("Usage: :AddRef <label> <url>")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local label = args[1]
|
||||||
|
local url = args[2]
|
||||||
|
|
||||||
|
add_reference_at_end(label, url, "")
|
||||||
|
end, {
|
||||||
|
desc = "Add reference link at buffer end",
|
||||||
|
nargs = "+",
|
||||||
|
complete = function(arg_lead, cmdline, curpos)
|
||||||
|
vim.print(string.format("arg_lead: '%s', cmdline: '%s', curpos: %d", arg_lead, cmdline, curpos))
|
||||||
|
|
||||||
|
if count_consecutive_spaces(cmdline) > 1 then
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
|
local ref_link_labels = get_ref_link_labels()
|
||||||
|
return ref_link_labels
|
||||||
|
end,
|
||||||
|
})
|
67
after/ftplugin/markdown.vim
Normal file
67
after/ftplugin/markdown.vim
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
set concealcursor=c
|
||||||
|
set wrap
|
||||||
|
|
||||||
|
" Fix minor issue with footnote, see https://github.com/vim-pandoc/vim-markdownfootnotes/issues/22
|
||||||
|
if exists(':FootnoteNumber')
|
||||||
|
nnoremap <buffer><silent> ^^ :<C-U>call markdownfootnotes#VimFootnotes('i')<CR>
|
||||||
|
inoremap <buffer><silent> ^^ <C-O>:<C-U>call markdownfootnotes#VimFootnotes('i')<CR>
|
||||||
|
imap <buffer> <silent> @@ <Plug>ReturnFromFootnote
|
||||||
|
nmap <buffer> <silent> @@ <Plug>ReturnFromFootnote
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Text objects for Markdown code blocks
|
||||||
|
xnoremap <buffer><silent> ic :<C-U>call text_obj#MdCodeBlock('i')<CR>
|
||||||
|
xnoremap <buffer><silent> ac :<C-U>call text_obj#MdCodeBlock('a')<CR>
|
||||||
|
onoremap <buffer><silent> ic :<C-U>call text_obj#MdCodeBlock('i')<CR>
|
||||||
|
onoremap <buffer><silent> ac :<C-U>call text_obj#MdCodeBlock('a')<CR>
|
||||||
|
|
||||||
|
" Use + to turn several lines into an unorderd list
|
||||||
|
" Ref: https://vi.stackexchange.com/q/5495/15292 and https://stackoverflow.com/q/42438795/6064933
|
||||||
|
nnoremap <buffer><silent> + :set operatorfunc=AddListSymbol<CR>g@
|
||||||
|
xnoremap <buffer><silent> + :<C-U> call AddListSymbol(visualmode(), 1)<CR>
|
||||||
|
|
||||||
|
function! AddListSymbol(type, ...) abort
|
||||||
|
if a:0
|
||||||
|
let line_start = line("'<")
|
||||||
|
let line_end = line("'>")
|
||||||
|
else
|
||||||
|
let line_start = line("'[")
|
||||||
|
let line_end = line("']")
|
||||||
|
endif
|
||||||
|
|
||||||
|
" add list symbol to each line
|
||||||
|
for line in range(line_start, line_end)
|
||||||
|
let text = getline(line)
|
||||||
|
|
||||||
|
let l:end = matchend(text, '^\s*')
|
||||||
|
if l:end == 0
|
||||||
|
let new_text = '+ ' . text
|
||||||
|
else
|
||||||
|
let new_text = text[0 : l:end-1] . ' + ' . text[l:end :]
|
||||||
|
endif
|
||||||
|
|
||||||
|
call setline(line, new_text)
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Add hard line breaks for Markdown
|
||||||
|
nnoremap <buffer><silent> \ :set operatorfunc=AddLineBreak<CR>g@
|
||||||
|
xnoremap <buffer><silent> \ :<C-U> call AddLineBreak(visualmode(), 1)<CR>
|
||||||
|
|
||||||
|
function! AddLineBreak(type, ...) abort
|
||||||
|
if a:0
|
||||||
|
let line_start = line("'<")
|
||||||
|
let line_end = line("'>")
|
||||||
|
else
|
||||||
|
let line_start = line("'[")
|
||||||
|
let line_end = line("']")
|
||||||
|
endif
|
||||||
|
|
||||||
|
for line in range(line_start, line_end)
|
||||||
|
let text = getline(line)
|
||||||
|
" add backslash to each line
|
||||||
|
let new_text = text . "\\"
|
||||||
|
|
||||||
|
call setline(line, new_text)
|
||||||
|
endfor
|
||||||
|
endfunction
|
16
after/ftplugin/python.vim
Normal file
16
after/ftplugin/python.vim
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
if exists(':AsyncRun')
|
||||||
|
nnoremap <buffer><silent> <F9> :<C-U>AsyncRun python -u "%"<CR>
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Do not wrap Python source code.
|
||||||
|
set nowrap
|
||||||
|
set sidescroll=5
|
||||||
|
set sidescrolloff=2
|
||||||
|
set colorcolumn=100
|
||||||
|
|
||||||
|
set tabstop=4
|
||||||
|
set softtabstop=4
|
||||||
|
set shiftwidth=4
|
||||||
|
set expandtab
|
||||||
|
|
||||||
|
nnoremap <buffer><silent> <space>f <cmd>silent !black %<CR>
|
6
after/ftplugin/qf.vim
Normal file
6
after/ftplugin/qf.vim
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
" Set quickfix window height, see also https://github.com/lervag/vimtex/issues/1127
|
||||||
|
function! AdjustWindowHeight(minheight, maxheight)
|
||||||
|
execute max([a:minheight, min([line('$'), a:maxheight])]), 'wincmd _'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call AdjustWindowHeight(5, 15)
|
1
after/ftplugin/sql.vim
Normal file
1
after/ftplugin/sql.vim
Normal file
@ -0,0 +1 @@
|
|||||||
|
set commentstring=--\ %s
|
2
after/ftplugin/tex.lua
Normal file
2
after/ftplugin/tex.lua
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
vim.o.textwidth = 120
|
||||||
|
vim.o.wrap = true
|
1
after/ftplugin/text.vim
Normal file
1
after/ftplugin/text.vim
Normal file
@ -0,0 +1 @@
|
|||||||
|
set colorcolumn=
|
12
after/ftplugin/vim.vim
Normal file
12
after/ftplugin/vim.vim
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
" Disable inserting comment leader after hitting o or O or <Enter>
|
||||||
|
set formatoptions-=o
|
||||||
|
set formatoptions-=r
|
||||||
|
|
||||||
|
" Set the folding related options for vimscript. Setting folding option in
|
||||||
|
" modeline is annoying in that the modeline gets executed each time the window
|
||||||
|
" focus is lost
|
||||||
|
set foldmethod=expr foldexpr=utils#VimFolds(v:lnum) foldtext=utils#MyFoldText()
|
||||||
|
|
||||||
|
set keywordprg=:help
|
||||||
|
|
||||||
|
nnoremap <buffer><silent> <F9> :source %<CR>
|
4
after/ftplugin/yaml.vim
Normal file
4
after/ftplugin/yaml.vim
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
" Turn off syntax highlighting for large YAML files
|
||||||
|
if line('$') > 500
|
||||||
|
setlocal syntax=OFF
|
||||||
|
endif
|
3
after/lsp/clangd.lua
Normal file
3
after/lsp/clangd.lua
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
return {
|
||||||
|
filetypes = { "c", "cpp", "cc" },
|
||||||
|
}
|
8
after/lsp/ltex.lua
Normal file
8
after/lsp/ltex.lua
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
return {
|
||||||
|
filetypes = { "text", "plaintex", "tex", "markdown" },
|
||||||
|
settings = {
|
||||||
|
ltex = {
|
||||||
|
language = "en",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
13
after/lsp/lua_ls.lua
Normal file
13
after/lsp/lua_ls.lua
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
-- settings for lua-language-server can be found on https://luals.github.io/wiki/settings
|
||||||
|
return {
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
runtime = {
|
||||||
|
version = "LuaJIT",
|
||||||
|
},
|
||||||
|
hint = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
43
after/lsp/pyright.lua
Normal file
43
after/lsp/pyright.lua
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
local new_capability = {
|
||||||
|
-- remove some of the diagnostics that duplicates those from ruff
|
||||||
|
textDocument = {
|
||||||
|
publishDiagnostics = {
|
||||||
|
tagSupport = {
|
||||||
|
valueSet = { 2 },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
hover = {
|
||||||
|
contentFormat = { "plaintext" },
|
||||||
|
dynamicRegistration = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
cmd = { "delance-langserver", "--stdio" },
|
||||||
|
settings = {
|
||||||
|
pyright = {
|
||||||
|
-- disable import sorting and use ruff for this
|
||||||
|
disableOrganizeImports = true,
|
||||||
|
disableTaggedHints = false,
|
||||||
|
},
|
||||||
|
python = {
|
||||||
|
analysis = {
|
||||||
|
autoSearchPaths = true,
|
||||||
|
diagnosticMode = "workspace",
|
||||||
|
typeCheckingMode = "standard",
|
||||||
|
useLibraryCodeForTypes = true,
|
||||||
|
diagnosticSeverityOverrides = {
|
||||||
|
deprecateTypingAliases = false,
|
||||||
|
},
|
||||||
|
inlayHints = {
|
||||||
|
callArgumentNames = "partial",
|
||||||
|
functionReturnTypes = true,
|
||||||
|
pytestParameters = true,
|
||||||
|
variableTypes = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
capabilities = new_capability,
|
||||||
|
}
|
8
after/lsp/ruff.lua
Normal file
8
after/lsp/ruff.lua
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
-- Settings can be found here: https://docs.astral.sh/ruff/editors/settings/
|
||||||
|
return {
|
||||||
|
init_options = {
|
||||||
|
settings = {
|
||||||
|
organizeImports = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
27
autoload/buf_utils.vim
Normal file
27
autoload/buf_utils.vim
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
function! buf_utils#GoToBuffer(count, direction) abort
|
||||||
|
if a:count == 0
|
||||||
|
if a:direction ==# 'forward'
|
||||||
|
bnext
|
||||||
|
elseif a:direction ==# 'backward'
|
||||||
|
bprevious
|
||||||
|
else
|
||||||
|
echoerr 'Bad argument ' a:direction
|
||||||
|
endif
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
"Check validity of buffer number
|
||||||
|
if index(s:GetBufNums(), a:count) == -1
|
||||||
|
call v:lua.vim.notify('Invalid bufnr: ' . a:count, 4, {'tile': 'nvim-config'})
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Do not use {count} for gB (it is less useful)
|
||||||
|
if a:direction ==# 'forward'
|
||||||
|
silent execute('buffer', a:count)
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:GetBufNums() abort
|
||||||
|
return map(copy(getbufinfo({'buflisted':1})), 'v:val.bufnr')
|
||||||
|
endfunction
|
67
autoload/text_obj.vim
Normal file
67
autoload/text_obj.vim
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
function! text_obj#URL() abort
|
||||||
|
if match(&runtimepath, 'vim-highlighturl') != -1
|
||||||
|
let url_pattern = highlighturl#default_pattern()
|
||||||
|
else
|
||||||
|
let url_pattern = expand('<cfile>')
|
||||||
|
if len(url_pattern) <= 10
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Find all URLs on the line and determine if the cursor is on one of them
|
||||||
|
let line_text = getline('.')
|
||||||
|
let url_infos = []
|
||||||
|
|
||||||
|
let [_url, _idx_start, _idx_end] = matchstrpos(line_text, url_pattern)
|
||||||
|
while _url !=# ''
|
||||||
|
let url_infos += [[_url, _idx_start+1, _idx_end]]
|
||||||
|
let [_url, _idx_start, _idx_end] = matchstrpos(line_text, url_pattern, _idx_end)
|
||||||
|
endwhile
|
||||||
|
|
||||||
|
if len(url_infos) == 0
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
let [start_col, end_col] = [-1, -1]
|
||||||
|
let [buf_num, cur_row, cur_col] = getcurpos()[0:2]
|
||||||
|
for url_info in url_infos
|
||||||
|
let [_url, _idx_start, _idx_end] = url_info
|
||||||
|
if cur_col >= _idx_start && cur_col <= _idx_end
|
||||||
|
let start_col = _idx_start
|
||||||
|
let end_col = _idx_end
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
|
||||||
|
if start_col == -1
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
call setpos("'<", [buf_num, cur_row, start_col, 0])
|
||||||
|
call setpos("'>", [buf_num, cur_row, end_col, 0])
|
||||||
|
normal! gv
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! text_obj#MdCodeBlock(type) abort
|
||||||
|
normal! $
|
||||||
|
let start_row = searchpos('\s*```', 'bnW')[0]
|
||||||
|
let end_row = searchpos('\s*```', 'nW')[0]
|
||||||
|
|
||||||
|
let buf_num = bufnr()
|
||||||
|
if a:type ==# 'i'
|
||||||
|
let start_row += 1
|
||||||
|
let end_row -= 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
call setpos("'<", [buf_num, start_row, 1, 0])
|
||||||
|
call setpos("'>", [buf_num, end_row, 1, 0])
|
||||||
|
execute 'normal! `<V`>'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! text_obj#Buffer() abort
|
||||||
|
let buf_num = bufnr()
|
||||||
|
|
||||||
|
call setpos("'<", [buf_num, 1, 1, 0])
|
||||||
|
call setpos("'>", [buf_num, line('$'), 1, 0])
|
||||||
|
execute 'normal! `<V`>'
|
||||||
|
endfunction
|
130
autoload/utils.vim
Normal file
130
autoload/utils.vim
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
function! utils#Cabbrev(key, value) abort
|
||||||
|
execute printf('cabbrev <expr> %s (getcmdtype() == ":" && getcmdpos() <= %d) ? %s : %s',
|
||||||
|
\ a:key, 1 + len(a:key), <SID>Single_quote(a:value), <SID>Single_quote(a:key))
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:Single_quote(str) abort
|
||||||
|
return "'" . substitute(copy(a:str), "'", "''", 'g') . "'"
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! utils#VimFolds(lnum) abort
|
||||||
|
let l:cur_line = getline(a:lnum)
|
||||||
|
let l:next_line = getline(a:lnum+1)
|
||||||
|
|
||||||
|
if l:cur_line =~# '^"{'
|
||||||
|
return '>' . (matchend(l:cur_line, '"{*') - 1)
|
||||||
|
endif
|
||||||
|
|
||||||
|
if l:cur_line ==# '' && (matchend(l:next_line, '"{*') - 1) == 1
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
return '='
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! utils#MyFoldText() abort
|
||||||
|
let l:line = getline(v:foldstart)
|
||||||
|
let l:fold_line_num = v:foldend - v:foldstart
|
||||||
|
let l:fold_text = substitute(l:line, '^"{\+', '', 'g')
|
||||||
|
let l:fill_char_num = &textwidth - len(l:fold_text) - len(l:fold_line_num) - 10
|
||||||
|
return printf('+%s%s %s (%s L)', repeat('-', 4), l:fold_text, repeat('-', l:fill_char_num), l:fold_line_num)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! utils#ToggleCursorCol() abort
|
||||||
|
if &cursorcolumn
|
||||||
|
set nocursorcolumn
|
||||||
|
echo 'cursorcolumn: OFF'
|
||||||
|
else
|
||||||
|
set cursorcolumn
|
||||||
|
echo 'cursorcolumn: ON'
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! utils#SwitchLine(src_line_idx, direction) abort
|
||||||
|
if a:direction ==# 'up'
|
||||||
|
if a:src_line_idx == 1
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
move-2
|
||||||
|
elseif a:direction ==# 'down'
|
||||||
|
if a:src_line_idx == line('$')
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
move+1
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! utils#MoveSelection(direction) abort
|
||||||
|
if visualmode() !=# 'V'
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:start_line = line("'<")
|
||||||
|
let l:end_line = line("'>")
|
||||||
|
let l:num_line = l:end_line - l:start_line + 1
|
||||||
|
|
||||||
|
if a:direction ==# 'up'
|
||||||
|
if l:start_line == 1
|
||||||
|
normal! gv
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
silent execute printf('%s,%smove-2', l:start_line, l:end_line)
|
||||||
|
normal! gv
|
||||||
|
elseif a:direction ==# 'down'
|
||||||
|
if l:end_line == line('$')
|
||||||
|
normal! gv
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
silent execute printf('%s,%smove+%s', l:start_line, l:end_line, l:num_line)
|
||||||
|
normal! gv
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function utils#Get_titlestr() abort
|
||||||
|
let l:title_str = ''
|
||||||
|
if g:is_linux
|
||||||
|
let l:title_str = hostname() . ' '
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:buf_path = expand('%:p:~')
|
||||||
|
let l:title_str = l:title_str . l:buf_path . ' '
|
||||||
|
|
||||||
|
return l:title_str
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function utils#iso_time(timestamp) abort
|
||||||
|
if !a:timestamp
|
||||||
|
return strftime('%Y-%m-%d %H:%M:%S%z')
|
||||||
|
endif
|
||||||
|
|
||||||
|
if len(a:timestamp) == 13
|
||||||
|
let l:timestamp = a:timestamp[:-4]
|
||||||
|
elseif len(a:timestamp) == 16
|
||||||
|
let l:timestamp = a:timestamp[:-7]
|
||||||
|
else
|
||||||
|
let l:timestamp = a:timestamp
|
||||||
|
endif
|
||||||
|
return strftime('%Y-%m-%d %H:%M:%S%z', l:timestamp)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! utils#CaptureCommandOutput(command) abort
|
||||||
|
let l:tmp = @m
|
||||||
|
redir @m
|
||||||
|
silent! execute a:command
|
||||||
|
redir END
|
||||||
|
|
||||||
|
tabnew | setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile
|
||||||
|
|
||||||
|
let l:lines = split(@m, '\n')
|
||||||
|
call nvim_buf_set_lines(0, 0, 0, 0, l:lines)
|
||||||
|
|
||||||
|
let @m = l:tmp
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! utils#MultiEdit(patterns) abort
|
||||||
|
for p in a:patterns
|
||||||
|
for f in glob(p, 0, 1)
|
||||||
|
execute 'edit ' . f
|
||||||
|
endfor
|
||||||
|
endfor
|
||||||
|
endfunction
|
4
ftdetect/pdc.vim
Normal file
4
ftdetect/pdc.vim
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
augroup det_md
|
||||||
|
autocmd!
|
||||||
|
autocmd BufRead,BufNewFile *.pdc set filetype=markdown
|
||||||
|
augroup END
|
4
ftdetect/snippets.vim
Normal file
4
ftdetect/snippets.vim
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
augroup det_snippet
|
||||||
|
autocmd!
|
||||||
|
autocmd BufRead,BufNewFile *.snippets set filetype=snippets
|
||||||
|
augroup END
|
14
init.lua
Normal file
14
init.lua
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
-- Based on https://github.com/jdhao/nvim-config
|
||||||
|
|
||||||
|
vim.loader.enable()
|
||||||
|
|
||||||
|
local config_dir = vim.fn.stdpath("config")
|
||||||
|
--@cast config_dir string
|
||||||
|
|
||||||
|
require("globals")
|
||||||
|
require("custom-autocmd")
|
||||||
|
require("mappings")
|
||||||
|
require("diagnostic-conf")
|
||||||
|
require("colorschemes")
|
||||||
|
vim.cmd("source " .. vim.fs.joinpath(config_dir, "viml_conf/options.vim"))
|
||||||
|
vim.cmd("source " .. vim.fs.joinpath(config_dir, "viml_conf/plugins.vim"))
|
95
lazy-lock.json
Normal file
95
lazy-lock.json
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
{
|
||||||
|
"arctic": { "branch": "v2", "commit": "9052ab87b1d6e9b746ab8dde6576e2876ffda4c7" },
|
||||||
|
"ashen.nvim": { "branch": "main", "commit": "bfb04bd50b69d863469b2deb9fb361cf0d945ba7" },
|
||||||
|
"asyncrun.vim": { "branch": "master", "commit": "e17c49c67d1dd847cd1d7d6077a7168816f546cc" },
|
||||||
|
"better-escape.vim": { "branch": "master", "commit": "6b16a45a839727977277f6ab11bded63e9ed86bb" },
|
||||||
|
"bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" },
|
||||||
|
"catppuccin": { "branch": "main", "commit": "76a8d0515024cc55d8bd26fc13f1af88faef3ebf" },
|
||||||
|
"citruszest.nvim": { "branch": "main", "commit": "ce6749e4c3a842679cc302ce1c2db76c2d07f700" },
|
||||||
|
"cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" },
|
||||||
|
"cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" },
|
||||||
|
"cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" },
|
||||||
|
"cmp-nvim-ultisnips": { "branch": "main", "commit": "2be0eda0f7fbf47ebd9fbdace369cc45d57acf49" },
|
||||||
|
"cmp-omni": { "branch": "main", "commit": "4ef610bbd85a5ee4e97e09450c0daecbdc60de86" },
|
||||||
|
"cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" },
|
||||||
|
"dashboard-nvim": { "branch": "master", "commit": "c42fcfbd96dfcaa486c0a0ab52494316f1c31350" },
|
||||||
|
"diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" },
|
||||||
|
"dropbar.nvim": { "branch": "master", "commit": "418897fe7828b2749ca78056ec8d8ad43136b695" },
|
||||||
|
"e-ink.nvim": { "branch": "main", "commit": "c90bf520ed01daa333e372e9bf2917f7f1562425" },
|
||||||
|
"edge": { "branch": "master", "commit": "1d203dc579c09db5bf3188e1ce84e0348598ceff" },
|
||||||
|
"everforest": { "branch": "master", "commit": "4132e797f6ce555de53825b6ef3df0b618456703" },
|
||||||
|
"fidget.nvim": { "branch": "main", "commit": "dafd592c7bdbb6cd6d17d3c9a1a8abf3930138c1" },
|
||||||
|
"fzf-lua": { "branch": "main", "commit": "504b45d6cedec32d6f0ddeb82f3d7117a94b622b" },
|
||||||
|
"git-conflict.nvim": { "branch": "main", "commit": "4bbfdd92d547d2862a75b4e80afaf30e73f7bbb4" },
|
||||||
|
"github-theme": { "branch": "main", "commit": "c106c9472154d6b2c74b74565616b877ae8ed31d" },
|
||||||
|
"gitlinker.nvim": { "branch": "master", "commit": "cc59f732f3d043b626c8702cb725c82e54d35c25" },
|
||||||
|
"gitsigns.nvim": { "branch": "main", "commit": "c7d37ca22b461f64e26f8f6701b2586128ed0bef" },
|
||||||
|
"glance.nvim": { "branch": "master", "commit": "bf86d8b79dce808e65fdb6e9269d0b4ed6d2eefc" },
|
||||||
|
"gruvbox-material": { "branch": "master", "commit": "d080710b58e605b45db0b0e4288205ca6f7587f0" },
|
||||||
|
"hop.nvim": { "branch": "master", "commit": "2254e0b3c8054b9ee661c9be3cb201d4b3384d8e" },
|
||||||
|
"jellybeans.nvim": { "branch": "main", "commit": "28b80886b54396b13a2a85edf608926333e842b9" },
|
||||||
|
"kanagawa.nvim": { "branch": "master", "commit": "debe91547d7fb1eef34ce26a5106f277fbfdd109" },
|
||||||
|
"kanso.nvim": { "branch": "main", "commit": "f107190b81e84c132d5755d0153944f0f1e1e380" },
|
||||||
|
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
|
||||||
|
"lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" },
|
||||||
|
"live-command.nvim": { "branch": "main", "commit": "05b9f886628f3e9e6122e734c1fac4f13dcb64b4" },
|
||||||
|
"lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" },
|
||||||
|
"lush.nvim": { "branch": "main", "commit": "1be16d9002f8b2e8973a19ceac199ad394dea76a" },
|
||||||
|
"makurai-nvim": { "branch": "main", "commit": "825c35012951b2bced9e791fba8740a28951d038" },
|
||||||
|
"markdown.nvim": { "branch": "main", "commit": "3da7bb459f6cff03980dd1e106c46f3e62ff4d9f" },
|
||||||
|
"material.nvim": { "branch": "main", "commit": "2929c6fae4886bd7c33371937601409705049a18" },
|
||||||
|
"melange-nvim": { "branch": "master", "commit": "ce42f6b629beeaa00591ba73a77d3eeac4cf28ce" },
|
||||||
|
"mini.icons": { "branch": "main", "commit": "b8f6fa6f5a3fd0c56936252edcd691184e5aac0c" },
|
||||||
|
"mini.indentscope": { "branch": "main", "commit": "f1567c6f46c250b22f4ad1b847a042464742b11d" },
|
||||||
|
"modus-themes.nvim": { "branch": "master", "commit": "61b8c10ec636f42baf6c845edb14b9ae2723711f" },
|
||||||
|
"neogit": { "branch": "master", "commit": "269a813161b009de19db416ad159891502cf0c85" },
|
||||||
|
"nightfox.nvim": { "branch": "main", "commit": "ba47d4b4c5ec308718641ba7402c143836f35aa9" },
|
||||||
|
"nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" },
|
||||||
|
"nvim-bqf": { "branch": "main", "commit": "17680cda3538913e88dd4c6456c837db9ace40ae" },
|
||||||
|
"nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" },
|
||||||
|
"nvim-colorizer.lua": { "branch": "master", "commit": "16597180b4dd81fa3d23d88c4d2f1b49154f9479" },
|
||||||
|
"nvim-gdb": { "branch": "master", "commit": "cf00140361cabcd4e55a987fd9770a92ee682301" },
|
||||||
|
"nvim-hlslens": { "branch": "main", "commit": "95ced18ebaf19c1bdb64982a614ee8a9d7ee8e51" },
|
||||||
|
"nvim-lightbulb": { "branch": "master", "commit": "aa3a8b0f4305b25cfe368f6c9be9923a7c9d0805" },
|
||||||
|
"nvim-lspconfig": { "branch": "master", "commit": "d6dc63670d3dc5204b1e874af4cbf340cb5d9d18" },
|
||||||
|
"nvim-notify": { "branch": "master", "commit": "397c7c1184745fca649e5104de659e6392ef5a4d" },
|
||||||
|
"nvim-tree.lua": { "branch": "master", "commit": "0a52012d611f3c1492b8d2aba363fabf734de91d" },
|
||||||
|
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
|
||||||
|
"nvim-treesitter-textobjects": { "branch": "master", "commit": "71385f191ec06ffc60e80e6b0c9a9d5daed4824c" },
|
||||||
|
"nvim-ufo": { "branch": "main", "commit": "80fe8215ba566df2fbf3bf4d25f59ff8f41bc0e1" },
|
||||||
|
"onedark.nvim": { "branch": "master", "commit": "de495fabe171d48aed5525f002d14414efcecbb2" },
|
||||||
|
"onedarkpro.nvim": { "branch": "main", "commit": "3891f6f8db49774aa861d08ddc7c18ad8f1340e9" },
|
||||||
|
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
|
||||||
|
"promise-async": { "branch": "main", "commit": "119e8961014c9bfaf1487bf3c2a393d254f337e2" },
|
||||||
|
"snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" },
|
||||||
|
"sonokai": { "branch": "master", "commit": "27a71a6e058ba0a88b14b137a89020f6caeec93b" },
|
||||||
|
"statuscol.nvim": { "branch": "main", "commit": "c46172d0911aa5d49ba5f39f4351d1bb7aa289cc" },
|
||||||
|
"tabular": { "branch": "master", "commit": "12437cd1b53488e24936ec4b091c9324cafee311" },
|
||||||
|
"targets.vim": { "branch": "master", "commit": "6325416da8f89992b005db3e4517aaef0242602e" },
|
||||||
|
"telescope-symbols.nvim": { "branch": "master", "commit": "a6d0127a53d39b9fc2af75bd169d288166118aec" },
|
||||||
|
"telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" },
|
||||||
|
"ultisnips": { "branch": "master", "commit": "b22a86f9dcc5257624bff3c72d8b902eac468aad" },
|
||||||
|
"unicode.vim": { "branch": "master", "commit": "c7ae86b93e70e816377ad194789bab0f5639dce2" },
|
||||||
|
"vague.nvim": { "branch": "main", "commit": "676e5b4d74f32ff91c1583eba9c326d2b749672f" },
|
||||||
|
"vim-commentary": { "branch": "master", "commit": "64a654ef4a20db1727938338310209b6a63f60c9" },
|
||||||
|
"vim-eunuch": { "branch": "master", "commit": "e86bb794a1c10a2edac130feb0ea590a00d03f1e" },
|
||||||
|
"vim-flog": { "branch": "master", "commit": "665b16ac8915f746bc43c9572b4581a5e9047216" },
|
||||||
|
"vim-fugitive": { "branch": "master", "commit": "61b51c09b7c9ce04e821f6cf76ea4f6f903e3cf4" },
|
||||||
|
"vim-highlighturl": { "branch": "master", "commit": "7179156ccc68168e7ef8f1eae28edf36911f5a3c" },
|
||||||
|
"vim-markdownfootnotes": { "branch": "master", "commit": "2b288149f48cfaf7465d25bb094ed62898f5e5b0" },
|
||||||
|
"vim-matchup": { "branch": "master", "commit": "b4efd6a97380b99bb9f5eb80c9002e061402c288" },
|
||||||
|
"vim-mundo": { "branch": "master", "commit": "2ceda8c65f7b3f9066820729fc02003a09df91f9" },
|
||||||
|
"vim-obsession": { "branch": "master", "commit": "ed9dfc7c2cc917ace8b24f4f9f80a91e05614b63" },
|
||||||
|
"vim-oscyank": { "branch": "main", "commit": "d67d76b2f19b868b70a1cf33a779d71dc092cb30" },
|
||||||
|
"vim-repeat": { "branch": "master", "commit": "65846025c15494983dafe5e3b46c8f88ab2e9635" },
|
||||||
|
"vim-sandwich": { "branch": "master", "commit": "74cf93d58ccc567d8e2310a69860f1b93af19403" },
|
||||||
|
"vim-scriptease": { "branch": "master", "commit": "cdb5981d47ac98221a408ae2e7cae66524d9e872" },
|
||||||
|
"vim-snippets": { "branch": "master", "commit": "f0a3184d9f90b96b044d5914625a25c554d7f301" },
|
||||||
|
"vim-swap": { "branch": "master", "commit": "9358bfdc5e377aa13e7c2c2dd8699ba32b0dcf83" },
|
||||||
|
"vim-tmux": { "branch": "master", "commit": "cfe76281efc29890548cf9eedd42ad51c7a1faf0" },
|
||||||
|
"vim-toml": { "branch": "main", "commit": "1b63257680eeb65677eb1ca5077809a982756d58" },
|
||||||
|
"vista.vim": { "branch": "master", "commit": "1e90efad6e32c4f7d16b1ca8f49bf63d0693802e" },
|
||||||
|
"which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" },
|
||||||
|
"whitespace.nvim": { "branch": "master", "commit": "fda1dd48e63e62a0ebd270c38d87e246b29c3616" },
|
||||||
|
"yanky.nvim": { "branch": "main", "commit": "04775cc6e10ef038c397c407bc17f00a2f52b378" }
|
||||||
|
}
|
92
lua/colorschemes.lua
Normal file
92
lua/colorschemes.lua
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
local utils = require("utils")
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
M.colorscheme_conf = {
|
||||||
|
onedark = function()
|
||||||
|
require("onedark").setup {
|
||||||
|
style = "darker",
|
||||||
|
}
|
||||||
|
require("onedark").load()
|
||||||
|
end,
|
||||||
|
edge = function()
|
||||||
|
vim.g.edge_style = "default"
|
||||||
|
vim.g.edge_enable_italic = 1
|
||||||
|
vim.g.edge_better_performance = 1
|
||||||
|
vim.cmd([[colorscheme edge]])
|
||||||
|
end,
|
||||||
|
sonokai = function()
|
||||||
|
vim.g.sonokai_enable_italic = 1
|
||||||
|
vim.g.sonokai_better_performance = 1
|
||||||
|
vim.cmd([[colorscheme sonokai]])
|
||||||
|
end,
|
||||||
|
gruvbox_material = function()
|
||||||
|
-- foreground option can be material, mix, or original
|
||||||
|
vim.g.gruvbox_material_foreground = "original"
|
||||||
|
-- background option can be hard, medium, soft
|
||||||
|
vim.g.gruvbox_material_background = "hard"
|
||||||
|
vim.g.gruvbox_material_enable_italic = 1
|
||||||
|
vim.g.gruvbox_material_better_performance = 1
|
||||||
|
vim.cmd([[colorscheme gruvbox-material]])
|
||||||
|
end,
|
||||||
|
everforest = function()
|
||||||
|
vim.g.everforest_background = "hard"
|
||||||
|
vim.g.everforest_enable_italic = 1
|
||||||
|
vim.g.everforest_better_performance = 1
|
||||||
|
vim.cmd([[colorscheme everforest]])
|
||||||
|
end,
|
||||||
|
nightfox = function()
|
||||||
|
vim.cmd([[colorscheme carboxfox]])
|
||||||
|
end,
|
||||||
|
onedarkpro = function()
|
||||||
|
vim.cmd("colorscheme onedark_dark")
|
||||||
|
end,
|
||||||
|
material = function()
|
||||||
|
vim.g.material_style = "darker"
|
||||||
|
vim.cmd("colorscheme material")
|
||||||
|
end,
|
||||||
|
arctic = function()
|
||||||
|
vim.cmd("colorscheme arctic")
|
||||||
|
end,
|
||||||
|
kanagawa = function()
|
||||||
|
vim.cmd("colorscheme kanagawa-dragon")
|
||||||
|
end,
|
||||||
|
modus = function()
|
||||||
|
vim.cmd([[colorscheme modus]])
|
||||||
|
end,
|
||||||
|
jellybeans = function()
|
||||||
|
vim.cmd([[colorscheme jellybeans]])
|
||||||
|
end,
|
||||||
|
github = function()
|
||||||
|
vim.cmd([[colorscheme github_dark_default]])
|
||||||
|
end,
|
||||||
|
e_ink = function()
|
||||||
|
require("e-ink").setup()
|
||||||
|
vim.cmd.colorscheme("e-ink")
|
||||||
|
end,
|
||||||
|
ashen = function()
|
||||||
|
vim.cmd([[colorscheme ashen]])
|
||||||
|
end,
|
||||||
|
melange = function()
|
||||||
|
vim.cmd([[colorscheme melange]])
|
||||||
|
end,
|
||||||
|
makurai = function()
|
||||||
|
vim.cmd.colorscheme("makurai_warrior")
|
||||||
|
end,
|
||||||
|
vague = function()
|
||||||
|
vim.cmd([[colorscheme vague]])
|
||||||
|
end,
|
||||||
|
kanso = function()
|
||||||
|
vim.cmd([[colorscheme kanso]])
|
||||||
|
end,
|
||||||
|
citruszest = function()
|
||||||
|
vim.cmd([[colorscheme citruszest]])
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
M.rand_colorscheme = function()
|
||||||
|
local colorscheme = utils.rand_element(vim.tbl_keys(M.colorscheme_conf))
|
||||||
|
M.colorscheme_conf[colorscheme]()
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
32
lua/config/blink-cmp.lua
Normal file
32
lua/config/blink-cmp.lua
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
require("blink.cmp").setup {
|
||||||
|
keymap = {
|
||||||
|
preset = "default",
|
||||||
|
["<Tab>"] = { "select_next", "fallback" },
|
||||||
|
["<S-Tab>"] = { "select_prev", "fallback" },
|
||||||
|
["<Enter>"] = { "select_and_accept", "fallback" },
|
||||||
|
["<C-U>"] = { "scroll_documentation_up", "fallback" },
|
||||||
|
["<C-D>"] = { "scroll_documentation_down", "fallback" },
|
||||||
|
},
|
||||||
|
appearance = {
|
||||||
|
nerd_font_variant = "mono",
|
||||||
|
},
|
||||||
|
completion = {
|
||||||
|
documentation = {
|
||||||
|
auto_show = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
sources = {
|
||||||
|
default = { "lsp", "path", "buffer" },
|
||||||
|
},
|
||||||
|
fuzzy = { implementation = "prefer_rust_with_warning" },
|
||||||
|
cmdline = {
|
||||||
|
completion = {
|
||||||
|
menu = {
|
||||||
|
auto_show = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
keymap = {
|
||||||
|
["<Enter>"] = { "select_and_accept", "fallback" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
6
lua/config/bqf.lua
Normal file
6
lua/config/bqf.lua
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
require("bqf").setup {
|
||||||
|
auto_resize_height = false,
|
||||||
|
preview = {
|
||||||
|
auto_preview = false,
|
||||||
|
},
|
||||||
|
}
|
42
lua/config/bufferline.lua
Normal file
42
lua/config/bufferline.lua
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
require("bufferline").setup {
|
||||||
|
options = {
|
||||||
|
numbers = "none",
|
||||||
|
close_command = "bdelete! %d",
|
||||||
|
right_mouse_command = nil,
|
||||||
|
left_mouse_command = "buffer %d",
|
||||||
|
middle_mouse_command = nil,
|
||||||
|
indicator = {
|
||||||
|
icon = "▎",
|
||||||
|
style = "icon",
|
||||||
|
},
|
||||||
|
buffer_close_icon = "",
|
||||||
|
modified_icon = "●",
|
||||||
|
close_icon = "",
|
||||||
|
left_trunc_marker = "",
|
||||||
|
right_trunc_marker = "",
|
||||||
|
max_name_length = 18,
|
||||||
|
max_prefix_length = 15,
|
||||||
|
tab_size = 10,
|
||||||
|
diagnostics = false,
|
||||||
|
custom_filter = function(bufnr)
|
||||||
|
local exclude_ft = { "qf", "fugitive", "git" }
|
||||||
|
local cur_ft = vim.bo[bufnr].filetype
|
||||||
|
local should_filter = vim.tbl_contains(exclude_ft, cur_ft)
|
||||||
|
|
||||||
|
return not should_filter
|
||||||
|
end,
|
||||||
|
show_buffer_icons = false,
|
||||||
|
show_buffer_close_icons = true,
|
||||||
|
show_close_icon = true,
|
||||||
|
show_tab_indicators = true,
|
||||||
|
persist_buffer_sort = true,
|
||||||
|
separator_style = "bar",
|
||||||
|
enforce_regular_tabs = false,
|
||||||
|
always_show_bufferline = true,
|
||||||
|
sort_by = "id",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<space>bp", "<cmd>BufferLinePick<cr>", {
|
||||||
|
desc = "pick a buffer",
|
||||||
|
})
|
75
lua/config/dashboard-nvim.lua
Normal file
75
lua/config/dashboard-nvim.lua
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
local api = vim.api
|
||||||
|
local keymap = vim.keymap
|
||||||
|
local dashboard = require("dashboard")
|
||||||
|
|
||||||
|
local conf = {}
|
||||||
|
conf.header = {
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗",
|
||||||
|
" ████╗ ██║ ██╔════╝██╔═══██╗ ██║ ██║ ██║ ████╗ ████║",
|
||||||
|
" ██╔██╗ ██║ █████╗ ██║ ██║ ██║ ██║ ██║ ██╔████╔██║",
|
||||||
|
" ██║╚██╗██║ ██╔══╝ ██║ ██║ ╚██╗ ██╔╝ ██║ ██║╚██╔╝██║",
|
||||||
|
" ██║ ╚████║ ███████╗╚██████╔╝ ╚████╔╝ ██║ ██║ ╚═╝ ██║",
|
||||||
|
" ╚═╝ ╚═══╝ ╚══════╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
}
|
||||||
|
|
||||||
|
conf.center = {
|
||||||
|
{
|
||||||
|
icon = " ",
|
||||||
|
desc = "Find File ",
|
||||||
|
action = "FzfLua files",
|
||||||
|
key = "<Leader> f f",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon = " ",
|
||||||
|
desc = "Recently opened files ",
|
||||||
|
action = "FzfLua oldfiles",
|
||||||
|
key = "<Leader> f r",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon = " ",
|
||||||
|
desc = "Project grep ",
|
||||||
|
action = "FzfLua live_grep",
|
||||||
|
key = "<Leader> f g",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon = " ",
|
||||||
|
desc = "Open Nvim config ",
|
||||||
|
action = "tabnew $MYVIMRC | tcd %:p:h",
|
||||||
|
key = "<Leader> e v",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon = " ",
|
||||||
|
desc = "New file ",
|
||||||
|
action = "enew",
|
||||||
|
key = "e",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon = " ",
|
||||||
|
desc = "Quit Nvim ",
|
||||||
|
-- desc = "Quit Nvim ",
|
||||||
|
action = "qa",
|
||||||
|
key = "q",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
dashboard.setup {
|
||||||
|
theme = "doom",
|
||||||
|
shortcut_type = "number",
|
||||||
|
config = conf,
|
||||||
|
}
|
||||||
|
|
||||||
|
api.nvim_create_autocmd("FileType", {
|
||||||
|
pattern = "dashboard",
|
||||||
|
group = api.nvim_create_augroup("dashboard_enter", { clear = true }),
|
||||||
|
callback = function()
|
||||||
|
keymap.set("n", "q", ":qa<CR>", { buffer = true, silent = true })
|
||||||
|
keymap.set("n", "e", ":enew<CR>", { buffer = true, silent = true })
|
||||||
|
end,
|
||||||
|
})
|
1
lua/config/fidget-nvim.lua
Normal file
1
lua/config/fidget-nvim.lua
Normal file
@ -0,0 +1 @@
|
|||||||
|
require("fidget").setup {}
|
24
lua/config/fugitive.lua
Normal file
24
lua/config/fugitive.lua
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
local keymap = vim.keymap
|
||||||
|
|
||||||
|
keymap.set("n", "<leader>gs", "<cmd>Git<cr>", { desc = "Git: show status" })
|
||||||
|
keymap.set("n", "<leader>gw", "<cmd>Gwrite<cr>", { desc = "Git: add file" })
|
||||||
|
keymap.set("n", "<leader>gc", "<cmd>Git commit<cr>", { desc = "Git: commit changes" })
|
||||||
|
keymap.set("n", "<leader>gpl", "<cmd>Git pull<cr>", { desc = "Git: pull changes" })
|
||||||
|
keymap.set("n", "<leader>gpu", "<cmd>15 split|term git push<cr>", { desc = "Git: push changes" })
|
||||||
|
keymap.set("v", "<leader>gb", ":Git blame<cr>", { desc = "Git: blame selected line" })
|
||||||
|
|
||||||
|
vim.fn["utils#Cabbrev"]("git", "Git")
|
||||||
|
|
||||||
|
keymap.set("n", "<leader>gbn", function()
|
||||||
|
vim.ui.input({ prompt = "Enter a new branch name" }, function(user_input)
|
||||||
|
if user_input == nil or user_input == "" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local cmd_str = string.format("G checkout -b %s", user_input)
|
||||||
|
vim.cmd(cmd_str)
|
||||||
|
end)
|
||||||
|
end, { desc = "Git: create new branch" })
|
||||||
|
|
||||||
|
keymap.set("n", "<leader>gf", ":Git fetch ", { desc = "Git: prune branches" })
|
||||||
|
keymap.set("n", "<leader>gbd", ":Git branch -D ", { desc = "Git: delete branch" })
|
18
lua/config/fzf-lua.lua
Normal file
18
lua/config/fzf-lua.lua
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
require("fzf-lua").setup {
|
||||||
|
defaults = {
|
||||||
|
file_icons = "mini",
|
||||||
|
},
|
||||||
|
winopts = {
|
||||||
|
row = 0.5,
|
||||||
|
height = 0.7,
|
||||||
|
},
|
||||||
|
files = {
|
||||||
|
previewer = false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>ff", "<cmd>FzfLua files<cr>", { desc = "Fuzzy find files" })
|
||||||
|
vim.keymap.set("n", "<leader>fg", "<cmd>FzfLua live_grep<cr>", { desc = "Fuzzy grep files" })
|
||||||
|
vim.keymap.set("n", "<leader>fh", "<cmd>FzfLua helptags<cr>", { desc = "Fuzzy grep tags in help files" })
|
||||||
|
vim.keymap.set("n", "<leader>ft", "<cmd>FzfLua btags<cr>", { desc = "Fuzzy search buffer tags" })
|
||||||
|
vim.keymap.set("n", "<leader>fb", "<cmd>FzfLua buffers<cr>", { desc = "Fuzzy search opened buffers" })
|
9
lua/config/git-conflict.lua
Normal file
9
lua/config/git-conflict.lua
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
require("git-conflict").setup {}
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("User", {
|
||||||
|
pattern = "GitConflictResolved",
|
||||||
|
callback = function()
|
||||||
|
vim.fn.setqflist({}, "r")
|
||||||
|
vim.cmd([[silent! GitConflictListQf]])
|
||||||
|
end,
|
||||||
|
})
|
47
lua/config/git-linker.lua
Normal file
47
lua/config/git-linker.lua
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
local keymap = vim.keymap
|
||||||
|
local gitlinker = require("gitlinker")
|
||||||
|
|
||||||
|
gitlinker.setup {
|
||||||
|
callbacks = {
|
||||||
|
["dev.azure.com"] = function(url_data)
|
||||||
|
vim.print(url_data)
|
||||||
|
local url = require("gitlinker.hosts").get_base_https_url(url_data)
|
||||||
|
|
||||||
|
if url_data.lstart then
|
||||||
|
if url_data.lend == nil then
|
||||||
|
url_data.lend = url_data.lstart
|
||||||
|
end
|
||||||
|
url = url
|
||||||
|
.. "?path=/"
|
||||||
|
.. url_data.file
|
||||||
|
.. "&version=GC"
|
||||||
|
.. url_data.rev
|
||||||
|
.. "&line="
|
||||||
|
.. url_data.lstart
|
||||||
|
"&lineEnd="
|
||||||
|
.. url_data.lend
|
||||||
|
.. "&lineStartColumn=1"
|
||||||
|
.. "&lineEndColumn=120"
|
||||||
|
end
|
||||||
|
return url
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
mappings = nil,
|
||||||
|
}
|
||||||
|
|
||||||
|
keymap.set({ "n", "v" }, "<leader>gl", function()
|
||||||
|
local mode = string.lower(vim.fn.mode())
|
||||||
|
gitlinker.get_buf_range_url(mode)
|
||||||
|
end, {
|
||||||
|
silent = true,
|
||||||
|
desc = "Git: get permlink",
|
||||||
|
})
|
||||||
|
|
||||||
|
keymap.set("n", "<leader>gbr", function()
|
||||||
|
gitlinker.get_repo_url {
|
||||||
|
action_callback = gitlinker.actions.open_in_browser,
|
||||||
|
}
|
||||||
|
end, {
|
||||||
|
silent = true,
|
||||||
|
desc = "Git: browse repo in browser",
|
||||||
|
})
|
55
lua/config/gitsigns.lua
Normal file
55
lua/config/gitsigns.lua
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
local gs = require("gitsigns")
|
||||||
|
|
||||||
|
gs.setup {
|
||||||
|
signs = {
|
||||||
|
add = { text = "+" },
|
||||||
|
change = { text = "~" },
|
||||||
|
delete = { text = "_" },
|
||||||
|
topdelete = { text = "‾" },
|
||||||
|
changedelete = { text = "|" },
|
||||||
|
},
|
||||||
|
word_diff = false,
|
||||||
|
on_attach = function(bufnr)
|
||||||
|
local function map(mode, l, r, opts)
|
||||||
|
opts = opts or {}
|
||||||
|
opts.buffer = bufnr
|
||||||
|
vim.keymap.set(mode, l, r, opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
map("n", "]c", function()
|
||||||
|
if vim.wo.diff then
|
||||||
|
return "]c"
|
||||||
|
end
|
||||||
|
vim.schedule(function()
|
||||||
|
gs.next_hunk()
|
||||||
|
end)
|
||||||
|
return "<Ignore>"
|
||||||
|
end, { expr = true, desc = "next hunk" })
|
||||||
|
|
||||||
|
map("n", "[c", function()
|
||||||
|
if vim.wo.diff then
|
||||||
|
return "[c"
|
||||||
|
end
|
||||||
|
vim.schedule(function()
|
||||||
|
gs.prev_hunk()
|
||||||
|
end)
|
||||||
|
return "<Ignore>"
|
||||||
|
end, { expr = true, desc = "previous hunk" })
|
||||||
|
|
||||||
|
map("n", "<leader>hp", gs.preview_hunk, { desc = "preview hunk" })
|
||||||
|
map("n", "<leader>hb", function()
|
||||||
|
gs.blame_line { full = true }
|
||||||
|
end, { desc = "blame hunk" })
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("ColorScheme", {
|
||||||
|
pattern = "*",
|
||||||
|
callback = function()
|
||||||
|
vim.cmd([[
|
||||||
|
hi GitSignsChangeInline gui=reverse
|
||||||
|
hi GitSignsAddInline gui=reverse
|
||||||
|
hi GitSignsDeleteInline gui=reverse
|
||||||
|
]])
|
||||||
|
end,
|
||||||
|
})
|
12
lua/config/glance.lua
Normal file
12
lua/config/glance.lua
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
local glance = require("glance")
|
||||||
|
|
||||||
|
glance.setup {
|
||||||
|
height = 25,
|
||||||
|
border = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<space>gd", "<cmd>Glance definitions<cr>")
|
||||||
|
vim.keymap.set("n", "<space>gr", "<cmd>Glance reference<cr>")
|
||||||
|
vim.keymap.set("n", "<space>gi", "<cmd>Glance implementations<cr>")
|
75
lua/config/hlslens.lua
Normal file
75
lua/config/hlslens.lua
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
local api = vim.api
|
||||||
|
local keymap = vim.keymap
|
||||||
|
local hlslens = require("hlslens")
|
||||||
|
|
||||||
|
hlslens.setup {
|
||||||
|
calm_down = true,
|
||||||
|
nearest_only = true,
|
||||||
|
}
|
||||||
|
|
||||||
|
local activate_hlslens = function(direction)
|
||||||
|
local cmd = string.format("normal! %s%szzzv", vim.v.count1, direction)
|
||||||
|
local status, msg = pcall(vim.cmd, cmd)
|
||||||
|
|
||||||
|
if not status then
|
||||||
|
local start_idx, _ = string.find(msg, "E486", 1, true)
|
||||||
|
local msg_part = string.sub(msg, start_idx)
|
||||||
|
api.nvim_echo({ { msg_part } }, true, { err = true })
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
hlslens.start()
|
||||||
|
end
|
||||||
|
|
||||||
|
keymap.set("n", "n", "", {
|
||||||
|
callback = function()
|
||||||
|
activate_hlslens("n")
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
keymap.set("n", "N", "", {
|
||||||
|
callback = function()
|
||||||
|
activate_hlslens("N")
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
local check_cursor_word = function()
|
||||||
|
local cursor_word = vim.fn.expand("<cword>")
|
||||||
|
local result = cursor_word == ""
|
||||||
|
if result then
|
||||||
|
local msg = "E348: No string under cursor"
|
||||||
|
api.nvim_echo({ { msg } }, true, { err = true })
|
||||||
|
end
|
||||||
|
|
||||||
|
return result, cursor_word
|
||||||
|
end
|
||||||
|
|
||||||
|
keymap.set("n", "*", "", {
|
||||||
|
callback = function()
|
||||||
|
local cursor_word_empty, cursor_word = check_cursor_word()
|
||||||
|
if cursor_word_empty then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local cmd = string.format([[normal! /\v<%s>]], cursor_word)
|
||||||
|
local escaped_enter = vim.api.nvim_replace_termcodes("<CR>", true, false, true)
|
||||||
|
local full_cmd = cmd .. escaped_enter .. "N"
|
||||||
|
vim.fn.execute(full_cmd)
|
||||||
|
hlslens.start()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
keymap.set("n", "#", "", {
|
||||||
|
callback = function()
|
||||||
|
local cursor_word_empty, cursor_word = check_cursor_word()
|
||||||
|
if cursor_word_empty then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local cmd = string.format([[normal! ?\v<%s>]], cursor_word)
|
||||||
|
local escaped_enter = vim.api.nvim_replace_termcodes("<CR>", true, false, true)
|
||||||
|
|
||||||
|
local full_cmd = cmd .. escaped_enter .. "N"
|
||||||
|
vim.fn.execute(full_cmd)
|
||||||
|
hlslens.start()
|
||||||
|
end,
|
||||||
|
})
|
7
lua/config/iron.lua
Normal file
7
lua/config/iron.lua
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
local lua = require("iron")
|
||||||
|
iron.core.set_config {
|
||||||
|
preferred = {
|
||||||
|
python = "ipython",
|
||||||
|
},
|
||||||
|
repl_open_cmd = "vertical 120 split",
|
||||||
|
}
|
18
lua/config/lightbulb.lua
Normal file
18
lua/config/lightbulb.lua
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
---@diagnostic disable: missing-fields
|
||||||
|
require("nvim-lightbulb").setup {
|
||||||
|
autocmd = {
|
||||||
|
enabled = true,
|
||||||
|
updatetime = -1,
|
||||||
|
},
|
||||||
|
---@diagnostic disable-next-line: unused-local
|
||||||
|
filter = function(client_name, result)
|
||||||
|
-- Ruff always sends these two actions even if there are no actions to take
|
||||||
|
-- so it is better to just ignore these to avoid noise
|
||||||
|
local ignored_kinds = { "source.fixAll.ruff", "source.organizeImports.ruff" }
|
||||||
|
if vim.tbl_contains(ignored_kinds, result.kind) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
|
end,
|
||||||
|
}
|
9
lua/config/live-command.lua
Normal file
9
lua/config/live-command.lua
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
require("live-command").setup {
|
||||||
|
enable_highlighting = true,
|
||||||
|
inline_highlighting = true,
|
||||||
|
commands = {
|
||||||
|
Norm = { cmd = "norm" },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.cmd("cnoreabbrev norm Norm")
|
127
lua/config/lsp.lua
Normal file
127
lua/config/lsp.lua
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
local utils = require("utils")
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
|
group = vim.api.nvim_create_augroup("lsp_buf_conf", { clear = true }),
|
||||||
|
callback = function(event_context)
|
||||||
|
local client = vim.lsp.get_client_by_id(event_context.data.client_id)
|
||||||
|
|
||||||
|
if not client then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local bufnr = event_context.buf
|
||||||
|
local map = function(mode, l, r, opts)
|
||||||
|
opts = opts or {}
|
||||||
|
opts.silent = true
|
||||||
|
opts.buffer = bufnr
|
||||||
|
vim.keymap.set(mode, l, r, opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
map("n", "gd", function()
|
||||||
|
vim.lsp.buf.definition {
|
||||||
|
on_list = function(options)
|
||||||
|
local unique_defs = {}
|
||||||
|
local def_loc_hash = {}
|
||||||
|
|
||||||
|
for _, def_location in pairs(options.items) do
|
||||||
|
local hash_key = def_location.filename .. def_location.lnum
|
||||||
|
|
||||||
|
if not def_loc_hash[hash_key] then
|
||||||
|
def_loc_hash[hash_key] = true
|
||||||
|
table.insert(unique_defs, def_location)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
options.items = unique_defs
|
||||||
|
|
||||||
|
---@diagnostic disable-next-line: param-type-mismatch
|
||||||
|
vim.fn.setloclist(0, {}, " ", options)
|
||||||
|
|
||||||
|
if #options.items > 1 then
|
||||||
|
vim.cmd.lopen()
|
||||||
|
else
|
||||||
|
vim.cmd([[silent! lfirst]])
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
end, { desc = "go to definition" })
|
||||||
|
map("n", "<c-]>", vim.lsp.buf.definition)
|
||||||
|
map("n", "K", function()
|
||||||
|
vim.lsp.buf.hover { border = "single", max_height = 25, max_width = 120 }
|
||||||
|
end)
|
||||||
|
map("n", "<c-k>", vim.lsp.buf.signature_help)
|
||||||
|
map("n", "<space>rn", vim.lsp.buf.rename, { desc = "variable rename" })
|
||||||
|
map("n", "<space>ca", vim.lsp.buf.code_action, { desc = "LSP code action" })
|
||||||
|
map("n", "<space>wa", vim.lsp.buf.add_workspace_folder, { desc = "add workspace folder" })
|
||||||
|
map("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, { desc = "remove workspace folder" })
|
||||||
|
map("n", "<space>wl", function()
|
||||||
|
vim.print(vim.lsp.buf.list_workspace_folders())
|
||||||
|
end, { desc = "list workspace folder" })
|
||||||
|
|
||||||
|
if client.name == "ruff" then
|
||||||
|
client.server_capabilities.hoverProvider = false
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.lsp.inlay_hint.enable(true, { buffer = bufnr })
|
||||||
|
|
||||||
|
if client.server_capabilities.documentHighlightProvider then
|
||||||
|
local gid = vim.api.nvim_create_augroup("lsp_document_highlight", { clear = true })
|
||||||
|
vim.api.nvim_create_autocmd("CursorHold", {
|
||||||
|
group = gid,
|
||||||
|
buffer = bufnr,
|
||||||
|
callback = function()
|
||||||
|
vim.lsp.buf.document_highlight()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("CursorMoved", {
|
||||||
|
group = gid,
|
||||||
|
buffer = bufnr,
|
||||||
|
callback = function()
|
||||||
|
vim.lsp.buf.clear_references()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("CursorMoved", {
|
||||||
|
group = gid,
|
||||||
|
buffer = bufnr,
|
||||||
|
callback = function()
|
||||||
|
vim.lsp.buf.clear_references()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
nested = true,
|
||||||
|
desc = "configure buffer keymap and behavior based on LSP",
|
||||||
|
})
|
||||||
|
|
||||||
|
local capabilities = require("lsp_utils").get_default_capabilities()
|
||||||
|
|
||||||
|
vim.lsp.config("*", {
|
||||||
|
capabilities = capabilities,
|
||||||
|
flags = {
|
||||||
|
debounce_text_changes = 500,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
local enabled_lsp_servers = {
|
||||||
|
pyright = "delance-langserver",
|
||||||
|
ruff = "ruff",
|
||||||
|
lua_ls = "lua-language-server",
|
||||||
|
vimls = "vim-language-server",
|
||||||
|
bashls = "bash-language-server",
|
||||||
|
yamlls = "yaml-language-server",
|
||||||
|
}
|
||||||
|
|
||||||
|
for server_name, lsp_executable in pairs(enabled_lsp_servers) do
|
||||||
|
if utils.executable(lsp_executable) then
|
||||||
|
vim.lsp.enable(server_name)
|
||||||
|
else
|
||||||
|
local msg = string.format(
|
||||||
|
"Executable '%s' for server '%s' not found! Server will not be enabled",
|
||||||
|
lsp_executable,
|
||||||
|
server_name
|
||||||
|
)
|
||||||
|
vim.notify(msg, vim.log.levels.WARN, { title = "nvim-config" })
|
||||||
|
end
|
||||||
|
end
|
310
lua/config/lualine.lua
Normal file
310
lua/config/lualine.lua
Normal file
@ -0,0 +1,310 @@
|
|||||||
|
local fn = vim.fn
|
||||||
|
|
||||||
|
local git_status_cache = {}
|
||||||
|
|
||||||
|
local on_exit_fetch = function(result)
|
||||||
|
if result.code == 0 then
|
||||||
|
git_status_cache.fetch_success = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function handle_numeric_result(cache_key)
|
||||||
|
return function(result)
|
||||||
|
if result.code == 0 then
|
||||||
|
git_status_cache[cache_key] = tonumber(result.stdout:match("(%d+)")) or 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local async_cmd = function(cmd_str, on_exit)
|
||||||
|
local cmd = vim.tbl_filter(function(element)
|
||||||
|
return element ~= ""
|
||||||
|
end, vim.split(cmd_str, " "))
|
||||||
|
|
||||||
|
vim.system(cmd, { text = true }, on_exit)
|
||||||
|
end
|
||||||
|
|
||||||
|
local async_git_status_update = function()
|
||||||
|
-- Fetch the latest changes from the remote repository (replace 'origin' if needed)
|
||||||
|
async_cmd("git fetch origin", on_exit_fetch)
|
||||||
|
if not git_status_cache.fetch_success then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Get the number of commits behind
|
||||||
|
-- the @{upstream} notation is inspired by post: https://www.reddit.com/r/neovim/comments/t48x5i/git_branch_aheadbehind_info_status_line_component/
|
||||||
|
-- note that here we should use double dots instead of triple dots
|
||||||
|
local behind_cmd_str = "git rev-list --count HEAD..@{upstream}"
|
||||||
|
async_cmd(behind_cmd_str, handle_numeric_result("behind_count"))
|
||||||
|
|
||||||
|
-- Get the number of commits ahead
|
||||||
|
local ahead_cmd_str = "git rev-list --count @{upstream}..HEAD"
|
||||||
|
async_cmd(ahead_cmd_str, handle_numeric_result("ahead_count"))
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_git_ahead_behind_info()
|
||||||
|
async_git_status_update()
|
||||||
|
|
||||||
|
local status = git_status_cache
|
||||||
|
if not status then
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
|
||||||
|
local msg = ""
|
||||||
|
|
||||||
|
if type(status.ahead_count) == "number" and status.ahead_count > 0 then
|
||||||
|
local ahead_str = string.format("↑[%d] ", status.ahead_count)
|
||||||
|
msg = msg .. ahead_str
|
||||||
|
end
|
||||||
|
|
||||||
|
if type(status.behind_count) == "number" and status.behind_count > 0 then
|
||||||
|
local behind_str = string.format("↓[%d] ", status.behind_count)
|
||||||
|
msg = msg .. behind_str
|
||||||
|
end
|
||||||
|
|
||||||
|
return msg
|
||||||
|
end
|
||||||
|
|
||||||
|
local function spell()
|
||||||
|
if vim.o.spell then
|
||||||
|
return string.format("[SPELL]")
|
||||||
|
end
|
||||||
|
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
|
||||||
|
--- show indicator for Chinese IME
|
||||||
|
local function ime_state()
|
||||||
|
if vim.g.is_mac then
|
||||||
|
-- ref: https://github.com/vim-airline/vim-airline/blob/master/autoload/airline/extensions/xkblayout.vim#L11
|
||||||
|
local layout = fn.libcall(vim.g.XkbSwitchLib, "Xkb_Switch_getXkbLayout", "")
|
||||||
|
|
||||||
|
-- We can use `xkbswitch -g` on the command line to get current mode.
|
||||||
|
-- mode for macOS builtin pinyin IME: com.apple.inputmethod.SCIM.ITABC
|
||||||
|
-- mode for Rime: im.rime.inputmethod.Squirrel.Rime
|
||||||
|
local res = fn.match(layout, [[\v(Squirrel\.Rime|SCIM.ITABC)]])
|
||||||
|
if res ~= -1 then
|
||||||
|
return "[CN]"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
|
||||||
|
local function trailing_space()
|
||||||
|
if not vim.o.modifiable then
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
|
||||||
|
local line_num = nil
|
||||||
|
|
||||||
|
for i = 1, fn.line("$") do
|
||||||
|
local linetext = fn.getline(i)
|
||||||
|
-- To prevent invalid escape error, we wrap the regex string with `[[]]`.
|
||||||
|
local idx = fn.match(linetext, [[\v\s+$]])
|
||||||
|
|
||||||
|
if idx ~= -1 then
|
||||||
|
line_num = i
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local msg = ""
|
||||||
|
if line_num ~= nil then
|
||||||
|
msg = string.format("[%d]trailing", line_num)
|
||||||
|
end
|
||||||
|
|
||||||
|
return msg
|
||||||
|
end
|
||||||
|
|
||||||
|
local function mixed_indent()
|
||||||
|
if not vim.o.modifiable then
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
|
||||||
|
local space_pat = [[\v^ +]]
|
||||||
|
local tab_pat = [[\v^\t+]]
|
||||||
|
local space_indent = fn.search(space_pat, "nwc")
|
||||||
|
local tab_indent = fn.search(tab_pat, "nwc")
|
||||||
|
local mixed = (space_indent > 0 and tab_indent > 0)
|
||||||
|
local mixed_same_line
|
||||||
|
if not mixed then
|
||||||
|
mixed_same_line = fn.search([[\v^(\t+ | +\t)]], "nwc")
|
||||||
|
mixed = mixed_same_line > 0
|
||||||
|
end
|
||||||
|
if not mixed then
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
if mixed_same_line ~= nil and mixed_same_line > 0 then
|
||||||
|
return "MI:" .. mixed_same_line
|
||||||
|
end
|
||||||
|
local space_indent_cnt = fn.searchcount({ pattern = space_pat, max_count = 1e3 }).total
|
||||||
|
local tab_indent_cnt = fn.searchcount({ pattern = tab_pat, max_count = 1e3 }).total
|
||||||
|
if space_indent_cnt > tab_indent_cnt then
|
||||||
|
return "MI:" .. tab_indent
|
||||||
|
else
|
||||||
|
return "MI:" .. space_indent
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local diff = function()
|
||||||
|
local git_status = vim.b.gitsigns_status_dict
|
||||||
|
if git_status == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local modify_num = git_status.changed
|
||||||
|
local remove_num = git_status.removed
|
||||||
|
local add_num = git_status.added
|
||||||
|
|
||||||
|
local info = { added = add_num, modified = modify_num, removed = remove_num }
|
||||||
|
-- vim.print(info)
|
||||||
|
return info
|
||||||
|
end
|
||||||
|
|
||||||
|
local virtual_env = function()
|
||||||
|
-- only show virtual env for Python
|
||||||
|
if vim.bo.filetype ~= "python" then
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
|
||||||
|
local conda_env = os.getenv("CONDA_DEFAULT_ENV")
|
||||||
|
local venv_path = os.getenv("VIRTUAL_ENV")
|
||||||
|
|
||||||
|
if venv_path == nil then
|
||||||
|
if conda_env == nil then
|
||||||
|
return ""
|
||||||
|
else
|
||||||
|
return string.format(" %s (conda)", conda_env)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
local venv_name = vim.fn.fnamemodify(venv_path, ":t")
|
||||||
|
return string.format(" %s (venv)", venv_name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local get_active_lsp = function()
|
||||||
|
local msg = "🚫"
|
||||||
|
local buf_ft = vim.api.nvim_get_option_value("filetype", {})
|
||||||
|
local clients = vim.lsp.get_clients { bufnr = 0 }
|
||||||
|
if next(clients) == nil then
|
||||||
|
return msg
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, client in ipairs(clients) do
|
||||||
|
---@diagnostic disable-next-line: undefined-field
|
||||||
|
local filetypes = client.config.filetypes
|
||||||
|
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
|
||||||
|
return client.name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return msg
|
||||||
|
end
|
||||||
|
|
||||||
|
require("lualine").setup {
|
||||||
|
options = {
|
||||||
|
icons_enabled = true,
|
||||||
|
theme = "auto",
|
||||||
|
component_separators = { left = "⏐", right = "⏐" },
|
||||||
|
section_separators = "",
|
||||||
|
disabled_filetypes = {},
|
||||||
|
always_divide_middle = true,
|
||||||
|
refresh = {
|
||||||
|
statusline = 1000,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
sections = {
|
||||||
|
lualine_a = {
|
||||||
|
{
|
||||||
|
"filename",
|
||||||
|
symbols = {
|
||||||
|
readonly = "[🔒]",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
lualine_b = {
|
||||||
|
{
|
||||||
|
"branch",
|
||||||
|
fmt = function(name, _)
|
||||||
|
-- truncate branch name in case the name is too long
|
||||||
|
return string.sub(name, 1, 20)
|
||||||
|
end,
|
||||||
|
color = { gui = "italic,bold" },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
get_git_ahead_behind_info,
|
||||||
|
color = { fg = "#E0C479" },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"diff",
|
||||||
|
source = diff,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
virtual_env,
|
||||||
|
color = { fg = "black", bg = "#F1CA81" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
lualine_c = {
|
||||||
|
{
|
||||||
|
"%S",
|
||||||
|
color = { gui = "bold", fg = "cyan" },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
spell,
|
||||||
|
color = { fg = "black", bg = "#a7c080" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
lualine_x = {
|
||||||
|
{
|
||||||
|
get_active_lsp,
|
||||||
|
icon = "📡",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"diagnostics",
|
||||||
|
sources = { "nvim_diagnostic" },
|
||||||
|
symbols = { error = "🆇 ", warn = "⚠️ ", info = "ℹ️ ", hint = " " },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
trailing_space,
|
||||||
|
color = "WarningMsg",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
mixed_indent,
|
||||||
|
color = "WarningMsg",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
lualine_y = {
|
||||||
|
{
|
||||||
|
"encoding",
|
||||||
|
fmt = string.upper,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fileformat",
|
||||||
|
symbols = {
|
||||||
|
unix = "unix",
|
||||||
|
dos = "win",
|
||||||
|
mac = "mac",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"filetype",
|
||||||
|
{
|
||||||
|
ime_state,
|
||||||
|
color = { fg = "black", bg = "#f46868" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
lualine_z = {
|
||||||
|
"location",
|
||||||
|
"progress",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
inactive_sections = {
|
||||||
|
lualine_a = {},
|
||||||
|
lualine_b = {},
|
||||||
|
lualine_c = { "filename" },
|
||||||
|
lualine_x = { "location" },
|
||||||
|
lualine_y = {},
|
||||||
|
lualine_z = {},
|
||||||
|
},
|
||||||
|
tabline = {},
|
||||||
|
extensions = { "quickfix", "fugitive", "nvim-tree" },
|
||||||
|
}
|
106
lua/config/nvim-cmp.lua
Normal file
106
lua/config/nvim-cmp.lua
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
local cmp = require("cmp")
|
||||||
|
|
||||||
|
require("cmp_nvim_lsp")
|
||||||
|
require("cmp_path")
|
||||||
|
require("cmp_buffer")
|
||||||
|
require("cmp_omni")
|
||||||
|
require("cmp_nvim_ultisnips")
|
||||||
|
require("cmp_cmdline")
|
||||||
|
|
||||||
|
local MiniIcons = require("mini.icons")
|
||||||
|
|
||||||
|
cmp.setup {
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
vim.fn["UltiSnips#Anon"](args.body)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
mapping = cmp.mapping.preset.insert {
|
||||||
|
["<Tab>"] = function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
["<S-Tab>"] = function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_prev_item()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
["<CR>"] = cmp.mapping.confirm { select = true },
|
||||||
|
["<C-e>"] = cmp.mapping.abort(),
|
||||||
|
["<Esc>"] = cmp.mapping.close(),
|
||||||
|
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||||
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||||
|
},
|
||||||
|
sources = {
|
||||||
|
{ name = "nvim_lsp" },
|
||||||
|
{ name = "ultisnips" },
|
||||||
|
{ name = "path" },
|
||||||
|
{ name = "buffer", keyword_length = 2 },
|
||||||
|
},
|
||||||
|
completion = {
|
||||||
|
keyword_length = 1,
|
||||||
|
completeopt = "menu,noselect",
|
||||||
|
},
|
||||||
|
view = {
|
||||||
|
entries = "custom",
|
||||||
|
},
|
||||||
|
formatting = {
|
||||||
|
format = function(_, vim_item)
|
||||||
|
local icon, hl = MiniIcons.get("lsp", vim_item.kind)
|
||||||
|
vim_item.kind = icon .. " " .. vim_item.kind
|
||||||
|
vim_item.kind_hl_group = hl
|
||||||
|
return vim_item
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
cmp.setup.filetype("tex", {
|
||||||
|
sources = {
|
||||||
|
{ name = "omni" },
|
||||||
|
{ name = "ultisnips" },
|
||||||
|
{ name = "buffer", keyword_length = 2 },
|
||||||
|
{ name = "path" },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
cmp.setup.cmdline("/", {
|
||||||
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
|
sources = {
|
||||||
|
{ name = "buffer" },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
cmp.setup.cmdline(":", {
|
||||||
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = "path" },
|
||||||
|
}, {
|
||||||
|
{ name = "cmdline" },
|
||||||
|
}),
|
||||||
|
matching = { disallow_symbol_nonprefix_matching = false },
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.cmd([[
|
||||||
|
highlight! link CmpItemMenu Comment
|
||||||
|
" gray
|
||||||
|
highlight! CmpItemAbbrDeprecated guibg=NONE gui=strikethrough guifg=#808080
|
||||||
|
" blue
|
||||||
|
highlight! CmpItemAbbrMatch guibg=NONE guifg=#569CD6
|
||||||
|
highlight! CmpItemAbbrMatchFuzzy guibg=NONE guifg=#569CD6
|
||||||
|
" light blue
|
||||||
|
highlight! CmpItemKindVariable guibg=NONE guifg=#9CDCFE
|
||||||
|
highlight! CmpItemKindInterface guibg=NONE guifg=#9CDCFE
|
||||||
|
highlight! CmpItemKindText guibg=NONE guifg=#9CDCFE
|
||||||
|
" pink
|
||||||
|
highlight! CmpItemKindFunction guibg=NONE guifg=#C586C0
|
||||||
|
highlight! CmpItemKindMethod guibg=NONE guifg=#C586C0
|
||||||
|
" front
|
||||||
|
highlight! CmpItemKindKeyword guibg=NONE guifg=#D4D4D4
|
||||||
|
highlight! CmpItemKindProperty guibg=NONE guifg=#D4D4D4
|
||||||
|
highlight! CmpItemKindUnit guibg=NONE guifg=#D4D4D4
|
||||||
|
]])
|
27
lua/config/nvim-hop.lua
Normal file
27
lua/config/nvim-hop.lua
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
local keymap = vim.keymap
|
||||||
|
local hop = require("hop")
|
||||||
|
hop.setup {
|
||||||
|
case_insensitive = true,
|
||||||
|
char2_fallback_key = "<CR>",
|
||||||
|
quit_key = "<Esc>",
|
||||||
|
}
|
||||||
|
|
||||||
|
keymap.set({ "n", "v", "o" }, "f", "", {
|
||||||
|
silent = true,
|
||||||
|
noremap = true,
|
||||||
|
callback = function()
|
||||||
|
hop.hint_char2()
|
||||||
|
end,
|
||||||
|
desc = "nvim-hop char2",
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("ColorScheme", {
|
||||||
|
pattern = "*",
|
||||||
|
callback = function()
|
||||||
|
vim.cmd([[
|
||||||
|
hi HopNextKey cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff
|
||||||
|
hi HopNextKey cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff
|
||||||
|
hi HopNextKey cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff
|
||||||
|
]])
|
||||||
|
end,
|
||||||
|
})
|
8
lua/config/nvim-notify.lua
Normal file
8
lua/config/nvim-notify.lua
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
local nvim_notify = require("notify")
|
||||||
|
nvim_notify.setup {
|
||||||
|
stages = "fade_in_slide_out",
|
||||||
|
timeout = 1500,
|
||||||
|
background_colour = "#2E3440",
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.notify = nvim_notify
|
22
lua/config/nvim-statuscol.lua
Normal file
22
lua/config/nvim-statuscol.lua
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
local builtin = require("statuscol.builtin")
|
||||||
|
local ffi = require("statuscol.ffidef")
|
||||||
|
local C = ffi.C
|
||||||
|
|
||||||
|
local fold_level_limit = 3
|
||||||
|
local function foldfunc(args)
|
||||||
|
local foldinfo = C.fold_info(args.wp, args.lnum)
|
||||||
|
if foldinfo.level > fold_level_limit then
|
||||||
|
return " "
|
||||||
|
end
|
||||||
|
|
||||||
|
return builtin.foldfunc(args)
|
||||||
|
end
|
||||||
|
|
||||||
|
require("statuscol").setup {
|
||||||
|
relculright = false,
|
||||||
|
segments = {
|
||||||
|
{ text = { "%s" }, click = "v:lua.ScSa" },
|
||||||
|
{ text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" },
|
||||||
|
{ text = { foldfunc, " " }, condition = { true, builtin.not_empty }, click = "v:lua.ScFa" },
|
||||||
|
},
|
||||||
|
}
|
108
lua/config/nvim-tree.lua
Normal file
108
lua/config/nvim-tree.lua
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
local keymap = vim.keymap
|
||||||
|
local nvim_tree = require("nvim-tree")
|
||||||
|
|
||||||
|
nvim_tree.setup {
|
||||||
|
auto_reload_on_write = true,
|
||||||
|
disable_netrw = false,
|
||||||
|
hijack_netrw = true,
|
||||||
|
hijack_cursor = false,
|
||||||
|
hijack_unnamed_buffer_when_opening = false,
|
||||||
|
open_on_tab = false,
|
||||||
|
sort_by = "name",
|
||||||
|
update_cwd = false,
|
||||||
|
view = {
|
||||||
|
width = 30,
|
||||||
|
side = "left",
|
||||||
|
preserve_window_proportions = false,
|
||||||
|
number = false,
|
||||||
|
relativenumber = false,
|
||||||
|
signcolumn = "yes",
|
||||||
|
},
|
||||||
|
renderer = {
|
||||||
|
indent_markers = {
|
||||||
|
enable = false,
|
||||||
|
icons = {
|
||||||
|
corner = "└ ",
|
||||||
|
edge = "| ",
|
||||||
|
none = " ",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
icons = {
|
||||||
|
webdev_colors = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
hijack_directories = {
|
||||||
|
enable = true,
|
||||||
|
auto_open = true,
|
||||||
|
},
|
||||||
|
update_focused_file = {
|
||||||
|
enable = false,
|
||||||
|
update_cwd = false,
|
||||||
|
ignore_list = {},
|
||||||
|
},
|
||||||
|
system_open = {
|
||||||
|
cmd = "",
|
||||||
|
args = {},
|
||||||
|
},
|
||||||
|
diagnostics = {
|
||||||
|
enable = false,
|
||||||
|
show_on_dirs = false,
|
||||||
|
icons = {
|
||||||
|
hint = "",
|
||||||
|
info = "",
|
||||||
|
warning = "",
|
||||||
|
error = "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
filters = {
|
||||||
|
dotfiles = false,
|
||||||
|
custom = {},
|
||||||
|
exclude = {},
|
||||||
|
},
|
||||||
|
git = {
|
||||||
|
enable = true,
|
||||||
|
ignore = true,
|
||||||
|
timeout = 400,
|
||||||
|
},
|
||||||
|
actions = {
|
||||||
|
use_system_clipboard = true,
|
||||||
|
change_dir = {
|
||||||
|
enable = true,
|
||||||
|
global = false,
|
||||||
|
restrict_above_cwd = false,
|
||||||
|
},
|
||||||
|
open_file = {
|
||||||
|
quit_on_open = false,
|
||||||
|
resize_window = false,
|
||||||
|
window_picker = {
|
||||||
|
enable = true,
|
||||||
|
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
|
||||||
|
exclude = {
|
||||||
|
filetype = { "notify", "qf", "diff", "fugitive", "fugitiveblame" },
|
||||||
|
buftype = { "nofile", "terminal", "help" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
trash = {
|
||||||
|
cmd = "trash",
|
||||||
|
require_confirm = true,
|
||||||
|
},
|
||||||
|
log = {
|
||||||
|
enable = false,
|
||||||
|
truncate = false,
|
||||||
|
types = {
|
||||||
|
all = false,
|
||||||
|
config = false,
|
||||||
|
copy_paste = false,
|
||||||
|
diagnostics = false,
|
||||||
|
git = false,
|
||||||
|
profile = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
keymap.set("n", "<space>s", require("nvim-tree.api").tree.toggle, {
|
||||||
|
silent = true,
|
||||||
|
desc = "toggle nvim-tree",
|
||||||
|
})
|
41
lua/config/nvim-ufo.lua
Normal file
41
lua/config/nvim-ufo.lua
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
local handler = function(virtText, lnum, endLnum, width, truncate)
|
||||||
|
local newVirtText = {}
|
||||||
|
local foldedLines = endLnum - lnum
|
||||||
|
local suffix = (" %d"):format(foldedLines)
|
||||||
|
local sufWidth = vim.fn.strdisplaywidth(suffix)
|
||||||
|
local targetWidth = width - sufWidth
|
||||||
|
local curWidth = 0
|
||||||
|
|
||||||
|
for _, chunk in ipairs(virtText) do
|
||||||
|
local chunkText = chunk[1]
|
||||||
|
local chunkWidth = vim.fn.strdisplaywidth(chunkText)
|
||||||
|
if targetWidth > curWidth + chunkWidth then
|
||||||
|
table.insert(newVirtText, chunk)
|
||||||
|
else
|
||||||
|
chunkText = truncate(chunkText, targetWidth - curWidth)
|
||||||
|
local hlGroup = chunk[2]
|
||||||
|
table.insert(newVirtText, { chunkText, hlGroup })
|
||||||
|
chunkWidth = vim.fn.strdisplaywidth(chunkText)
|
||||||
|
if curWidth + chunkWidth < targetWidth then
|
||||||
|
suffix = suffix .. (" "):rep(targetWidth - curWidth - chunkWidth)
|
||||||
|
end
|
||||||
|
break
|
||||||
|
end
|
||||||
|
curWidth = curWidth + chunkWidth
|
||||||
|
end
|
||||||
|
local rAlignAppndx = math.max(math.min(vim.opt.textwidth["_value"], width - 1) - curWidth - sufWidth, 0)
|
||||||
|
suffix = (" "):rep(rAlignAppndx) .. suffix
|
||||||
|
table.insert(newVirtText, { suffix, "MoreMsg" })
|
||||||
|
return newVirtText
|
||||||
|
end
|
||||||
|
|
||||||
|
require("ufo").setup {
|
||||||
|
fold_virt_text_handler = handler,
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.keymap.set("n", "zR", require("ufo").openAllFolds)
|
||||||
|
vim.keymap.set("n", "zM", require("ufo").closeAllFolds)
|
||||||
|
vim.keymap.set("n", "zr", require("ufo").openFoldsExceptKinds)
|
||||||
|
vim.keymap.set("n", "<leader>K", function()
|
||||||
|
local _ = require("ufo").peekFoldedLinesUnderCursor()
|
||||||
|
end, { desc = "Preview folded maps" })
|
23
lua/config/treesitter-textobjects.lua
Normal file
23
lua/config/treesitter-textobjects.lua
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
require("nvim-treesitter.configs").setup {
|
||||||
|
textobjects = {
|
||||||
|
select = {
|
||||||
|
enable = true,
|
||||||
|
lookahead = true,
|
||||||
|
keymaps = {
|
||||||
|
["af"] = "@function.outer",
|
||||||
|
["if"] = "@function.inner",
|
||||||
|
["ac"] = "@class.outer",
|
||||||
|
["ic"] = { query = "@class.inner", desc = "select inner part of a class region" },
|
||||||
|
},
|
||||||
|
selection_modes = {
|
||||||
|
["@function.inner"] = "V",
|
||||||
|
["@function.outer"] = "V",
|
||||||
|
["@class.outer"] = "V",
|
||||||
|
["@class.inner"] = "V",
|
||||||
|
["@parameter.outer"] = "v",
|
||||||
|
},
|
||||||
|
include_surrounding_whitespace = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
8
lua/config/treesitter.lua
Normal file
8
lua/config/treesitter.lua
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
require("nvim-treesitter.configs").setup {
|
||||||
|
ensure_installed = { "python", "cpp", "lua", "vim", "json", "toml" },
|
||||||
|
ignore_install = {},
|
||||||
|
highlight = {
|
||||||
|
enable = true,
|
||||||
|
disable = { "help" },
|
||||||
|
},
|
||||||
|
}
|
6
lua/config/which-key.lua
Normal file
6
lua/config/which-key.lua
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
require("which-key").setup {
|
||||||
|
present = "modern",
|
||||||
|
icons = {
|
||||||
|
mappings = false,
|
||||||
|
},
|
||||||
|
}
|
15
lua/config/yanky.lua
Normal file
15
lua/config/yanky.lua
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
require("yanky").setup {
|
||||||
|
preserve_cursor_position = {
|
||||||
|
enabled = false,
|
||||||
|
},
|
||||||
|
highlight = {
|
||||||
|
on_put = true,
|
||||||
|
on_yank = false,
|
||||||
|
timer = 300,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.keymap.set({ "n", "x" }, "p", "<Plug>(YankyPutAfter)")
|
||||||
|
vim.keymap.set({ "n", "x" }, "P", "<Plug>(YankyPutBefore)")
|
||||||
|
vim.keymap.set("n", "[y", "<Plug>(YankyPreviousEntry)")
|
||||||
|
vim.keymap.set("n", "]y", "<Plug>(YankyNextEntry)")
|
217
lua/custom-autocmd.lua
Normal file
217
lua/custom-autocmd.lua
Normal file
@ -0,0 +1,217 @@
|
|||||||
|
local fn = vim.fn
|
||||||
|
local api = vim.api
|
||||||
|
|
||||||
|
local utils = require("utils")
|
||||||
|
|
||||||
|
-- Display a message when the current file is not in utf-8 format
|
||||||
|
api.nvim_create_autocmd({ "BufRead" }, {
|
||||||
|
pattern = "*",
|
||||||
|
group = api.nvim_create_augroup("non_utf8_file", { clear = true }),
|
||||||
|
callback = function()
|
||||||
|
if vim.bo.fileencoding ~= "utf-8" then
|
||||||
|
vim.notify("File not in UTF-8 format!", vim.log.levels.WARN, { title = "nvim-config" })
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Highlight yanked region
|
||||||
|
local yank_group = api.nvim_create_augroup("highlight_yank", { clear = true })
|
||||||
|
api.nvim_create_autocmd({ "TextYankPost" }, {
|
||||||
|
pattern = "*",
|
||||||
|
group = yank_group,
|
||||||
|
callback = function()
|
||||||
|
vim.hl.on_yank { higroup = "YankColor", timeout = 300 }
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
api.nvim_create_autocmd({ "CursorMoved" }, {
|
||||||
|
pattern = "*",
|
||||||
|
group = yank_group,
|
||||||
|
callback = function()
|
||||||
|
vim.g.current_cursor_pos = vim.fn.getcurpos()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
api.nvim_create_autocmd("TextYankPost", {
|
||||||
|
pattern = "*",
|
||||||
|
group = yank_group,
|
||||||
|
---@diagnostic disable-next-line: unused-local
|
||||||
|
callback = function(ctx)
|
||||||
|
if vim.v.event.operator == "y" then
|
||||||
|
vim.fn.setpos(".", vim.g.current_cursor_pos)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Auto-create dir when saving a file in case some intermediate directory does not exist
|
||||||
|
api.nvim_create_autocmd({ "BufWritePre" }, {
|
||||||
|
pattern = "*",
|
||||||
|
group = api.nvim_create_augroup("auto_create_dir", { clear = true }),
|
||||||
|
callback = function(ctx)
|
||||||
|
local dir = fn.fnamemodify(ctx.file, ":p:h")
|
||||||
|
utils.may_create_dir(dir)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Automatically reload the file if it is changed outside of nvim
|
||||||
|
-- It seems that `checktime` does not work in command line, so we need to check if we are in
|
||||||
|
-- command line before executing this command
|
||||||
|
local auto_read_group = api.nvim_create_augroup("auto_read", { clear = true })
|
||||||
|
|
||||||
|
api.nvim_create_autocmd({ "FileChangedShellPost" }, {
|
||||||
|
pattern = "*",
|
||||||
|
group = auto_read_group,
|
||||||
|
callback = function()
|
||||||
|
vim.notify("File changed on disk. Buffer reloaded!", vim.log.levels.WARN, { title = "nvim-config" })
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
api.nvim_create_autocmd({ "FocusGained", "CursorHold" }, {
|
||||||
|
pattern = "*",
|
||||||
|
group = auto_read_group,
|
||||||
|
callback = function()
|
||||||
|
if fn.getcmdwintype() == "" then
|
||||||
|
vim.cmd("checktime")
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Resize all windows when we resize the terminal
|
||||||
|
api.nvim_create_autocmd("VimResized", {
|
||||||
|
group = api.nvim_create_augroup("win_autoresize", { clear = true }),
|
||||||
|
command = "wincmd =",
|
||||||
|
})
|
||||||
|
|
||||||
|
local function open_nvim_tree(data)
|
||||||
|
local is_directory = vim.fn.isdirectory(data.file) == 1
|
||||||
|
|
||||||
|
if not directory then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.cmd.enew()
|
||||||
|
vim.cmd.bw(data.buf)
|
||||||
|
require("nvim-tree.api").tree.open()
|
||||||
|
end
|
||||||
|
|
||||||
|
api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })
|
||||||
|
|
||||||
|
-- Do not use smart case in command line mode
|
||||||
|
api.nvim_create_augroup("dynamic_smartcase", { clear = true })
|
||||||
|
api.nvim_create_autocmd("CmdLineEnter", {
|
||||||
|
group = "dynamic_smartcase",
|
||||||
|
pattern = ":",
|
||||||
|
callback = function()
|
||||||
|
vim.o.smartcase = false
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
api.nvim_create_autocmd("CmdLineLeave", {
|
||||||
|
group = "dynamic_smartcase",
|
||||||
|
pattern = ":",
|
||||||
|
callback = function()
|
||||||
|
vim.o.smartcase = true
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
api.nvim_create_autocmd("TermOpen", {
|
||||||
|
group = api.nvim_create_augroup("term_start", { clear = true }),
|
||||||
|
pattern = "*",
|
||||||
|
callback = function()
|
||||||
|
vim.wo.relativenumber = false
|
||||||
|
vim.wo.number = false
|
||||||
|
vim.cmd("startinsert")
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
local number_toggle_group = api.nvim_create_augroup("numbertoggle", { clear = true })
|
||||||
|
api.nvim_create_autocmd({ "BufEnter", "FocusGained", "InsertLeave", "WinEnter" }, {
|
||||||
|
pattern = "*",
|
||||||
|
group = number_toggle_group,
|
||||||
|
callback = function()
|
||||||
|
if vim.wo.number then
|
||||||
|
vim.wo.relativenumber = true
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
api.nvim_create_autocmd({ "BufLeave", "FocusLost", "InsertEnter", "WinLeave" }, {
|
||||||
|
group = number_toggle_group,
|
||||||
|
callback = function()
|
||||||
|
if vim.wo.number then
|
||||||
|
vim.wo.relativenumber = false
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
api.nvim_create_autocmd("ColorScheme", {
|
||||||
|
group = api.nvim_create_augroup("custom_highlight", { clear = true }),
|
||||||
|
pattern = "*",
|
||||||
|
desc = "Define or override some highlight groups",
|
||||||
|
callback = function()
|
||||||
|
vim.api.nvim_set_hl(0, "YankColor", { fg = "#34495E", bg = "#2ECC71", ctermfg = 59, ctermbg = 41 })
|
||||||
|
vim.api.nvim_set_hl(0, "Cursor", { fg = "black", bg = "#00C918", bold = true })
|
||||||
|
vim.api.nvim_set_hl(0, "Cursor2", { fg = "red", bg = "red" })
|
||||||
|
vim.api.nvim_set_hl(0, "FloatBorder", { fg = "LightGreen", bg = "None", bold = true })
|
||||||
|
|
||||||
|
local hl = vim.api.nvim_get_hl(0, { name = "NormalFloat" })
|
||||||
|
vim.api.nvim_set_hl(0, "NormalFloat", { fg = hl.fg, bg = "None" })
|
||||||
|
|
||||||
|
vim.api.nvim_set_hl(0, "MatchParen", { bold = true, underline = true })
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
api.nvim_create_autocmd("BufEnter", {
|
||||||
|
pattern = "*",
|
||||||
|
group = api.nvim_create_augroup("auto_close_win", { clear = true }),
|
||||||
|
desc = "Quit nvim if we have only one window and its filetype matches our pattern",
|
||||||
|
---@diagnostic disable-next-line: unused-local
|
||||||
|
callback = function(ctx)
|
||||||
|
local quit_filetypes = { "qf", "vista", "NvimTree" }
|
||||||
|
local should_quit = true
|
||||||
|
local tabwins = api.nvim_tabpage_list_wins(0)
|
||||||
|
|
||||||
|
for _, win in pairs(tabwins) do
|
||||||
|
local buf = api.nvim_win_get_buf(win)
|
||||||
|
local buf_type = vim.api.nvim_get_option_value("filetype", { buf = buf })
|
||||||
|
|
||||||
|
if not vim.tbl_contains(quit_filetypes, buf_type) then
|
||||||
|
should_quit = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if should_quit then
|
||||||
|
vim.cmd("qall")
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
api.nvim_create_autocmd({ "VimEnter", "DirChanged" }, {
|
||||||
|
group = api.nvim_create_augroup("git_repo_check", { clear = true }),
|
||||||
|
pattern = "*",
|
||||||
|
desc = "Check if we are inside a git repo",
|
||||||
|
callback = function()
|
||||||
|
utils.inside_git_repo()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- ref: https://vi.stackexchange.com/a/169/15292
|
||||||
|
api.nvim_create_autocmd("BufReadPre", {
|
||||||
|
group = api.nvim_create_augroup("large_file", { clear = true }),
|
||||||
|
pattern = "*",
|
||||||
|
desc = "Optimize for large files",
|
||||||
|
callback = function(ctx)
|
||||||
|
local file_size_limit = 524288 -- 0.5MB
|
||||||
|
local f = ctx.file
|
||||||
|
|
||||||
|
if fn.getfsize(f) > file_size_limit or fn.getfsize(f) == -2 then
|
||||||
|
vim.o.eventignore = "all"
|
||||||
|
vim.o.ruler = true
|
||||||
|
vim.wo.relativenumber = false
|
||||||
|
vim.wo.number = false
|
||||||
|
vim.bo.swapfile = false
|
||||||
|
vim.bo.bufhidden = "unload"
|
||||||
|
vim.bo.undolevels = -1
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
62
lua/diagnostic-conf.lua
Normal file
62
lua/diagnostic-conf.lua
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
local diagnostic = vim.diagnostic
|
||||||
|
local api = vim.api
|
||||||
|
|
||||||
|
-- Global config for diagnostic
|
||||||
|
diagnostic.config {
|
||||||
|
underline = false,
|
||||||
|
virtual_text = false,
|
||||||
|
virtual_lines = false,
|
||||||
|
signs = {
|
||||||
|
text = {
|
||||||
|
[diagnostic.severity.ERROR] = "🆇",
|
||||||
|
[diagnostic.severity.WARN] = "⚠️",
|
||||||
|
[diagnostic.severity.INFO] = "ℹ️",
|
||||||
|
[diagnostic.severity.HINT] = "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
severity_sort = true,
|
||||||
|
float = {
|
||||||
|
source = true,
|
||||||
|
header = "Diagnostics:",
|
||||||
|
prefix = " ",
|
||||||
|
border = "single",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Set quickfix list from diagnostics in a certain buffer, not the whole workspace
|
||||||
|
local set_qflist = function(buf_num, severity)
|
||||||
|
local diagnostics = nil
|
||||||
|
diagnostics = diagnostic.get(buf_num, { severity = severity })
|
||||||
|
|
||||||
|
local qf_items = diagnostic.toqflist(diagnostics)
|
||||||
|
vim.fn.setqflist({}, " ", { title = "Diagnostics", items = qf_items })
|
||||||
|
|
||||||
|
vim.cmd([[copen]])
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<space>qw", diagnostic.setqflist, { desc = "Put window diagnostics to qf" })
|
||||||
|
vim.keymap.set("n", "<space>qb", function()
|
||||||
|
set_qflist(0)
|
||||||
|
end, { desc = "Put buffer diagnostics to qf" })
|
||||||
|
|
||||||
|
-- Automatically show diagnostic in float win for current line
|
||||||
|
api.nvim_create_autocmd("CursorHold", {
|
||||||
|
pattern = "*",
|
||||||
|
callback = function()
|
||||||
|
if #vim.diagnostic.get(0) == 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if not vim.b.diagnostics_pos then
|
||||||
|
vim.b.diagnostics_pos = { nil, nil }
|
||||||
|
end
|
||||||
|
|
||||||
|
local cursor_pos = api.nvim_win_get_cursor(0)
|
||||||
|
|
||||||
|
if not vim.deep_equal(cursor_pos, vim.b.diagnostics_pos) then
|
||||||
|
diagnostic.open_float { width = 100 }
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.b.diagnostics_pos = cursor_pos
|
||||||
|
end,
|
||||||
|
})
|
58
lua/globals.lua
Normal file
58
lua/globals.lua
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
local fn = vim.fn
|
||||||
|
local api = vim.api
|
||||||
|
|
||||||
|
local utils = require("utils")
|
||||||
|
|
||||||
|
-- Custom variables
|
||||||
|
vim.g.is_win = (utils.has("win32") or utils.has("win64")) and true or false
|
||||||
|
vim.g.is_linux = (utils.has("unix") and (not utils.has("macunix"))) and true or false
|
||||||
|
vim.g.is_mac = utils.has("macunix") and true or false
|
||||||
|
|
||||||
|
vim.g.logging_level = vim.log.levels.INFO
|
||||||
|
|
||||||
|
-- Built-in variables
|
||||||
|
vim.g.loaded_perl_provider = 0
|
||||||
|
vim.g.loaded_ruby_provider = 0
|
||||||
|
vim.g.loaded_node_provider = 0
|
||||||
|
vim.g.did_install_default_menus = 1 -- do not load menu
|
||||||
|
|
||||||
|
vim.g.python3_host_prog = "~/.local/share/nvim/venv/bin/python"
|
||||||
|
|
||||||
|
vim.g.mapleader = ","
|
||||||
|
|
||||||
|
-- Enable highlighting for lua HERE doc inside vim script
|
||||||
|
vim.g.vimsyn_embed = "l"
|
||||||
|
|
||||||
|
-- Use English as main language
|
||||||
|
vim.cmd([[language en_US.UTF-8]])
|
||||||
|
|
||||||
|
-- Disable loading certain plugins
|
||||||
|
|
||||||
|
-- Whether to load netrw by default
|
||||||
|
vim.g.loaded_netrw = 1
|
||||||
|
vim.g.loaded_netrwPlugin = 1
|
||||||
|
vim.g.netrw_liststyle = 3
|
||||||
|
if vim.g.is_win then
|
||||||
|
vim.g.netrw_http_cmd = "curl --ssl-no-revoke -Lo"
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Don't load tohtml.vim
|
||||||
|
vim.g.loaded_2html_plugin = 1
|
||||||
|
|
||||||
|
-- Don't load zipPlugin.vim, gzip.vim, or tarPlugin.vim
|
||||||
|
vim.g.loaded_zipPlugin = 1
|
||||||
|
vim.g.loaded_gzip = 1
|
||||||
|
vim.g.loaded_tarPlugin = 1
|
||||||
|
|
||||||
|
-- Don't load the tutor plugin
|
||||||
|
vim.g.loaded_tutor_mode_plugin = 1
|
||||||
|
|
||||||
|
-- Don't use built-in matchit.vim and matchparen.vim since we use vim-matchup
|
||||||
|
vim.g.loaded_matchit = 1
|
||||||
|
vim.g.loaded_matchparen = 1
|
||||||
|
|
||||||
|
-- Disable sql omni completion since it's broken
|
||||||
|
vim.g.loaded_sql_completion = 1
|
||||||
|
|
||||||
|
-- Control how to show health check window
|
||||||
|
vim.g.health = { style = nil }
|
14
lua/lsp_utils.lua
Normal file
14
lua/lsp_utils.lua
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
M.get_default_capabilities = function()
|
||||||
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
|
|
||||||
|
capabilities.textDocument.foldingRange = {
|
||||||
|
dynamicRegistration = false,
|
||||||
|
lineFoldingOnly = true,
|
||||||
|
}
|
||||||
|
|
||||||
|
return capabilities
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
153
lua/mappings.lua
Normal file
153
lua/mappings.lua
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
local keymap = vim.keymap
|
||||||
|
local uv = vim.uv
|
||||||
|
|
||||||
|
keymap.set({ "n", "x" }, ";", ":", { desc = "enter command mode" })
|
||||||
|
keymap.set("i", "<c-u>", "<Esc>viwUea", { desc = "make word upper case" })
|
||||||
|
keymap.set("i", "<c-t>", "<Esc>b~lea", { desc = "make word title case" })
|
||||||
|
keymap.set("n", "<leader>p", "m`o<ESC>p``", { desc = "paste below current line" })
|
||||||
|
keymap.set("n", "<leader>P", "m`O<ESC>p``", { desc = "paste above current line" })
|
||||||
|
keymap.set("n", "<leader>w", "<cmd>update<cr>", { silent = true, desc = "save buffer" })
|
||||||
|
keymap.set("n", "<leader>q", "<cmd>x<cr>", { silent = true, desc = "quit current window" })
|
||||||
|
keymap.set("n", "<leader>Q", "<cmd>qa!<cr>", { silent = true, desc = "quit nvim" })
|
||||||
|
keymap.set("n", [[\x]], "<cmd>windo lclose <bar> cclose <cr>", {
|
||||||
|
silent = true,
|
||||||
|
desc = "close qf and location lists",
|
||||||
|
})
|
||||||
|
keymap.set("n", [[\d]], "<cmd>bprevious <bar> bdelete #<cr>", {
|
||||||
|
silent = true,
|
||||||
|
desc = "delete current buffer",
|
||||||
|
})
|
||||||
|
keymap.set("n", [[\D]], function()
|
||||||
|
local buf_ids = vim.api.nvim_list_bufs()
|
||||||
|
local cur_buf = vim.api.nvim_win_get_buf(0)
|
||||||
|
|
||||||
|
for _, buf_id in pairs(buf_ids) do
|
||||||
|
if vim.api.nvim_get_option_value("buflisted", { buf = buf_id }) and buf_id ~= cur_buf then
|
||||||
|
vim.api.nvim_buf_delete(buf_id, { force = true })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end, { desc = "delete other buffers" })
|
||||||
|
keymap.set("n", "<space>o", "printf('m`%so<ESC>``', v:count1)", {
|
||||||
|
expr = true,
|
||||||
|
desc = "insert line below",
|
||||||
|
})
|
||||||
|
keymap.set("n", "<space>O", "printf('m`%sO<ESC>``', v:count1)", {
|
||||||
|
expr = true,
|
||||||
|
desc = "insert line above",
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Move the cursor base on physical lines, not the actual lines
|
||||||
|
keymap.set("n", "j", "v:count == 0 ? 'gj' : 'j'", { expr = true })
|
||||||
|
keymap.set("n", "k", "v:count == 0 ? 'gk' : 'k'", { expr = true })
|
||||||
|
keymap.set("n", "^", "g^")
|
||||||
|
keymap.set("n", "0", "g0")
|
||||||
|
|
||||||
|
-- Don't include white space characters when using '$' in visual mode
|
||||||
|
keymap.set("x", "$", "g_")
|
||||||
|
|
||||||
|
-- Go to start and end of line easier
|
||||||
|
keymap.set({ "n", "x" }, "H", "^")
|
||||||
|
keymap.set({ "n", "x" }, "L", "g_")
|
||||||
|
|
||||||
|
-- Continuous visual shifting
|
||||||
|
keymap.set("x", "<", "<gv")
|
||||||
|
keymap.set("x", ">", ">gv")
|
||||||
|
|
||||||
|
keymap.set("n", "<leader>ev", "<cmd>tabnew $MYVIMRC <bar> tcd %:h<cr>", {
|
||||||
|
silent = true,
|
||||||
|
desc = "open init.lua",
|
||||||
|
})
|
||||||
|
keymap.set("n", "<leader>sv", function()
|
||||||
|
vim.cmd([[
|
||||||
|
update $MYVIMRC
|
||||||
|
source $MYVIMRC
|
||||||
|
]])
|
||||||
|
vim.notify("Nvim config successfully reloaded!", vim.log.levels.INFO, { title = "nvim-config" })
|
||||||
|
end, { silent = true, desc = "reload init.lua" })
|
||||||
|
keymap.set("n", "<leader>v", "printf('`[%s`]', getregtype()[0])", {
|
||||||
|
expr = true,
|
||||||
|
desc = "reselect last pasted area",
|
||||||
|
})
|
||||||
|
keymap.set("n", "<leader>cd", "<cmd>lcd %:p:h<cr><cmd>pwd<cr>", { desc = "change cwd" })
|
||||||
|
keymap.set("t", "<Esc>", [[<c-\><c-n>]], { desc = "quit term" })
|
||||||
|
keymap.set("n", "<F11>", "<cmd>set spell!<cr>", { desc = "toggle spell" })
|
||||||
|
keymap.set("i", "<F11>", "<c-o><cmd>set spell!<cr>", { desc = "toggle spell" })
|
||||||
|
|
||||||
|
-- Change text without putting it into the vim register
|
||||||
|
keymap.set("n", "c", '"_c')
|
||||||
|
keymap.set("n", "C", '"_C')
|
||||||
|
keymap.set("n", "cc", '"_cc')
|
||||||
|
keymap.set("x", "c", '"_c')
|
||||||
|
|
||||||
|
keymap.set("n", "<leader><space>", "<cmd>StripTrailingWhitespace<cr>", { desc = "remove trailing spaces" })
|
||||||
|
keymap.set("n", "<leader>y", "<cmd>%yank<cr>", { desc = "yank entire buffer" })
|
||||||
|
keymap.set("n", "<leader>cl", "<cmd>call utils#ToggleCursorCol()<cr>", { desc = "toggle cursor column" })
|
||||||
|
keymap.set("n", "<A-k>", '<cmd>call utils#SwitchLine(line("."), "up")<cr>', { desc = "move line up" })
|
||||||
|
keymap.set("n", "<A-j>", '<cmd>call utils#SwitchLine(line("."), "down")<cr>', { desc = "move line down" })
|
||||||
|
keymap.set("x", "<A-k>", '<cmd>call utils#MoveSelection("up")<cr>', { desc = "move selection up" })
|
||||||
|
keymap.set("x", "<A-j>", '<cmd>call utils#MoveSelection("down")<cr>', { desc = "move selection down" })
|
||||||
|
keymap.set("x", "p", '"_c<Esc>p', { desc = "replace visual selection with text in register without contaminating the register" })
|
||||||
|
keymap.set("n", "gb", '<cmd>call buf_utils#GoToBuffer(v:count, "forward")<cr>', {
|
||||||
|
desc = "go to buffer (forward)",
|
||||||
|
})
|
||||||
|
keymap.set("n", "gB", '<cmd>call buf_utils#GoToBuffer(v:count, "backward")<cr>', {
|
||||||
|
desc = "go to buffer (backward)",
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Switch windows
|
||||||
|
keymap.set("n", "<left>", "<c-w>h")
|
||||||
|
keymap.set("n", "<right>", "<c-w>l")
|
||||||
|
keymap.set("n", "<up>", "<c-w>k")
|
||||||
|
keymap.set("n", "<down>", "<c-w>j")
|
||||||
|
|
||||||
|
keymap.set({ "x", "o" }, "iu", "<cmd>call text_obj#URL()<cr>", { desc = "URL text object" })
|
||||||
|
keymap.set({ "x", "o" }, "iB", ":<C-U>call text_obj#Buffer()<cr>", { desc = "buffer text object" })
|
||||||
|
keymap.set("n", "J", function()
|
||||||
|
vim.cmd([[
|
||||||
|
normal! mzJ`z
|
||||||
|
delmarks z
|
||||||
|
]])
|
||||||
|
end, { desc = "join lines without moving cursor" })
|
||||||
|
keymap.set("n", "gJ", function()
|
||||||
|
vim.cmd([[
|
||||||
|
normal! mzgJ`z
|
||||||
|
delmarks z
|
||||||
|
]])
|
||||||
|
end, { desc = "join lines without moving cursor" })
|
||||||
|
|
||||||
|
-- Break inserted text into smaller undo units
|
||||||
|
local undo_ch = { ",", ".", "!", "?", ";", ":" }
|
||||||
|
for _, ch in ipairs(undo_ch) do
|
||||||
|
keymap.set("i", ch, ch .. "<c-g>u")
|
||||||
|
end
|
||||||
|
|
||||||
|
keymap.set("i", "<A-;>", "<Esc>miA;<Esc>`ii", { desc = "insert semicolon at end" })
|
||||||
|
keymap.set("i", "<c-a>", "<HOME>", { desc = "go to beginning of line" })
|
||||||
|
keymap.set("i", "<c-e>", "<END>", { desc = "go to end of line" })
|
||||||
|
keymap.set("c", "<c-a>", "<HOME>", { desc = "go to beginning of command" })
|
||||||
|
keymap.set("i", "<c-d>", "<DEL>", { desc = "delete character to right of cursor" })
|
||||||
|
keymap.set("n", "<leader>cb", function()
|
||||||
|
local cnt = 0
|
||||||
|
local blink_times = 7
|
||||||
|
local timer = uv.new_timer()
|
||||||
|
if timer == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
timer:start(
|
||||||
|
0,
|
||||||
|
100,
|
||||||
|
vim.schedule_wrap(function()
|
||||||
|
vim.cmd([[
|
||||||
|
set cursorcolumn!
|
||||||
|
set cursorline!
|
||||||
|
]])
|
||||||
|
|
||||||
|
if cnt == blink_times then
|
||||||
|
timer:close()
|
||||||
|
end
|
||||||
|
|
||||||
|
cnt = cnt + 1
|
||||||
|
end)
|
||||||
|
)
|
||||||
|
end, { desc = "show cursor" })
|
405
lua/plugin_specs.lua
Normal file
405
lua/plugin_specs.lua
Normal file
@ -0,0 +1,405 @@
|
|||||||
|
local utils = require("utils")
|
||||||
|
|
||||||
|
local plugin_dir = vim.fn.stdpath("data") .. "/lazy"
|
||||||
|
local lazypath = plugin_dir .. "/lazy.nvim"
|
||||||
|
|
||||||
|
if not vim.uv.fs_stat(lazypath) then
|
||||||
|
vim.fn.system {
|
||||||
|
"git",
|
||||||
|
"clone",
|
||||||
|
"--filter=blob:none",
|
||||||
|
"https://github.com/folke/lazy.nvim.git",
|
||||||
|
"--branch=stable",
|
||||||
|
lazypath,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
vim.opt.rtp:prepend(lazypath)
|
||||||
|
|
||||||
|
local firenvim_not_active = function()
|
||||||
|
return not vim.g.started_by_firenvim
|
||||||
|
end
|
||||||
|
|
||||||
|
local plugin_specs = {
|
||||||
|
{ "hrsh7th/cmp-nvim-lsp", lazy = true },
|
||||||
|
{ "hrsh7th/cmp-path", lazy = true },
|
||||||
|
{ "hrsh7th/cmp-buffer", lazy = true },
|
||||||
|
{ "hrsh7th/cmp-omni", lazy = true },
|
||||||
|
{ "hrsh7th/cmp-cmdline", lazy = true },
|
||||||
|
{ "quangnguyen30192/cmp-nvim-ultisnips", lazy = true },
|
||||||
|
{
|
||||||
|
"hrsh7th/nvim-cmp",
|
||||||
|
name = "nvim-cmp",
|
||||||
|
event = "VeryLazy",
|
||||||
|
config = function()
|
||||||
|
require("config.nvim-cmp")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"echasnovski/mini.icons",
|
||||||
|
version = false,
|
||||||
|
config = function()
|
||||||
|
require("mini.icons").mock_nvim_web_devicons()
|
||||||
|
require("mini.icons").tweak_lsp_kind()
|
||||||
|
end,
|
||||||
|
lazy = true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"SirVer/ultisnips",
|
||||||
|
dependencies = {
|
||||||
|
"honza/vim-snippets",
|
||||||
|
},
|
||||||
|
event = "InsertEnter",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"neovim/nvim-lspconfig",
|
||||||
|
config = function()
|
||||||
|
require("config.lsp")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dnlhc/glance.nvim",
|
||||||
|
config = function()
|
||||||
|
require("config.glance")
|
||||||
|
end,
|
||||||
|
event = "VeryLazy",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"nvim-treesitter/nvim-treesitter",
|
||||||
|
lazy = true,
|
||||||
|
build = ":TSUpdate",
|
||||||
|
config = function()
|
||||||
|
require("config.treesitter")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"nvim-treesitter/nvim-treesitter-textobjects",
|
||||||
|
event = "VeryLazy",
|
||||||
|
branch = "master",
|
||||||
|
config = function()
|
||||||
|
require("config.treesitter-textobjects")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{ "machakann/vim-swap", event = "VeryLazy" },
|
||||||
|
{
|
||||||
|
"smoka7/hop.nvim",
|
||||||
|
keys = { "f" },
|
||||||
|
config = function()
|
||||||
|
require("config.nvim-hop")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kevinhwang91/nvim-hlslens",
|
||||||
|
branch = "main",
|
||||||
|
keys = { "*", "#", "n", "N" },
|
||||||
|
config = function()
|
||||||
|
require("config.hlslens")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"nvim-telescope/telescope.nvim",
|
||||||
|
cmd = "Telescope",
|
||||||
|
dependencies = {
|
||||||
|
"nvim-telescope/telescope-symbols.nvim",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ibhagwan/fzf-lua",
|
||||||
|
config = function()
|
||||||
|
require("config.fzf-lua")
|
||||||
|
end,
|
||||||
|
event = "VeryLazy",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"MeanderingProgrammer/markdown.nvim",
|
||||||
|
main = "render-markdown",
|
||||||
|
opts = {},
|
||||||
|
ft = { "markdown" },
|
||||||
|
},
|
||||||
|
{ "navarasu/onedark.nvim", lazy = true },
|
||||||
|
{ "sainnhe/edge", lazy = true },
|
||||||
|
{ "sainnhe/sonokai", lazy = true },
|
||||||
|
{ "sainnhe/gruvbox-material", lazy = true },
|
||||||
|
{ "sainnhe/everforest", lazy = true },
|
||||||
|
{ "EdenEast/nightfox.nvim", lazy = true },
|
||||||
|
{ "catppuccin/nvim", name = "catppuccin", lazy = true },
|
||||||
|
{ "olimorris/onedarkpro.nvim", lazy = true },
|
||||||
|
{ "marko-cerovac/material.nvim", lazy = true },
|
||||||
|
{
|
||||||
|
"rockyzhang24/arctic.nvim",
|
||||||
|
dependencies = { "rktjmp/lush.nvim" },
|
||||||
|
name = "arctic",
|
||||||
|
branch = "v2",
|
||||||
|
},
|
||||||
|
{ "rebelot/kanagawa.nvim", lazy = true },
|
||||||
|
{ "miikanissi/modus-themes.nvim", priority = 1000 },
|
||||||
|
{ "wtfox/jellybeans.nvim", priority = 1000 },
|
||||||
|
{ "projekt0n/github-nvim-theme", name = "github-theme" },
|
||||||
|
{ "e-ink-colorscheme/e-ink.nvim", priority = 1000 },
|
||||||
|
{ "ficcdaf/ashen.nvim", priority = 1000 },
|
||||||
|
{ "savq/melange-nvim", priority = 1000 },
|
||||||
|
{ "Skardyy/makurai-nvim", priority = 1000 },
|
||||||
|
{ "vague2k/vague.nvim", priority = 1000 },
|
||||||
|
{ "webhooked/kanso.nvim", priority = 1000 },
|
||||||
|
{ "zootedb0t/citruszest.nvim", priority = 1000 },
|
||||||
|
{
|
||||||
|
"nvim-lualine/lualine.nvim",
|
||||||
|
event = "BufRead",
|
||||||
|
cond = firenvim_not_active,
|
||||||
|
config = function()
|
||||||
|
require("config.lualine")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"akinsho/bufferline.nvim",
|
||||||
|
event = { "BufEnter" },
|
||||||
|
cond = firenvim_not_active,
|
||||||
|
config = function()
|
||||||
|
require("config.bufferline")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"nvimdev/dashboard-nvim",
|
||||||
|
cond = firenvim_not_active,
|
||||||
|
config = function()
|
||||||
|
require("config.dashboard-nvim")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"echasnovski/mini.indentscope",
|
||||||
|
version = false,
|
||||||
|
config = function()
|
||||||
|
local mini_indent = require("mini.indentscope")
|
||||||
|
mini_indent.setup {
|
||||||
|
draw = {
|
||||||
|
animation = mini_indent.gen_animation.none(),
|
||||||
|
},
|
||||||
|
symbol = "▏",
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"luukvbaal/statuscol.nvim",
|
||||||
|
opts = {},
|
||||||
|
config = function()
|
||||||
|
require("config.nvim-statuscol")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kevinhwang91/nvim-ufo",
|
||||||
|
dependencies = "kevinhwang91/promise-async",
|
||||||
|
event = "VeryLazy",
|
||||||
|
opts = {},
|
||||||
|
init = function()
|
||||||
|
vim.o.foldcolumn = "1"
|
||||||
|
vim.o.foldlevel = 99
|
||||||
|
vim.o.foldlevelstart = 99
|
||||||
|
vim.o.foldenable = true
|
||||||
|
end,
|
||||||
|
config = function()
|
||||||
|
require("config.nvim-ufo")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{ "itchyny/vim-highlighturl", event = "BufReadPost" },
|
||||||
|
{
|
||||||
|
"rcarriga/nvim-notify",
|
||||||
|
event = "VeryLazy",
|
||||||
|
config = function()
|
||||||
|
require("config.nvim-notify")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{"nvim-lua/plenary.nvim", lazy = true },
|
||||||
|
{
|
||||||
|
"liuchengxu/vista.vim",
|
||||||
|
enabled = function()
|
||||||
|
return utils.executable("ctags")
|
||||||
|
end,
|
||||||
|
cmd = "Vista",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"windwp/nvim-autopairs",
|
||||||
|
event = "InsertEnter",
|
||||||
|
config = true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tpope/vim-commentary",
|
||||||
|
keys = {
|
||||||
|
{ "gc", mode = "n" },
|
||||||
|
{ "gc", mode = "v" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ "simnalamburt/vim-mundo", cmd = { "MundoToggle", "MundoShow" } },
|
||||||
|
{
|
||||||
|
"gbprod/yanky.nvim",
|
||||||
|
config = function()
|
||||||
|
require("config.yanky")
|
||||||
|
end,
|
||||||
|
cmd = "YankyRingHistory",
|
||||||
|
},
|
||||||
|
{ "tpope/vim-eunuch", cmd = { "Rename", "Delete" } },
|
||||||
|
{ "tpope/vim-repeat", event = "VeryLazy" },
|
||||||
|
{ "nvim-zh/better-escape.vim", event = { "InsertEnter" } },
|
||||||
|
{
|
||||||
|
"tpope/vim-fugitive",
|
||||||
|
event = "User InGitRepo",
|
||||||
|
config = function()
|
||||||
|
require("config.fugitive")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"NeogitOrg/neogit",
|
||||||
|
dependencies = {
|
||||||
|
"nvim-lua/plenary.nvim",
|
||||||
|
},
|
||||||
|
event = "User InGitRepo",
|
||||||
|
},
|
||||||
|
{ "rbong/vim-flog", cmd = { "Flog" } },
|
||||||
|
{
|
||||||
|
"akinsho/git-conflict.nvim",
|
||||||
|
version = "*",
|
||||||
|
event = "VeryLazy",
|
||||||
|
config = function()
|
||||||
|
require("config.git-conflict")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ruifm/gitlinker.nvim",
|
||||||
|
event = "User InGitRepo",
|
||||||
|
config = function()
|
||||||
|
require("config.git-linker")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"lewis6991/gitsigns.nvim",
|
||||||
|
config = function()
|
||||||
|
require("config.gitsigns")
|
||||||
|
end,
|
||||||
|
event = "BufRead",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sindrets/diffview.nvim",
|
||||||
|
cmd = { "DiffViewOpen" },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kevinhwang91/nvim-bqf",
|
||||||
|
ft = "qf",
|
||||||
|
config = function()
|
||||||
|
require("config.bqf")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{ "vim-pandoc/vim-markdownfootnotes", ft = { "markdown" } },
|
||||||
|
{ "godlygeek/tabular", ft = { "markdown" } },
|
||||||
|
{ "chrisbra/unicode.vim", keys = { "ga" }, cmd = { "UnicodeSearch" } },
|
||||||
|
{ "wellle/targets.vim", event = "VeryLazy" },
|
||||||
|
{ "machakann/vim-sandwich", event = "VeryLazy" },
|
||||||
|
{
|
||||||
|
"tmux-plugins/vim-tmux",
|
||||||
|
enabled = function()
|
||||||
|
return utils.executable("tmux")
|
||||||
|
end,
|
||||||
|
ft = { "tmux" },
|
||||||
|
},
|
||||||
|
{ "andymass/vim-matchup", event = "BufRead" },
|
||||||
|
{ "tpope/vim-scriptease", cmd = { "Scriptnames", "Messages", "Verbose" } },
|
||||||
|
{ "skywind3000/asyncrun.vim", lazy = true, cmd = { "AsyncRun" } },
|
||||||
|
{ "cespare/vim-toml", ft = { "toml" }, branch = "main" },
|
||||||
|
{
|
||||||
|
"sakhnik/nvim-gdb",
|
||||||
|
enabled = function()
|
||||||
|
return vim.g.is_win or vim.g.is_linux
|
||||||
|
end,
|
||||||
|
build = { "bash install.sh" },
|
||||||
|
lazy = true,
|
||||||
|
},
|
||||||
|
{ "tpope/vim-obsession", cmd = "Obsession" },
|
||||||
|
{
|
||||||
|
"ojroques/vim-oscyank",
|
||||||
|
enabled = function()
|
||||||
|
return vim.g.is_linux
|
||||||
|
end,
|
||||||
|
cmd = { "OSCYank", "OSCYankReg" },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"folke/which-key.nvim",
|
||||||
|
event = "VeryLazy",
|
||||||
|
config = function()
|
||||||
|
require("config.which-key")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"folke/snacks.nvim",
|
||||||
|
priority = 1000,
|
||||||
|
lazy = false,
|
||||||
|
opts = {
|
||||||
|
input = {
|
||||||
|
enabled = true,
|
||||||
|
win = {
|
||||||
|
relative = "cursor",
|
||||||
|
backdrop = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
picker = { enabled = true },
|
||||||
|
image = { enabled = false },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ "jdhao/whitespace.nvim", event = "VeryLazy" },
|
||||||
|
{
|
||||||
|
"nvim-tree/nvim-tree.lua",
|
||||||
|
keys = { "<space>s" },
|
||||||
|
config = function()
|
||||||
|
require("config.nvim-tree")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"j-hui/fidget.nvim",
|
||||||
|
event = "BufRead",
|
||||||
|
config = function()
|
||||||
|
require("config.fidget-nvim")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"folke/lazydev.nvim",
|
||||||
|
ft = "lua",
|
||||||
|
opts = {
|
||||||
|
library = {
|
||||||
|
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"smjonas/live-command.nvim",
|
||||||
|
event = "VeryLazy",
|
||||||
|
config = function()
|
||||||
|
require("config.live-command")
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kosayoda/nvim-lightbulb",
|
||||||
|
config = function()
|
||||||
|
require("config.lightbulb")
|
||||||
|
end,
|
||||||
|
event = "LspAttach",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Bekaboo/dropbar.nvim",
|
||||||
|
event = "VeryLazy",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"catgoose/nvim-colorizer.lua",
|
||||||
|
event = "BufReadPre",
|
||||||
|
opts = {},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
---@diagnostic disable-next-line: missing-fields
|
||||||
|
require("lazy").setup {
|
||||||
|
spec = plugin_specs,
|
||||||
|
ui = {
|
||||||
|
border = "rounded",
|
||||||
|
title = "Plugin Manager",
|
||||||
|
title_pos = "center",
|
||||||
|
},
|
||||||
|
rocks = {
|
||||||
|
enabled = false,
|
||||||
|
hererocks = false,
|
||||||
|
},
|
||||||
|
}
|
87
lua/utils.lua
Normal file
87
lua/utils.lua
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
local fn = vim.fn
|
||||||
|
local version = vim.version
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
--- Check if an executable exists
|
||||||
|
--- @param name string An executable name/path
|
||||||
|
--- @return boolean
|
||||||
|
function M.executable(name)
|
||||||
|
return fn.executable(name) > 0
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Check whether a feature exists in nvim
|
||||||
|
--- @param feat string the feature name, like `nvim-0.7` or `unix`
|
||||||
|
--- @return boolean
|
||||||
|
M.has = function(feat)
|
||||||
|
if fn.has(feat) == 1 then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Create a dir if it does not exist
|
||||||
|
function M.may_create_dir(dir)
|
||||||
|
local res = fn.isdirectory(dir)
|
||||||
|
if res == 0 then
|
||||||
|
fn.mkdir(dir, "p")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Generate random integers in the range [low, high], inclusive,
|
||||||
|
--- @param low integer the lower value for this range
|
||||||
|
--- @param high integer the upper value for this range
|
||||||
|
--- @return integer
|
||||||
|
function M.rand_int(low, high)
|
||||||
|
math.randomseed(os.time())
|
||||||
|
return math.random(low, high)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Select a random element from a sequence/list
|
||||||
|
--- @param seq any[] the sequence to choose an element from
|
||||||
|
function M.rand_element(seq)
|
||||||
|
local idx = M.rand_int(1, #seq)
|
||||||
|
return seq[idx]
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Check if the current nvim version is compatible with the allowed version
|
||||||
|
--- @param expected_version string
|
||||||
|
--- @return boolean
|
||||||
|
function M.is_compatible_version(expected_version)
|
||||||
|
local expect_ver = version.parse(expected_version)
|
||||||
|
local actual_ver = vim.version()
|
||||||
|
|
||||||
|
if expect_ver == nil then
|
||||||
|
local msg = string.format("Unsupported version string: %s", expected_version)
|
||||||
|
vim.api.nvim_echo({ { msg } }, true, { err = true })
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local result = version.cmp(expect_ver, actual_ver)
|
||||||
|
if result ~= 0 then
|
||||||
|
local _ver = string.format("%s.%s.%s", actual_ver.major, actual_ver.minor, actual_ver.patch)
|
||||||
|
local msg = string.format(
|
||||||
|
"Expect nvim version %s, but your current nvim version is %s. Use at your own risk!",
|
||||||
|
expected_version,
|
||||||
|
_ver
|
||||||
|
)
|
||||||
|
vim.api.nvim_echo({ { msg } }, true, { err = true })
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Check if we are inside a git repo
|
||||||
|
--- @return boolean
|
||||||
|
function M.inside_git_repo()
|
||||||
|
local result = vim.system({ "git", "rev-parse", "--is-inside-work-tree" }, { text = true }):wait()
|
||||||
|
if result.code ~= 0 then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.cmd([[doautocmd User InGitRepo]])
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
7
my_snippets/all.snippets
Normal file
7
my_snippets/all.snippets
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
snippet "(?<!\w)ltx" "LaTeX symbol" r
|
||||||
|
LaTeX
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet arw "Right-pointed arrow"
|
||||||
|
--> $1
|
||||||
|
endsnippet
|
149
my_snippets/cpp.snippets
Normal file
149
my_snippets/cpp.snippets
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
snippet bar "barebone code template"
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <map>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <set>
|
||||||
|
#include <unordered_set>
|
||||||
|
#include <stack>
|
||||||
|
#include <queue>
|
||||||
|
#include <numeric>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet icd "#include directive" b
|
||||||
|
#include <$1>
|
||||||
|
$0
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet plist "print vector" w
|
||||||
|
template <class T>
|
||||||
|
void printList(const T& arr, const string& desc) {
|
||||||
|
std::cout << desc << ": [";
|
||||||
|
for (auto it = arr.begin(); it != arr.end(); it++) {
|
||||||
|
std::cout << *it << ((std::next(it) != arr.end()) ? ", " : "");
|
||||||
|
}
|
||||||
|
std::cout << "]" << std::endl;
|
||||||
|
}
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet pmat "print matrix" w
|
||||||
|
template <class T>
|
||||||
|
void printMat(const std::vector<std::vector<T>>& mat, const string& desc) {
|
||||||
|
std::cout << desc << ": " << std::endl;
|
||||||
|
for (auto it1 = mat.begin(); it1 != mat.end(); it1++) {
|
||||||
|
auto cur_vec = *it1;
|
||||||
|
std::cout << "[";
|
||||||
|
for (auto it2 = cur_vec.begin(); it2 != cur_vec.end(); it2++) {
|
||||||
|
std::cout << *it2 << ((std::next(it2) != cur_vec.end()) ? ", " : "]\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet pqueue "print queue"
|
||||||
|
template <class T>
|
||||||
|
void printQueue(T q) {
|
||||||
|
while (!q.empty()) {
|
||||||
|
std::cout << q.top() << " ";
|
||||||
|
q.pop();
|
||||||
|
}
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet cout "print a variable" w
|
||||||
|
std::cout << "$1: " << $2 << std::endl;
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet random "Generate a random list" b
|
||||||
|
std::vector<int> genRandom(int low, int high, int len) {
|
||||||
|
std::random_device rd;
|
||||||
|
std::mt19937 gen(rd());
|
||||||
|
std::uniform_int_distribution<int> distribution(low, high);
|
||||||
|
|
||||||
|
std::vector<int> arr(len, 0);
|
||||||
|
for (int i = 0; i != len; ++i) {
|
||||||
|
arr[i] = distribution(gen);
|
||||||
|
}
|
||||||
|
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet incset "Use set" b
|
||||||
|
#include <set>
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet incmap "Use map" b
|
||||||
|
#include <map>
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet incqueue "Use queue" b
|
||||||
|
#include <queue>
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet incstr "Use string" b
|
||||||
|
#include <string>
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet incvec "Use vector" b
|
||||||
|
#include <vector>
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet incstack "Use stack" b
|
||||||
|
#include <stack>
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet vec "std::vector" w
|
||||||
|
std::vector<$1> ${2:vec}
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet map "std::map" w
|
||||||
|
std::map<$1, $2> ${3:mymap}
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet umap "std::unordered_map"
|
||||||
|
std::unordered_map<$1, $2> ${3:mymap}
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet set "std::set" w
|
||||||
|
std::set<$1> ${2:myset}
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet uset "std::unordered_set" w
|
||||||
|
std::unordered_set<$1> ${2:myset}
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet queue "std::queue" w
|
||||||
|
std::queue<$1> ${2:q}
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet stack "std::stack" w
|
||||||
|
std::stack<$1> ${2:mystack}
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet for "for loop" w
|
||||||
|
for ($1; $2; $3) {
|
||||||
|
$4
|
||||||
|
}
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet if "if condition" w
|
||||||
|
if ($1) {
|
||||||
|
$2
|
||||||
|
}
|
||||||
|
$0
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet ifelse "if else condition"
|
||||||
|
if ($1) {
|
||||||
|
$2
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
endsnippet
|
163
my_snippets/markdown.snippets
Normal file
163
my_snippets/markdown.snippets
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
global !p
|
||||||
|
def gen_header(snip):
|
||||||
|
placeholders_string = snip.buffer[snip.line].strip()
|
||||||
|
level = int(placeholders_string[0])
|
||||||
|
|
||||||
|
# erase current line
|
||||||
|
snip.buffer[snip.line] = ""
|
||||||
|
line_content = "#" * level + " ${1:Section Name}"
|
||||||
|
line_content += '\n$0'
|
||||||
|
|
||||||
|
snip.expand_anon(line_content)
|
||||||
|
endglobal
|
||||||
|
|
||||||
|
snippet "(k1|kbd)" "HTML kbd tag" rw
|
||||||
|
<kbd>${1:KEY}</kbd>$0
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet k2 "Two key strokes shortcut"
|
||||||
|
<kbd>${1:KEY}</kbd> + <kbd>${2:KEY}</kbd>
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet k3 "Three key strokes shortcut"
|
||||||
|
<kbd>${1:KEY}</kbd> + <kbd>${2:KEY}</kbd> + <kbd>${3:KEY}</kbd>
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet meta "Markdown front matter (YAML format)" b
|
||||||
|
---
|
||||||
|
title: "$1"
|
||||||
|
date: `!p from datetime import datetime
|
||||||
|
if not snip.c:
|
||||||
|
snip.rv = datetime.now().astimezone().strftime("%Y-%m-%d %H:%M:%S%z")`
|
||||||
|
tags: [$2]
|
||||||
|
categories: [$3]
|
||||||
|
---
|
||||||
|
$0
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet more "HTML more tag"
|
||||||
|
<!--more-->
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet img "Aligned image using HTML tag"
|
||||||
|
<p align="center">
|
||||||
|
<img src="${1:URL}" width="${2:800}">
|
||||||
|
</p>
|
||||||
|
$0
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet font "HTML font tag"
|
||||||
|
<font color="${1:blue}">${2:TEXT}</font>
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet link "Markdown links"
|
||||||
|
[$1]($2)$0
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet rlink "Markdown ref link"
|
||||||
|
[${1:link_text}][${2:label}]
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
post_jump "gen_header(snip)"
|
||||||
|
snippet "h([1-6])" "Markdown header" br
|
||||||
|
`!p snip.rv = match.group(1)`
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet detail "Clickable details" b
|
||||||
|
<details>
|
||||||
|
<summary><font size="2" color="red">${1:Click to show the code.}</font></summary>
|
||||||
|
|
||||||
|
$2
|
||||||
|
</details>
|
||||||
|
|
||||||
|
snippet info "info box"
|
||||||
|
<style type="text/css">
|
||||||
|
@import url('//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css');
|
||||||
|
|
||||||
|
.info-msg {
|
||||||
|
color: #059;
|
||||||
|
background-color: #BEF;
|
||||||
|
margin: 5px 0;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 5px 5px 5px 5px;
|
||||||
|
border: 2px solid transparent;
|
||||||
|
border-color: transparent;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div class="info-msg">
|
||||||
|
<i class="fa fa-info-circle"> Info</i></br>
|
||||||
|
${1:info text}
|
||||||
|
</div>
|
||||||
|
$0
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet warn "warning box"
|
||||||
|
<style type="text/css">
|
||||||
|
@import url('//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css');
|
||||||
|
|
||||||
|
.warning-msg {
|
||||||
|
color: #9F6000;
|
||||||
|
background-color: #FEEFB3;
|
||||||
|
margin: 5px 0;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 5px 5px 5px 5px;
|
||||||
|
border: 2px solid transparent;
|
||||||
|
border-color: transparent;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div class="warning-msg">
|
||||||
|
<i class="fa fa-warning"> Warning</i></br>
|
||||||
|
${1:warning text}
|
||||||
|
</div>
|
||||||
|
$0
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet error "error box"
|
||||||
|
<style type="text/css">
|
||||||
|
@import url('//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css');
|
||||||
|
|
||||||
|
.error-msg {
|
||||||
|
color: #D8000C;
|
||||||
|
background-color: #FFBABA;
|
||||||
|
margin: 5px 0;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 5px 5px 5px 5px;
|
||||||
|
border: 2px solid transparent;
|
||||||
|
border-color: transparent;
|
||||||
|
}
|
||||||
|
<style>
|
||||||
|
|
||||||
|
<div class="error-msg">
|
||||||
|
<i class="fa fa-times-circle"> Error</i></br>
|
||||||
|
${1:error text}
|
||||||
|
</div>
|
||||||
|
$0
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet success "success box"
|
||||||
|
<style type="text/css">
|
||||||
|
@import url('//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css');
|
||||||
|
|
||||||
|
.success-msg {
|
||||||
|
color: #270;
|
||||||
|
background-color: #DFF2BF;
|
||||||
|
margin: 5px 0;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 5px 5px 5px 5px;
|
||||||
|
border: 2px solid transparent;
|
||||||
|
border-color: transparent;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div class="success-msg">
|
||||||
|
<i class="fa fa-check"></i>
|
||||||
|
${1:success text}
|
||||||
|
</div>
|
||||||
|
$0
|
||||||
|
endsnippet
|
15
my_snippets/python.snippets
Normal file
15
my_snippets/python.snippets
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
snippet fimp "from foo import bar"
|
||||||
|
from ${1:foo} import ${2:bar}
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet impa "import foo as bar"
|
||||||
|
import ${1:foo} as ${2:bar}
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet main "Main function boilerplate" b
|
||||||
|
def main():
|
||||||
|
$0
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
endsnippet
|
5
my_snippets/snippets.snippets
Normal file
5
my_snippets/snippets.snippets
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
snippet snip "Ultisnips snippet definition" b
|
||||||
|
`!p snip.rv = "snippet"` ${1:Tab_trigger} "${2:Description}" ${3:b}
|
||||||
|
${0:${VISUAL}}
|
||||||
|
`!p snip.rv = "endsnippet"`
|
||||||
|
endsnippet
|
9
my_snippets/tex.snippets
Normal file
9
my_snippets/tex.snippets
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
snippet use "usepackage" b
|
||||||
|
\usepackage{${1:package}}
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet eqa "equation environment" b
|
||||||
|
\begin{equation}\label{$1}
|
||||||
|
$2
|
||||||
|
\end{equation}
|
||||||
|
endsnippet
|
14
my_snippets/vim.snippets
Normal file
14
my_snippets/vim.snippets
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
snippet fun "vim function"
|
||||||
|
function! ${1:MyFunc}(${2}) abort
|
||||||
|
$3
|
||||||
|
endfunction
|
||||||
|
$0
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet aug "vim augroup" b
|
||||||
|
augroup ${1:GROUP_NAME}
|
||||||
|
autocmd!
|
||||||
|
autocmd ${2:EVENT} ${3:PATTERN} $4
|
||||||
|
augroup END
|
||||||
|
$0
|
||||||
|
endsnippet
|
6
package-lock.json
generated
Normal file
6
package-lock.json
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"name": "nvim",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {}
|
||||||
|
}
|
3
plugin/abbrev.vim
Normal file
3
plugin/abbrev.vim
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
iabbrev reqire require
|
||||||
|
iabbrev serveral several
|
||||||
|
iabbrev ture true
|
50
plugin/command.lua
Normal file
50
plugin/command.lua
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
vim.api.nvim_create_user_command("CopyPath", function(context)
|
||||||
|
local full_path = vim.fn.glob("%:p")
|
||||||
|
local file_path = nil
|
||||||
|
if context["args"] == "nameonly" then
|
||||||
|
file_path = vim.fn.fnamemodify(full_path, ":t")
|
||||||
|
end
|
||||||
|
|
||||||
|
if context["args"] == "relative" then
|
||||||
|
local project_marker = { ".git", "pyproject.toml" }
|
||||||
|
local project_root = vim.fs.root(0, project_marker)
|
||||||
|
if project_root == nil then
|
||||||
|
vim.print("can't find project root")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
file_path = vim.fn.substitute(full_path, project_root, "<project-root>", "g")
|
||||||
|
end
|
||||||
|
|
||||||
|
if context["args"] == "absolute" then
|
||||||
|
file_path = full_path
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.fn.setreg("+", file_path)
|
||||||
|
vim.print("Filepath copied to clipboard!")
|
||||||
|
end, {
|
||||||
|
bang = false,
|
||||||
|
nargs = 1,
|
||||||
|
force = true,
|
||||||
|
desc = "Copy current file path to clipboard",
|
||||||
|
complete = function()
|
||||||
|
return { "nameonly", "relative", "absolute" }
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_user_command("JSONFormat", function(context)
|
||||||
|
local range = context["range"]
|
||||||
|
local line1 = context["line1"]
|
||||||
|
local line2 = context["line2"]
|
||||||
|
|
||||||
|
if range == 0 or range == 2 then
|
||||||
|
local cmd_str = string.format("%s,%s!python -m json.tool", line1, line2)
|
||||||
|
vim.fn.execute(cmd_str)
|
||||||
|
else
|
||||||
|
local msg = string.format("unsupported range: %s", range)
|
||||||
|
vim.api.nvim_echo({ { msg } }, true, { err = true })
|
||||||
|
end
|
||||||
|
end, {
|
||||||
|
desc = "Format JSON",
|
||||||
|
range = "%",
|
||||||
|
})
|
46
plugin/command.vim
Normal file
46
plugin/command.vim
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
" Capture output from a command to register @m
|
||||||
|
" To paste, press "mp
|
||||||
|
command! -nargs=1 -complete=command Redir call utils#CaptureCommandOutput(<q-args>)
|
||||||
|
|
||||||
|
command! -bar -bang -nargs=+ -complete=file Edit call utils#MultiEdit([<f-args>])
|
||||||
|
call utils#Cabbrev('edit', 'Edit')
|
||||||
|
|
||||||
|
call utils#Cabbrev('man', 'Man')
|
||||||
|
|
||||||
|
" show current date and time in human-readable format
|
||||||
|
command! -nargs=? Datetime echo utils#iso_time(<q-args>)
|
||||||
|
|
||||||
|
" Convert Markdown file to PDF
|
||||||
|
command! ToPDF call s:md_to_pdf()
|
||||||
|
|
||||||
|
function! s:md_to_pdf() abort
|
||||||
|
" check if pandoc is installed
|
||||||
|
if executable('pandoc') != 1
|
||||||
|
echoerr 'pandoc not found'
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:md_path = expand('%:p')
|
||||||
|
let l:pdf_path = fnamemodify(l:md_path, ':r') .. '.pdf'
|
||||||
|
|
||||||
|
let l:header_path = stdpath('config') . '/resources/head.tex'
|
||||||
|
|
||||||
|
let l:cmd = 'pandoc --pdf-engine=xelatex --highlight-style=zenburn --table-of-content ' .
|
||||||
|
\ '--include-in-header=' . l:header_path . ' -V fontsize=10pt -V colorlinks -V toccolor=NavyBlue ' .
|
||||||
|
\ '-V linkcolor=red -V urlcolor=teal -V filecolor=magenta -s ' .
|
||||||
|
\ l:md_path . ' -o ' . l:pdf_path
|
||||||
|
|
||||||
|
if g:is_mac
|
||||||
|
let l:cmd = l:cmd . '&& open ' . l:pdf_path
|
||||||
|
endif
|
||||||
|
|
||||||
|
if g:is_win
|
||||||
|
let l:cmd = l:cmd . '&& start ' . l:pdf_path
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:id = jobstart(l:cmd)
|
||||||
|
|
||||||
|
if l:id == 0 || l:id == -1
|
||||||
|
echoerr "Error running command"
|
||||||
|
endif
|
||||||
|
endfunction
|
118
plugin/log-autocmds.vim
Normal file
118
plugin/log-autocmds.vim
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
command! LogAutocmds call s:log_autocmds_toggle()
|
||||||
|
|
||||||
|
function! s:log_auto_cmds_toggle()
|
||||||
|
augroup LogAutocmd
|
||||||
|
autocmd!
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
let l:date = strftime('%F', localtime())
|
||||||
|
let s:activate = get(s:, 'activate', 0) ? 0 : 1
|
||||||
|
if !s:activate
|
||||||
|
call s:log('Stopped autocmd log (' . l:date . ')')
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
call s:log('Started autocmd log (' . l:date . ')')
|
||||||
|
augroup LogAutocmd
|
||||||
|
for l:au in s:aulist
|
||||||
|
silent execute 'autocmd' l:au '* call s:log(''' . l:au . ''')'
|
||||||
|
endfor
|
||||||
|
augroup END
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:log(message)
|
||||||
|
silent execute '!echo "'
|
||||||
|
\ . strftime('%T', localtime()) . ' - ' . a:message . '"'
|
||||||
|
\ '>> /tmp/vim_log_autocommands'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Deliberately left out due to side effects
|
||||||
|
" - SourceCmd
|
||||||
|
" - FileAppendCmd
|
||||||
|
" - FileWriteCmd
|
||||||
|
" - BufWriteCmd
|
||||||
|
" - FileReadCmd
|
||||||
|
" - BufReadCmd
|
||||||
|
" - FuncUndefined
|
||||||
|
|
||||||
|
let s:aulist = [
|
||||||
|
\ 'BufNewFile',
|
||||||
|
\ 'BufReadPre',
|
||||||
|
\ 'BufRead',
|
||||||
|
\ 'BufReadPost',
|
||||||
|
\ 'FileReadPre',
|
||||||
|
\ 'FileReadPost',
|
||||||
|
\ 'FilterReadPre',
|
||||||
|
\ 'FilterReadPost',
|
||||||
|
\ 'StdinReadPre',
|
||||||
|
\ 'StdinReadPost',
|
||||||
|
\ 'BufWrite',
|
||||||
|
\ 'BufWritePre',
|
||||||
|
\ 'BufWritePost',
|
||||||
|
\ 'FileWritePre',
|
||||||
|
\ 'FileWritePost',
|
||||||
|
\ 'FileAppendPre',
|
||||||
|
\ 'FileAppendPost',
|
||||||
|
\ 'FilterWritePre',
|
||||||
|
\ 'FilterWritePost',
|
||||||
|
\ 'BufAdd',
|
||||||
|
\ 'BufCreate',
|
||||||
|
\ 'BufDelete',
|
||||||
|
\ 'BufWipeout',
|
||||||
|
\ 'BufFilePre',
|
||||||
|
\ 'BufFilePost',
|
||||||
|
\ 'BufEnter',
|
||||||
|
\ 'BufLeave',
|
||||||
|
\ 'BufWinEnter',
|
||||||
|
\ 'BufWinLeave',
|
||||||
|
\ 'BufUnload',
|
||||||
|
\ 'BufHidden',
|
||||||
|
\ 'BufNew',
|
||||||
|
\ 'SwapExists',
|
||||||
|
\ 'FileType',
|
||||||
|
\ 'Syntax',
|
||||||
|
\ 'EncodingChanged',
|
||||||
|
\ 'TermChanged',
|
||||||
|
\ 'VimEnter',
|
||||||
|
\ 'GUIEnter',
|
||||||
|
\ 'GUIFailed',
|
||||||
|
\ 'TermResponse',
|
||||||
|
\ 'QuitPre',
|
||||||
|
\ 'VimLeavePre',
|
||||||
|
\ 'VimLeave',
|
||||||
|
\ 'FileChangedShell',
|
||||||
|
\ 'FileChangedShellPost',
|
||||||
|
\ 'FileChangedRO',
|
||||||
|
\ 'ShellCmdPost',
|
||||||
|
\ 'ShellFilterPost',
|
||||||
|
\ 'CmdUndefined',
|
||||||
|
\ 'SpellFileMissing',
|
||||||
|
\ 'SourcePre',
|
||||||
|
\ 'VimResized',
|
||||||
|
\ 'FocusGained',
|
||||||
|
\ 'FocusLost',
|
||||||
|
\ 'CursorHold',
|
||||||
|
\ 'CursorHoldI',
|
||||||
|
\ 'CursorMoved',
|
||||||
|
\ 'CursorMovedI',
|
||||||
|
\ 'WinEnter',
|
||||||
|
\ 'WinLeave',
|
||||||
|
\ 'TabEnter',
|
||||||
|
\ 'TabLeave',
|
||||||
|
\ 'CmdwinEnter',
|
||||||
|
\ 'CmdwinLeave',
|
||||||
|
\ 'InsertEnter',
|
||||||
|
\ 'InsertChange',
|
||||||
|
\ 'InsertLeave',
|
||||||
|
\ 'InsertCharPre',
|
||||||
|
\ 'TextChanged',
|
||||||
|
\ 'TextChangedI',
|
||||||
|
\ 'ColorScheme',
|
||||||
|
\ 'RemoteReply',
|
||||||
|
\ 'QuickFixCmdPre',
|
||||||
|
\ 'QuickFixCmdPost',
|
||||||
|
\ 'SessionLoadPost',
|
||||||
|
\ 'MenuPopup',
|
||||||
|
\ 'CompleteDone',
|
||||||
|
\ 'User',
|
||||||
|
\ ]
|
478
spell/en.utf-8.add
Normal file
478
spell/en.utf-8.add
Normal file
@ -0,0 +1,478 @@
|
|||||||
|
AED
|
||||||
|
API
|
||||||
|
Autocommands
|
||||||
|
BufRead
|
||||||
|
Builtin
|
||||||
|
Bézier
|
||||||
|
CER
|
||||||
|
CMD
|
||||||
|
CentOS
|
||||||
|
Cmder
|
||||||
|
Ctrl
|
||||||
|
DLL
|
||||||
|
DT
|
||||||
|
Deoplete
|
||||||
|
Deteval
|
||||||
|
Esc
|
||||||
|
Exif
|
||||||
|
Firefox
|
||||||
|
Foxmail
|
||||||
|
GPU
|
||||||
|
GPUs
|
||||||
|
GUIs
|
||||||
|
GhostText
|
||||||
|
GitHub
|
||||||
|
HomeBrew
|
||||||
|
ICCF
|
||||||
|
ICDAR
|
||||||
|
IDE
|
||||||
|
IoU
|
||||||
|
Iterm2
|
||||||
|
JPEG
|
||||||
|
JSON
|
||||||
|
LSP
|
||||||
|
Linters
|
||||||
|
Listary
|
||||||
|
MPI
|
||||||
|
MXNet
|
||||||
|
MacOS
|
||||||
|
Matplotlib
|
||||||
|
Neomake
|
||||||
|
Nvim
|
||||||
|
Numpy
|
||||||
|
OpenCV
|
||||||
|
PIL
|
||||||
|
PNG
|
||||||
|
POSIX
|
||||||
|
Pandoc
|
||||||
|
Plugin
|
||||||
|
Plugins
|
||||||
|
PowerShell
|
||||||
|
PyTorch
|
||||||
|
Pynvim
|
||||||
|
RCTW
|
||||||
|
Ripgrep
|
||||||
|
TOC
|
||||||
|
TensorFlow
|
||||||
|
UI
|
||||||
|
URLs
|
||||||
|
Uber
|
||||||
|
Ubuntu
|
||||||
|
UltiSnips
|
||||||
|
Ultisnips
|
||||||
|
Unindent
|
||||||
|
VOC
|
||||||
|
VimConf
|
||||||
|
WSL
|
||||||
|
X11
|
||||||
|
YouCompleteMe
|
||||||
|
Zsh
|
||||||
|
ack
|
||||||
|
ag
|
||||||
|
appimage
|
||||||
|
autocommand
|
||||||
|
autocommands
|
||||||
|
autocompletion
|
||||||
|
autoload
|
||||||
|
backend
|
||||||
|
backtick
|
||||||
|
base64
|
||||||
|
bashrc
|
||||||
|
blog
|
||||||
|
bruteforce
|
||||||
|
builtin
|
||||||
|
cmder
|
||||||
|
colorscheme
|
||||||
|
conda
|
||||||
|
config
|
||||||
|
configs
|
||||||
|
css
|
||||||
|
css_intro/!
|
||||||
|
ctags
|
||||||
|
deoplete
|
||||||
|
dict
|
||||||
|
diff
|
||||||
|
dir
|
||||||
|
docstrings
|
||||||
|
emoji
|
||||||
|
env
|
||||||
|
epub
|
||||||
|
favicon
|
||||||
|
favicons
|
||||||
|
filetype
|
||||||
|
filetypes
|
||||||
|
filetypes/!
|
||||||
|
firenvim
|
||||||
|
fontconfig
|
||||||
|
fzf
|
||||||
|
gcc
|
||||||
|
grep
|
||||||
|
gutentags
|
||||||
|
homebrew
|
||||||
|
horovod
|
||||||
|
inline
|
||||||
|
iterm2
|
||||||
|
jedi
|
||||||
|
jpg
|
||||||
|
keras
|
||||||
|
linters
|
||||||
|
linting
|
||||||
|
lookaround
|
||||||
|
lookbehind
|
||||||
|
lua
|
||||||
|
macOS
|
||||||
|
maskrcnn
|
||||||
|
mergetools
|
||||||
|
metadata
|
||||||
|
mobi
|
||||||
|
modeline
|
||||||
|
modelines
|
||||||
|
mouseless
|
||||||
|
namespace
|
||||||
|
ndarray
|
||||||
|
neovim
|
||||||
|
nerdtree
|
||||||
|
nvim
|
||||||
|
opentype
|
||||||
|
pdflatex
|
||||||
|
perl
|
||||||
|
plugin
|
||||||
|
plugins
|
||||||
|
png
|
||||||
|
popup
|
||||||
|
pylint
|
||||||
|
quickfix
|
||||||
|
refractor
|
||||||
|
regex
|
||||||
|
repo
|
||||||
|
rg
|
||||||
|
ripgrep
|
||||||
|
runtimepath
|
||||||
|
smartphone
|
||||||
|
solarized
|
||||||
|
specicial/!
|
||||||
|
statusline
|
||||||
|
statuslines
|
||||||
|
tabline
|
||||||
|
tabstops
|
||||||
|
tagbar
|
||||||
|
terminfo
|
||||||
|
tex
|
||||||
|
textline
|
||||||
|
tmux
|
||||||
|
truetype
|
||||||
|
uWSGI
|
||||||
|
ultisnips
|
||||||
|
uninstall
|
||||||
|
usepackage
|
||||||
|
uwsgi
|
||||||
|
vimrc
|
||||||
|
vimscript
|
||||||
|
vimtex
|
||||||
|
warmup
|
||||||
|
wildmenu
|
||||||
|
workflow
|
||||||
|
wsltty
|
||||||
|
zplug
|
||||||
|
zsh
|
||||||
|
zinit
|
||||||
|
pycodestyle
|
||||||
|
pep8
|
||||||
|
pyflakes
|
||||||
|
pyls
|
||||||
|
flake8
|
||||||
|
sbcl
|
||||||
|
quicklisp
|
||||||
|
REPL
|
||||||
|
vlime
|
||||||
|
Matplotlib's
|
||||||
|
MiKTeX
|
||||||
|
FontManager
|
||||||
|
ttc
|
||||||
|
xnoremap
|
||||||
|
wiki
|
||||||
|
backticks
|
||||||
|
Reddit
|
||||||
|
LeaderF
|
||||||
|
tabpage
|
||||||
|
ccls
|
||||||
|
cmake
|
||||||
|
LLVM
|
||||||
|
llvm
|
||||||
|
subsampling
|
||||||
|
refactor
|
||||||
|
colorschemes
|
||||||
|
gruvbox8
|
||||||
|
gruvbox
|
||||||
|
Gruvbox
|
||||||
|
monokai
|
||||||
|
NeoSolarized
|
||||||
|
FiraCode
|
||||||
|
libc
|
||||||
|
printf
|
||||||
|
CMake
|
||||||
|
lsp
|
||||||
|
PPTX
|
||||||
|
libreoffice
|
||||||
|
PPT
|
||||||
|
pptx
|
||||||
|
pdf
|
||||||
|
unoconv
|
||||||
|
python3
|
||||||
|
imagemagick
|
||||||
|
ghostscript
|
||||||
|
poppler
|
||||||
|
Tqdm
|
||||||
|
tqdm
|
||||||
|
cmd
|
||||||
|
ThreadPoolExecutor
|
||||||
|
Cygwin
|
||||||
|
mintty
|
||||||
|
iTerm
|
||||||
|
stdin
|
||||||
|
unicode
|
||||||
|
ClashX
|
||||||
|
Qv2ray
|
||||||
|
socks5
|
||||||
|
v2ray
|
||||||
|
V2Ray
|
||||||
|
Dockerfile
|
||||||
|
pip3
|
||||||
|
dein
|
||||||
|
pynvim
|
||||||
|
iTerm2
|
||||||
|
neoformat
|
||||||
|
documentation/!
|
||||||
|
documentation
|
||||||
|
WSGI
|
||||||
|
ncurses
|
||||||
|
powerline
|
||||||
|
repos
|
||||||
|
hugo
|
||||||
|
ZOC
|
||||||
|
stackexchange
|
||||||
|
https
|
||||||
|
username
|
||||||
|
url
|
||||||
|
dev
|
||||||
|
Miniconda
|
||||||
|
Semshi
|
||||||
|
Alacritty
|
||||||
|
vim/!
|
||||||
|
Vim/!
|
||||||
|
Vim
|
||||||
|
vim
|
||||||
|
RPC
|
||||||
|
SumatraPDF/!
|
||||||
|
api
|
||||||
|
YAML
|
||||||
|
TOML
|
||||||
|
pandoc
|
||||||
|
textwidth
|
||||||
|
bytecode
|
||||||
|
CPython
|
||||||
|
nohup
|
||||||
|
stdout
|
||||||
|
stderr
|
||||||
|
UTC
|
||||||
|
CJK
|
||||||
|
numpy
|
||||||
|
LibreOffice
|
||||||
|
rebase
|
||||||
|
rebasing
|
||||||
|
glibc
|
||||||
|
Clangd
|
||||||
|
clangd
|
||||||
|
cheatsheet
|
||||||
|
redis
|
||||||
|
Disqus
|
||||||
|
submodules
|
||||||
|
stackoverflow
|
||||||
|
hostname
|
||||||
|
strftime
|
||||||
|
shiftwidth
|
||||||
|
whitespace
|
||||||
|
treesitter
|
||||||
|
linter
|
||||||
|
MySQL
|
||||||
|
advocator
|
||||||
|
Hexo
|
||||||
|
pybind11
|
||||||
|
OSC
|
||||||
|
minpac
|
||||||
|
ctrl
|
||||||
|
IME
|
||||||
|
emacs
|
||||||
|
Elisp
|
||||||
|
conf
|
||||||
|
MELPA
|
||||||
|
smartparens
|
||||||
|
Tpope
|
||||||
|
extmarks
|
||||||
|
extmark
|
||||||
|
CTAN
|
||||||
|
MikTex/!
|
||||||
|
MikTeX
|
||||||
|
softwares/!
|
||||||
|
Zong
|
||||||
|
cjk
|
||||||
|
backupcopy
|
||||||
|
nowritebackup
|
||||||
|
nvim's
|
||||||
|
linux
|
||||||
|
zshrc
|
||||||
|
pdftoppm
|
||||||
|
pdf2image
|
||||||
|
pdffonts
|
||||||
|
myers
|
||||||
|
difftool
|
||||||
|
vimdiff
|
||||||
|
softmax
|
||||||
|
lib64
|
||||||
|
toolset
|
||||||
|
sym
|
||||||
|
ffmpeg
|
||||||
|
PyAV
|
||||||
|
mp4
|
||||||
|
vint
|
||||||
|
npm
|
||||||
|
js
|
||||||
|
sudo
|
||||||
|
ps1
|
||||||
|
tpm
|
||||||
|
hacky
|
||||||
|
PCRE
|
||||||
|
teardown
|
||||||
|
github
|
||||||
|
fastgit
|
||||||
|
EOL
|
||||||
|
PyCharm
|
||||||
|
deduplication
|
||||||
|
STL
|
||||||
|
delimitMate
|
||||||
|
lspconfig
|
||||||
|
lualine
|
||||||
|
Keymap
|
||||||
|
iCloud
|
||||||
|
keyframe
|
||||||
|
maskRCNN
|
||||||
|
vundle
|
||||||
|
ycm
|
||||||
|
ftplugin
|
||||||
|
vim9
|
||||||
|
dotfile
|
||||||
|
magit
|
||||||
|
xelatex
|
||||||
|
subarray
|
||||||
|
fvim
|
||||||
|
CUDA
|
||||||
|
cuda
|
||||||
|
cpu
|
||||||
|
jdhao
|
||||||
|
whitelisted
|
||||||
|
BST
|
||||||
|
autocmd
|
||||||
|
init
|
||||||
|
miniconda
|
||||||
|
tsinghua
|
||||||
|
pylsp
|
||||||
|
mypy
|
||||||
|
isort
|
||||||
|
ustc
|
||||||
|
PyTorch
|
||||||
|
maxcdn
|
||||||
|
torchvision
|
||||||
|
FFmpeg
|
||||||
|
pyav
|
||||||
|
wezterm
|
||||||
|
frac
|
||||||
|
argmax
|
||||||
|
NeruIPS
|
||||||
|
InfoNCE
|
||||||
|
LSTM
|
||||||
|
linkedin
|
||||||
|
hotmail
|
||||||
|
datetime
|
||||||
|
csv
|
||||||
|
iterable
|
||||||
|
dataframe
|
||||||
|
CRNN
|
||||||
|
ICPR
|
||||||
|
matplotlib
|
||||||
|
scikit
|
||||||
|
NumPy
|
||||||
|
cudnn
|
||||||
|
SGD
|
||||||
|
ImageNet
|
||||||
|
ReLU
|
||||||
|
CIFAR
|
||||||
|
ResNet
|
||||||
|
XGBoost
|
||||||
|
Shenzhen
|
||||||
|
Tanh
|
||||||
|
Kaggle
|
||||||
|
minist
|
||||||
|
src
|
||||||
|
RGBA
|
||||||
|
yapf
|
||||||
|
Vimming
|
||||||
|
overfitting
|
||||||
|
PCA
|
||||||
|
SVM
|
||||||
|
KNN
|
||||||
|
leetcode
|
||||||
|
Logitech
|
||||||
|
WTF
|
||||||
|
tensorboard
|
||||||
|
Nvidia
|
||||||
|
GPG
|
||||||
|
manpage
|
||||||
|
metatable
|
||||||
|
open3d
|
||||||
|
pyntcloud
|
||||||
|
param
|
||||||
|
reddit
|
||||||
|
viml
|
||||||
|
PostgreSQL
|
||||||
|
CNY
|
||||||
|
wechat
|
||||||
|
ziroom
|
||||||
|
Postgres
|
||||||
|
plpgsql
|
||||||
|
postgres
|
||||||
|
PySpark
|
||||||
|
winbar
|
||||||
|
cmdline
|
||||||
|
shada
|
||||||
|
async
|
||||||
|
localhost
|
||||||
|
JetBrains
|
||||||
|
localhost
|
||||||
|
MariaDB
|
||||||
|
SQLite
|
||||||
|
Pgadmin
|
||||||
|
Datagrip
|
||||||
|
mysql
|
||||||
|
cwd
|
||||||
|
pyright
|
||||||
|
stubgen
|
||||||
|
pylance
|
||||||
|
variadic
|
||||||
|
Vimium
|
||||||
|
Databricks
|
||||||
|
Jira
|
||||||
|
databricks
|
||||||
|
FastAPI
|
||||||
|
pylintrc
|
||||||
|
PYTHONPATH
|
||||||
|
Uvicorn
|
||||||
|
qpdf
|
||||||
|
Elasticsearch
|
||||||
|
kibana
|
||||||
|
submodule
|
||||||
|
unix
|
||||||
|
GCP
|
||||||
|
Kubernetes
|
||||||
|
pubsub
|
||||||
|
Luarocks
|
||||||
|
luarocks
|
171
viml_conf/options.vim
Normal file
171
viml_conf/options.vim
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
scriptencoding utf-8
|
||||||
|
|
||||||
|
" Change fillchars for folding, vertical split, end of buffer, and message
|
||||||
|
" separator
|
||||||
|
set fillchars=fold:\ ,foldsep:\ ,foldopen:,foldclose:,vert:\│,eob:\ ,msgsep:‾,diff:╱
|
||||||
|
|
||||||
|
" Time in milliseconds to wait for a mapped sequence to complete
|
||||||
|
set timeoutlen=500
|
||||||
|
|
||||||
|
" For CursorHold events
|
||||||
|
set updatetime=500
|
||||||
|
|
||||||
|
" Always use clipboard for all delete, yank, change, and put operations
|
||||||
|
if !empty(provider#clipboard#Executable())
|
||||||
|
set clipboard+=unnamedplus
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Ignore certain files and folders when globing
|
||||||
|
set wildignore+=*.o,*.obj,*.dylib,*.bin,*.dll,*.exe
|
||||||
|
set wildignore+=*/.git/*,*/.svn/*,*/__pycache__/*,*/build/**
|
||||||
|
set wildignore+=*.jpg,*.png,*.jpeg,*.bmp,*.gif,*.tiff,*.svg,*.ico
|
||||||
|
set wildignore+=*.pyc,*pkl
|
||||||
|
set wildignore+=*.DS_Store
|
||||||
|
set wildignore+=*.aux,*.bbl,*.blg,*.brf,*.fls,*.fdb_latexmk,*.synctex.gz,*.xdv
|
||||||
|
set wildignorecase " ignore file and dir name cases in cmd-completion
|
||||||
|
|
||||||
|
" Set up backup directory
|
||||||
|
let g:backupdir=expand(stdpath('data') . '/backup//')
|
||||||
|
let &backupdir=g:backupdir
|
||||||
|
|
||||||
|
" Skip backup for patterns in option wildignore
|
||||||
|
let &backupskip=&wildignore
|
||||||
|
set backup " create backup for files
|
||||||
|
set backupcopy=yes " copy the original file to backupdir and overwrite it
|
||||||
|
|
||||||
|
" Set up swap directory
|
||||||
|
let g:swapdir=expand(stdpath('data') . '/swap//')
|
||||||
|
let &directory=g:swapdir
|
||||||
|
|
||||||
|
" Set up persistent undo
|
||||||
|
set undofile
|
||||||
|
let g:undodir=expand(stdpath('data') . '/undo//')
|
||||||
|
let &undodir=g:undodir
|
||||||
|
|
||||||
|
" General tab settings
|
||||||
|
set tabstop=2 " number of visual spaces per TAB
|
||||||
|
set softtabstop=2 " number of spaces in tab when editing
|
||||||
|
set shiftwidth=2 " number of spaces to use for autoindent
|
||||||
|
set expandtab " expand tab to spaces so that tabs are spaces
|
||||||
|
|
||||||
|
" Set matching pairs of characters and highlight matching brackets
|
||||||
|
set matchpairs+=<:>,「:」,『:』,【:】,“:”,‘:’,《:》
|
||||||
|
|
||||||
|
" Show line number and relative line number
|
||||||
|
set number relativenumber
|
||||||
|
|
||||||
|
" Ignore case in general, but become case-sensitive when uppercase is present
|
||||||
|
set ignorecase smartcase
|
||||||
|
|
||||||
|
" File and script encoding settings for vim
|
||||||
|
set fileencoding=utf-8
|
||||||
|
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
|
||||||
|
|
||||||
|
" Break line at predefined characters
|
||||||
|
set linebreak
|
||||||
|
|
||||||
|
" Character to show before the lines that have been soft-wrapped
|
||||||
|
set showbreak=↪
|
||||||
|
|
||||||
|
" List all matches and complete till longest common string
|
||||||
|
set wildmode=list:longest
|
||||||
|
|
||||||
|
" Minimum lines to keep above and below cursor when scrolling
|
||||||
|
set scrolloff=3
|
||||||
|
|
||||||
|
" Use mouse to select and resize windows, etc.
|
||||||
|
set mouse=n
|
||||||
|
set mousemodel=popup " Set the behavior of mouse
|
||||||
|
set mousescroll=ver:1,hor:0
|
||||||
|
|
||||||
|
" Fileformats to use for new files
|
||||||
|
set fileformats=unix,dos
|
||||||
|
|
||||||
|
" Ask for confirmation when handling unsaved or read-only files
|
||||||
|
set confirm
|
||||||
|
|
||||||
|
" Do not use visual and errorbells
|
||||||
|
set visualbell noerrorbells
|
||||||
|
|
||||||
|
" Number of commands and search history to keep
|
||||||
|
set history=500
|
||||||
|
|
||||||
|
" Use list mode and customized listchars (show characters for whitespace)
|
||||||
|
set list listchars=tab:▸\ ,extends:❯,precedes:❮,nbsp:␣
|
||||||
|
|
||||||
|
" Auto-write the file base on some condition
|
||||||
|
set autowrite
|
||||||
|
|
||||||
|
" Show hostname and full path of file on the window title
|
||||||
|
set title
|
||||||
|
set titlestring=
|
||||||
|
set titlestring=%{utils#Get_titlestr()}
|
||||||
|
|
||||||
|
" Do not show "match xx of xx" and other messages during auto-completion
|
||||||
|
set shortmess+=c
|
||||||
|
|
||||||
|
" Do not show search match count on bottom right
|
||||||
|
set shortmess+=S
|
||||||
|
|
||||||
|
" Disable showing intro message (:intro)
|
||||||
|
set shortmess+=I
|
||||||
|
|
||||||
|
set messagesopt=hit-enter,history:500
|
||||||
|
|
||||||
|
" Completion behavior
|
||||||
|
" set completeopt+=noinsert " Auto select the first completion entry
|
||||||
|
set completeopt+=menuone " Show menu even if there is only one item
|
||||||
|
set completeopt-=preview " Disable the preview window
|
||||||
|
|
||||||
|
set pumheight=10 " Maximum number of items to show in popup menu
|
||||||
|
set pumblend=5 " pseudo transparency for completion menu
|
||||||
|
|
||||||
|
set winblend=0 " pseudo transparency for floating window
|
||||||
|
set winborder=none
|
||||||
|
|
||||||
|
" Insert mode key word completion setting
|
||||||
|
set complete+=kspell complete-=w complete-=b complete-=u complete-=t
|
||||||
|
|
||||||
|
set spelllang=en,cjk " Spell languages
|
||||||
|
set spellsuggest+=9 " Show 9 spell suggestions at most
|
||||||
|
|
||||||
|
" Align indent to next multiple value of shiftwidth
|
||||||
|
set shiftround
|
||||||
|
|
||||||
|
" Virtual edit is useful for visual block edit
|
||||||
|
set virtualedit=block
|
||||||
|
|
||||||
|
" Correctly break multi-byte characters such as CJK
|
||||||
|
set formatoptions+=mM
|
||||||
|
|
||||||
|
" Text after this column number is not highlighted
|
||||||
|
set synmaxcol=250
|
||||||
|
|
||||||
|
set nostartofline
|
||||||
|
|
||||||
|
" External program to use for grep command
|
||||||
|
if executable('rg')
|
||||||
|
set grepprg=rg\ --vimgrep\ --no-heading\ --smart-case
|
||||||
|
set grepformat=%f:%l:%c:%m
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Enable true color support
|
||||||
|
set termguicolors
|
||||||
|
|
||||||
|
" Set up cursor color and shape in various modes, ref:
|
||||||
|
" https:;//github.com/neovim/neovim/wiki/FAQ#how-to-change-cursor-color-in-the-terminal
|
||||||
|
set guicursor=n-v-c:block-Cursor/lCursor,i-ci-ve:ver25-Cursor2/lCursor2,r-cr:hor20,o:hor20
|
||||||
|
|
||||||
|
set signcolumn=yes:1
|
||||||
|
|
||||||
|
" Remove certain character from file name pattern matching
|
||||||
|
set isfname-==
|
||||||
|
set isfname-=,
|
||||||
|
|
||||||
|
" diff options
|
||||||
|
set diffopt=
|
||||||
|
set diffopt+=vertical " show diff in vertical position
|
||||||
|
set diffopt+=filler " show filler for deleted lines
|
||||||
|
set diffopt+=closeoff " turn off
|
||||||
|
|
||||||
|
set shell=/bin/ash
|
188
viml_conf/plugins.vim
Normal file
188
viml_conf/plugins.vim
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
scriptencoding utf-8
|
||||||
|
|
||||||
|
lua require('plugin_specs')
|
||||||
|
|
||||||
|
call utils#Cabbrev('pi', 'Lazy install')
|
||||||
|
call utils#Cabbrev('pud', 'Lazy update')
|
||||||
|
call utils#Cabbrev('pc', 'Lazy clean')
|
||||||
|
call utils#Cabbrev('ps', 'Lazy sync')
|
||||||
|
|
||||||
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
" configurations for vimscript plugins "
|
||||||
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
|
||||||
|
" UltiSnips settings
|
||||||
|
let g:UltiSnipsExpandTrigger='<c-j>'
|
||||||
|
let g:UltiSnipsEnableSnipMate = 0
|
||||||
|
let g:UltiSnipsJumpForwardTrigger='<c-j>'
|
||||||
|
let g:UltiSnipsJumpBackwardTrigger='<c-k>'
|
||||||
|
let g:UltiSnipsSnippetDirectories=['UltiSnips', 'my_snippets']
|
||||||
|
|
||||||
|
" vlime settings
|
||||||
|
command! -nargs=0 StartVlime call jobstart(printf('sbcl --load %s/vlime/lisp/start-vlime.lisp', g:package_home))
|
||||||
|
|
||||||
|
" vista settings
|
||||||
|
let g:vista#renderer#icons = {
|
||||||
|
\ 'member': '',
|
||||||
|
\ }
|
||||||
|
let g:vista_echo_cursor = 0
|
||||||
|
let g:vista_stay_on_open = 0
|
||||||
|
nnoremap <silent> <Space>t :<c-u>Vista!!<cr>
|
||||||
|
|
||||||
|
" vim-mundo settings
|
||||||
|
let g:mundo_verbose_graph = 0
|
||||||
|
let g:mundo_width = 80
|
||||||
|
nnoremap <silent> <Space>u :MundoToggle<CR>
|
||||||
|
|
||||||
|
" better-escape.vim settings
|
||||||
|
let g:better_escape_interval = 200
|
||||||
|
|
||||||
|
" vim-xkbswitch settings
|
||||||
|
let g:XkbSwitchEnabled = 1
|
||||||
|
|
||||||
|
" markdown-preview settings
|
||||||
|
if g:is_win || g:is_mac
|
||||||
|
let g:mkdp_auto_close = 0
|
||||||
|
nnoremap <silent> <M-m> :<c-u>MarkdownPreview<cr>
|
||||||
|
nnoremap <silent> <M-S-m> :<c-u>MarkdownPreviewStop<cr>
|
||||||
|
endif
|
||||||
|
|
||||||
|
" vim-grammarous settings
|
||||||
|
if g:is_mac
|
||||||
|
let g:grammarous#languagetool_cmd = 'languagetool'
|
||||||
|
let g:grammarous#disabled_rules = {
|
||||||
|
\ '*': ['WHITESPACE_RULE', 'EN_QUOTES', 'ARROWS', 'SENTENCE_WHITESPACE',
|
||||||
|
\ 'WORD_CONTAINS_UNDERSCORE', 'COMMA_PARENTHESIS_WHITESPACE',
|
||||||
|
\ 'EN_UNPAIRED_BRACKETS', 'UPPERCASE_SENTENCE_START',
|
||||||
|
\ 'ENGLISH_WORD_REPEAT_BEGINNING_RULE', 'DASH_RULE', 'PLUS_MINUS',
|
||||||
|
\ 'PUNCTUATION_PARAGRAPH_END', 'MULTIPLICATION_SIGN', 'PRP_CHECKOUT',
|
||||||
|
\ 'CAN_CHECKOUT', 'SOME_OF_THE', 'DOUBLE_PUNCTUATION', 'HELL',
|
||||||
|
\ 'CURRENCY', 'POSSESSIVE_APOSTROPHE', 'ENGLISH_WORD_REPEAT_RULE',
|
||||||
|
\ 'NON_STANDARD_WORD', 'AU', 'DATE_NEW_YEAR'],
|
||||||
|
\ }
|
||||||
|
|
||||||
|
augroup grammarous_map
|
||||||
|
autocmd!
|
||||||
|
autocmd FileType markdown nmap <buffer> <leader>x <Plug>(grammarous-close-info-window)
|
||||||
|
autocmd FileType markdown nmap <buffer> <c-n> <Plug>(grammarous-move-to-next-error)
|
||||||
|
autocmd FileType markdown nmap <buffer> <c-p> <Plug>(grammarous-move-to-previous-error)
|
||||||
|
augroup END
|
||||||
|
endif
|
||||||
|
|
||||||
|
" unicode.vim settings
|
||||||
|
nmap ga <Plug>(UnicodeGA)
|
||||||
|
|
||||||
|
" vim-sandwich settings
|
||||||
|
nmap s <Nop>
|
||||||
|
omap s <Nop>
|
||||||
|
|
||||||
|
" vimtex settings
|
||||||
|
if executable('latex')
|
||||||
|
function! s:write_server_name() abort
|
||||||
|
let nvim_server_file = (has('win32') ? $TEMP : '/tmp') . '/vimtexserver.txt'
|
||||||
|
call writefile([v:servername], nvim_server_file)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
augroup vimtex_common
|
||||||
|
autocmd!
|
||||||
|
autocmd FileType tex call s:write_server_name()
|
||||||
|
autocmd FileType tex nmap <buffer> <F9> <Plug>(vimtex-compile)
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
let g:vimtex_compiler_latexmk = {
|
||||||
|
\ 'build_dir' : 'build',
|
||||||
|
\ }
|
||||||
|
let g:vimtex_toc_config = {
|
||||||
|
\ 'name' : 'TOC',
|
||||||
|
\ 'layers' : ['content', 'todo', 'include'],
|
||||||
|
\ 'resize' : 1,
|
||||||
|
\ 'split_width' : 30,
|
||||||
|
\ 'todo_sorted' : 0,
|
||||||
|
\ 'show_help' : 1,
|
||||||
|
\ 'show_numbers': 1,
|
||||||
|
\ 'mode' : 2,
|
||||||
|
\ }
|
||||||
|
|
||||||
|
if g:is_win
|
||||||
|
let g:vimtex_view_general_viewer = 'SumatraPDF'
|
||||||
|
let g:vimtex_view_general_options = '-reuse-instance -forward-search @tex @line @pdf'
|
||||||
|
endif
|
||||||
|
|
||||||
|
if g:is_mac
|
||||||
|
let g:vimtex_view_general_viewer = '/Application/Skim.app/Contents/SharedSupport/displayline'
|
||||||
|
let g:vimtex_view_general_options = '-r @line @pdf @tex'
|
||||||
|
|
||||||
|
augroup vimtex_mac
|
||||||
|
autocmd!
|
||||||
|
autocmd User VimtexEventCompileSuccess call UpdateSkim()
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
function! UpdateSkim() abort
|
||||||
|
let l:out = b:vimtex.out()
|
||||||
|
let l:src_file_path = expand('%:p')
|
||||||
|
let l:cmd = [g:vimtex_view_general_viewer, '-r']
|
||||||
|
|
||||||
|
if !empty(system('pgrep Skim'))
|
||||||
|
call extend(l:cmd, ['-g'])
|
||||||
|
endif
|
||||||
|
|
||||||
|
call jobstart(l:cmd + [line('.'), l:out, l:src_file_path])
|
||||||
|
endfunction
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
" vim-matchup settings
|
||||||
|
let g:matchup_matchparen_deferred = 1
|
||||||
|
let g:matchup_matchparen_timeout = 100
|
||||||
|
let g:matchup_matchparen_insert_timeout = 30
|
||||||
|
let g:matchup_override_vimtex = 1
|
||||||
|
let g:matchup_delim_noskips = 0
|
||||||
|
let g:matchup_matchparen_offscreen = {'method': 'popup'}
|
||||||
|
|
||||||
|
" asyncrun.vim settings
|
||||||
|
let g:asyncrun_open = 6
|
||||||
|
if g:is_win
|
||||||
|
let g:asyncrun_encs = 'gbk'
|
||||||
|
endif
|
||||||
|
|
||||||
|
" firenvim settings
|
||||||
|
if exists('g:started_by_firenvim') && g:started_by_firenvim
|
||||||
|
if g:is_mac
|
||||||
|
set guifont=Iosevka\ Nerd\ Font:h18
|
||||||
|
else
|
||||||
|
set guifont=Consolas
|
||||||
|
endif
|
||||||
|
|
||||||
|
let g:firenvim_config = {
|
||||||
|
\ 'globalSettings': {
|
||||||
|
\ 'alt': 'all',
|
||||||
|
\ },
|
||||||
|
\ 'localSettings': {
|
||||||
|
\ '.*': {
|
||||||
|
\ 'cmdline': 'neovim',
|
||||||
|
\ 'priority': 0,
|
||||||
|
\ 'selector': 'textarea',
|
||||||
|
\ 'takeover': 'never',
|
||||||
|
\ },
|
||||||
|
\ },
|
||||||
|
\ }
|
||||||
|
|
||||||
|
function s:setup_firenvim() abort
|
||||||
|
set signcolumn=no
|
||||||
|
set noruler
|
||||||
|
set noshowcmd
|
||||||
|
set laststatus=0
|
||||||
|
set showtabline=0
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
augroup firenvim
|
||||||
|
autocmd!
|
||||||
|
autocmd BufEnter * call s:setup_firenvim()
|
||||||
|
autocmd BufEnter sqlzoo*.txt set filetype=sql
|
||||||
|
autocmd BufEnter github.com_*.txt set filetype=markdown
|
||||||
|
autocmd BufEnter stackoverflow.com_*.txt set filetype=markdown
|
||||||
|
augroup END
|
||||||
|
endif
|
||||||
|
|
||||||
|
" nvim-gdb settings
|
||||||
|
nnoremap <leader>dp :<c-u>GdbStartPDB python -m pdb %<cr>
|
Loading…
x
Reference in New Issue
Block a user