This commit is contained in:
Nachuan Tang
2023-03-25 02:28:11 -04:00
8 changed files with 1669 additions and 1120 deletions
-1
View File
@@ -2,6 +2,5 @@
*.pyc
*._*
.vim/
autoload/
node_modules/
tags
+35 -58
View File
@@ -10,12 +10,14 @@
let after_directory = g:mydotfiles_directory . 'config/vi-plugs/coc-theme/after/'
" detect vim type(vim or nvim)
let g:vim_v = 0
if has('nvim')
let g:vim_type = 'nvim'
let g:vim_version = matchstr(execute('version'), 'NVIM v\zs[^\n]*')
else
let g:vim_type = 'vim'
let g:vim_version = matchstr(execute('version'), 'Vi IMproved \zs[^\n]*')
let g:vim_v = v:version
endif
" detect operating system (Windows/Linux/Darwin)
@@ -62,31 +64,36 @@
set hidden " Allow buffer switching without saving
set iskeyword-=. " '.' is an end of word designator
set iskeyword-=# " '#' is an end of word designator
set iskeyword+=-
" let '-' not be an end of word designator
"set iskeyword-=_ " '_' is an end of word designator
augroup FileFormat
autocmd!
autocmd FileType javascript,typescript,lua setlocal tabstop=2 shiftwidth=2 softtabstop=2
" autocmd FileType c,cpp,python,java setlocal tabstop=4 shiftwidth=4 softtabstop=4
autocmd BufNewFile,BufRead *.html.twig set filetype=html.twig
autocmd FileType haskell,puppet,ruby,yml setlocal expandtab shiftwidth=2 softtabstop=2
autocmd FileType vim execute('setlocal iskeyword='.&iskeyword.',:')
" Instead of reverting the cursor to the last position in the buffer, we
" set it to the first line when editing a git commit message
au FileType gitcommit au! BufEnter COMMIT_EDITMSG call setpos('.', [0, 1, 1, 0])
" http://vim.wikia.com/wiki/Restore_cursor_to_file_position_in_previous_editing_session
" Restore cursor to file position in previous editing session
function! ResCur()
if line("'\"") <= line("$")
silent! normal! g`"
return 1
endif
endfunction
augroup resCur
autocmd!
autocmd BufWinEnter * call ResCur()
autocmd FileType gitcommit au! BufEnter COMMIT_EDITMSG call setpos('.', [0, 1, 1, 0])
augroup END
" " http://vim.wikia.com/wiki/Restore_cursor_to_file_position_in_previous_editing_session
" " Restore cursor to file position in previous editing session
" function! ResCur()
" if line("'\"") <= line("$")
" silent! normal! g`"
" return 1
" endif
" endfunction
" augroup resCur
" autocmd!
" autocmd BufWinEnter * call ResCur()
" augroup END
" Setting up the directories {
set backup " Backups are nice ...
" set backup " Backups are nice ...
if has('persistent_undo')
set undofile " So is persistent undo ...
set undolevels=1000 " Maximum number of changes that can be undone
@@ -98,25 +105,17 @@
" Vim UI {
"
" set tabpagemax=15 " Only show 15 tabs
" set showmode " Display the current mode
" set cursorline " Highlight current line
" get rid of current line highlight, instead just highlight the number column
augroup CLClear
autocmd! ColorScheme * hi clear CursorLine
augroup END
set nocursorline " Highlight current line
set cmdheight=1 " get rid of the extra useless line at the bottom(if not working, probably a plugin is changing the value)
if has('cmdline_info')
set ruler " Show the ruler
set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%) " A ruler on steroids
set showcmd " Show partial commands in status line and
endif
" if has('cmdline_info')
" set ruler " Show the ruler
" set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%) " A ruler on steroids
" set showcmd " Show partial commands in status line and
" endif
set backspace=indent,eol,start " Backspace for dummies
set fillchars=eob:\ " it can remove '~' at the end of buffer
set number " Line numbers on
set showmatch " Show matching brackets/parenthesis
set incsearch " Find as you type search
@@ -141,8 +140,7 @@
set shiftwidth=4 " Use indents of 4 spaces
set tabstop=4 " An indentation every four columns
set softtabstop=4 " Let backspace delete indent
autocmd FileType javascript,typescript set tabstop=2 shiftwidth=2 softtabstop=2
autocmd FileType c,cpp,python,java set tabstop=4 shiftwidth=4 softtabstop=4
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
set splitright " Puts new vsplit windows to the right of the current
set splitbelow " Puts new split windows to the bottom of the current
@@ -150,32 +148,12 @@
set list " Display unprintable characters f12 - switches
" stop inserting the current comment leader after hitting 'o' or 'O' in Normal mode
au FileType java setlocal formatoptions-=o
au FileType * setlocal formatoptions-=o
set listchars=tab:•\ ,trail:•,extends:»,precedes:« " Unprintable chars mapping
"Remove all trailing whitespace by pressing <leader>ws
fun! TrimWhitespace()
let l:save = winsaveview()
keeppatterns %s/\s\+$//e
call winrestview(l:save)
endfun
nnoremap <leader>ws :call TrimWhitespace()<CR>
set nospell " Spell checking off
set matchpairs+=<:> " Match, to be used with %
"set comments=sl:/*,mb:*,elx:*/ " auto format comment blocks
autocmd BufNewFile,BufRead *.html.twig set filetype=html.twig
autocmd FileType haskell,puppet,ruby,yml setlocal expandtab shiftwidth=2 softtabstop=2
autocmd BufNewFile,BufRead *.coffee set filetype=coffee
" Workaround vim-commentary for Haskell
autocmd FileType haskell setlocal commentstring=--\ %s
" Workaround broken colour highlighting in Haskell
autocmd FileType haskell,rust setlocal nospell
" }
@@ -209,7 +187,7 @@
vnoremap . :normal .<CR>
" For when you forget to sudo.. Really Write the file.
cmap w!! w !sudo tee % >/dev/null
" cmap w!! w !sudo tee % >/dev/null
" Adjust viewports to the same size
map <Leader>= <C-w>=
@@ -326,4 +304,3 @@
source ~/.vimrc.bundles
endif
" }
+566 -497
View File
File diff suppressed because it is too large Load Diff
+402 -104
View File
@@ -1,18 +1,170 @@
local vim_version = vim.version()
local vim_version_minor = vim_version['minor']
-------------------------------------------------
-------------------OPTIONS-----------------------
-------------------------------------------------
show_icon = false
if vim.fn.HasPlug('nvim-web-devicons') then
show_icon = true
-- enable animation of command like "<C-u>" and "<C-d>", or cursor
-- jump animation. (Performence will be effected)
local animation_enable = vim.g.animation_enable
local high_performence = vim.g.high_performence
local debug_mode = vim.g.debug_mode
-- false basicly enable plugins like noice, nvim-notify etc.
local classic_vim_ui = vim.g.classic_vim_ui
-------------------------------------------------
------------------UTILITIES----------------------
-------------------------------------------------
local vim = vim
function HasPlug(name)
return vim.fn.HasPlug(name)
end
-- debug
-- print(vim.inspect(version))
--
local function vim_illuminate_config()
if not vim.fn.HasPlug('vim-illuminate') then
-- use as a wrapper function to set keymap that call a function with
-- parameters
local _wrap = function(func, ...)
local args = { ... }
return function()
func(unpack(args))
end
end
-- use to print object
function _G.put(...)
local objects = {}
for i = 1, select('#', ...) do
local v = select(i, ...)
table.insert(objects, vim.inspect(v))
end
print(table.concat(objects, '\n'))
return ...
end
local wk = nil
local function wk_register(opt)
if wk == nil then
return
end
require('illuminate').configure({
wk.register(opt)
end
-------------------------------------------------
----------------CONFIGURATION--------------------
-------------------------------------------------
local vim_version = vim.version()
local vim_version_minor = vim_version['minor']
local show_icon = false
if HasPlug('nvim-web-devicons') then
show_icon = true
end
local function nvim_noice_config()
if classic_vim_ui
or not HasPlug('noice.nvim')
or not HasPlug('nvim-notify')
or not HasPlug('nui.nvim') then
return
end
require("noice").setup({
lsp = {
-- override markdown rendering so that **cmp** and other plugins use **Treesitter**
override = {
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
["vim.lsp.util.stylize_markdown"] = true,
["cmp.entry.get_documentation"] = true,
},
},
-- you can enable a preset for easier configuration
presets = {
bottom_search = true, -- use a classic bottom cmdline for search
-- command_palette = true, -- position the cmdline and popupmenu together
long_message_to_split = true, -- long messages will be sent to a split
inc_rename = false, -- enables an input dialog for inc-rename.nvim
lsp_doc_border = false, -- add a border to hover docs and signature help
},
cmdline = {
enabled = true, -- enables the Noice cmdline UI
-- view = "cmdline", -- view for rendering the cmdline. Change to `cmdline` to get a classic cmdline at the bottom
opts = {}, -- global options for the cmdline. See section on views
format = {
-- cmdline = false,
search_down = false,
search_up = false,
-- filter = false,
-- help = false,
-- input = {}, -- Used by input()
-- lua = false, -- to disable a format, set to `false`
},
},
messages = {
-- NOTE: If you enable messages, then the cmdline is enabled automatically.
-- This is a current Neovim limitation.
enabled = true, -- enables the Noice messages UI
view = "notify", -- default view for messages
view_error = "notify", -- view for errors
view_warn = "notify", -- view for warnings
view_history = "messages", -- view for :messages
view_search = false, -- view for search count messages. Set to `false` to disable
},
})
end
local function nvim_scrollbar_config()
if classic_vim_ui or
not HasPlug('nvim-scrollbar') then
return
end
require("scrollbar").setup({
excluded_filetypes = {
"prompt",
"TelescopePrompt",
"noice",
"startify",
"vista",
},
})
end
local function toggleterm_config()
if not HasPlug('toggleterm.nvim') then
return
end
require("toggleterm").setup({
open_mapping = [[<c-\>]],
direction = 'float',
float_opts = {
border = 'rounded',
width = function(term) return math.floor(vim.o.columns * 0.5) end,
height = function(term) return math.floor(vim.o.lines * 0.5) end,
winblend = 20,
row = vim.o.lines * 0.5 - 3,
col = vim.o.columns * 0.5,
},
})
function _G.set_terminal_keymaps()
local opts = { buffer = 0 }
vim.keymap.set('t', '<esc>', [[<C-\><C-n>]], opts)
vim.keymap.set('t', 'jk', [[<C-\><C-n>]], opts)
vim.keymap.set('t', '<C-h>', [[<Cmd>wincmd h<CR>]], opts)
vim.keymap.set('t', '<C-j>', [[<Cmd>wincmd j<CR>]], opts)
vim.keymap.set('t', '<C-k>', [[<Cmd>wincmd k<CR>]], opts)
vim.keymap.set('t', '<C-l>', [[<Cmd>wincmd l<CR>]], opts)
vim.keymap.set('t', '<C-w>', [[<C-\><C-n><C-w>]], opts)
end
vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()')
end
local function vim_illuminate_config()
if not HasPlug('vim-illuminate') then
return
end
local illuminate = require('illuminate')
illuminate.configure({
providers = {
'lsp',
'treesitter',
@@ -39,12 +191,42 @@ local function vim_illuminate_config()
})
end
local function telescope_config()
if not vim.fn.HasPlug('telescope.nvim') then
local function which_key_config()
if not HasPlug('which-key.nvim') then
return
end
if vim.fn.HasPlug('telescope-fzf-native.nvim') then
wk = require("which-key")
wk.setup({
triggers_blacklist = {
i = { "j", "k" },
v = { "j", "k" },
c = { "w" },
},
})
end
vim.g.hhx = ''
local function telescope_config()
if not HasPlug('telescope.nvim') then
return
end
local actions = require("telescope.actions")
local action_state = require "telescope.actions.state"
if HasPlug('telescope-fzf-native.nvim') then
require('telescope').setup {
pickers = {
colorscheme = {
enable_preview = true,
mappings = {
i = {
["<CR>"] = function(bufnr)
local selection = action_state.get_selected_entry()
actions.select_default()
vim.fn.Theme_persistent(selection.value)
end,
},
},
}
},
extensions = {
fzf = {
fuzzy = true, -- false will only do exact matching
@@ -59,22 +241,21 @@ local function telescope_config()
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader><leader>f', builtin.find_files, {})
vim.keymap.set('n', '<leader>ff', builtin.find_files, { desc = "Search files inside cwd" })
-- need to install ripgrep
vim.keymap.set('n', '<leader><leader>r', builtin.live_grep, {})
-- vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
-- vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})
vim.api.nvim_create_autocmd(
"User",
{
vim.keymap.set('n', '<leader>fr', builtin.live_grep, { desc = "Regex search inside files" })
vim.keymap.set('n', '<leader>fb', builtin.buffers, { desc = "Search buffers" })
vim.keymap.set('n', '<leader>fc', builtin.colorscheme, { desc = "Search colorscheme" })
wk_register({ ["<leader>f"] = { name = "+Telescope" } })
vim.api.nvim_create_autocmd("User", {
pattern = "TelescopePreviewerLoaded",
command = "setlocal wrap number"
}
)
})
end
local function github_theme_config()
if not vim.fn.HasPlug('github-nvim-theme') then
if not HasPlug('github-nvim-theme') then
return
end
-- Example config in Lua
@@ -88,84 +269,179 @@ local function github_theme_config()
})
end
local function color_picker_nvim_config()
-- config for ziontee113/color-picker.nvim
require("color-picker").setup({
["keymap"] = { -- mapping example:
["U"] = "<Plug>ColorPickerSlider5Decrease",
["O"] = "<Plug>ColorPickerSlider5Increase",
},
})
local opts = { noremap = true, silent = true }
vim.keymap.set("n", "cp", "<cmd>PickColor<cr>", opts)
-- vim.keymap.set("i", "<C-u>c", "<cmd>PickColorInsert<cr>", opts)
end
local function indent_blankline_config()
if not vim.fn.HasPlug('indent-blankline.nvim') then
local function animate_config()
if not animation_enable then
return
end
if HasPlug('mini.animate') then
local animate = require('mini.animate')
animate.setup({
cursor = {
-- Whether to enable this animation
enable = true,
-- Timing of animation (how steps will progress in time)
-- timing = --<function: implements linear total 250ms animation duration>,
},
scroll = {
-- Whether to enable this animation
enable = true,
-- Timing of animation (how steps will progress in time)
timing = animate.gen_timing.linear({ duration = 150, unit = 'total' }),
},
open = {
-- Whether to enable this animation
enable = false,
},
})
vim.api.nvim_create_autocmd("FileType", {
pattern = { "help", "alpha", "dashboard", "neo-tree", "Trouble", "lazy", "mason",
"NvimTree", "vista", "toggleterm", "noice" },
callback = function()
vim.b.minianimate_disable = true
end,
})
end
-- if HasPlug('neoscroll.nvim') then
-- require('neoscroll').setup({
-- -- Set any options as needed
-- mappings = {'<C-u>', '<C-d>', '<C-b>', '<C-f>',
-- },
-- })
-- local t = {}
-- -- Syntax: t[keys] = {function, {function arguments}}
-- t['<C-u>'] = {'scroll', {'-vim.wo.scroll', 'true', '150'}}
-- t['<C-d>'] = {'scroll', { 'vim.wo.scroll', 'true', '150'}}
-- t['<C-b>'] = {'scroll', {'-vim.api.nvim_win_get_height(0)', 'true', '200'}}
-- t['<C-f>'] = {'scroll', { 'vim.api.nvim_win_get_height(0)', 'true', '200'}}
-- -- t['zb'] = {'zb', {'250'}}
-- require('neoscroll.config').set_mappings(t)
-- end
end
local function indentline_config()
if not animation_enable then
if HasPlug('indent-blankline.nvim') then
-- Example config in Lua
require("indent_blankline").setup {
show_current_context = true,
filetype_exclude = { "lspinfo", "packer", "checkhealth", "help", "man", "", "startify",}
filetype_exclude = { "lspinfo", "packer", "checkhealth",
"help", "man", "", "startify", }
-- use_treesitter = true,
}
end
else
if HasPlug('mini.indentscope') then
MiniIndentscope = require('mini.indentscope')
MiniIndentscope.setup({
symbol = '│',
-- draw = {
-- animation = MiniIndentscope.gen_animation.linear({
-- easing = 'out',
-- duration = 150,
-- unit = 'total'
-- })
-- },
})
vim.api.nvim_create_autocmd("FileType", {
pattern = { "help", "alpha", "dashboard", "neo-tree", "Trouble", "lazy", "mason",
"NvimTree", "vista", "startify", "toggleterm" },
callback = function()
vim.b.miniindentscope_disable = true
end,
})
end
end
end
local function transparent_config()
if not vim.fn.HasPlug('nvim-transparent') then
if not HasPlug('nvim-transparent') then
return
end
require("transparent").setup({
enable = true, -- boolean: enable transparent
extra_groups = { -- table/string: additional groups that should be cleared
-- In particular, when you set it to 'all', that means all available groups
"NvimTreeNormal",
"VertSplit",
},
exclude = {}, -- table: groups you don't want to clear
exclude_groups = {}, -- table: groups you don't want to clear
})
end
local function lualine_config()
if not vim.fn.HasPlug('lualine.nvim') then
if not HasPlug('lualine.nvim') then
return
end
for i=1,9 do
vim.api.nvim_set_keymap('n', '<Leader>'..i, ':LualineBuffersJump '..i..'<CR>', { noremap = true, silent = true, nowait = true })
-- :nnoremap <silent> <Leader>1 :LualineBuffersJump 1<CR>
vim.api.nvim_set_hl(0, 'CocstatusSucceed', { fg = "#e32be0" })
vim.api.nvim_set_hl(0, 'CocstatusLoading', { fg = "#35f0e9" })
-- custom lualine plugin show coc lsp status
local function cocstatus()
local loading = { "⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏" }
local step = #loading
local ok, result = pcall(vim.fn.CocAction, 'services')
if not ok then
return
end
for i=10,20 do
vim.api.nvim_set_keymap('n', '<Space>'..i, ':LualineBuffersJump '..i..'<CR>', { noremap = true, silent = true, nowait = true })
-- :nnoremap <silent> <Leader>1 :LualineBuffersJump 1<CR>
local ft = vim.bo.filetype
local state, id
for _, entry in ipairs(result) do
if entry['languageIds'][1] == ft then
state = entry['state']
id = entry['id']
break
end
end
local speed = 1600
local loadidx = (vim.loop.now() % speed)
local msg = "lsp:" .. id
if state == "starting" then
return msg .. " %#CocstatusLoading#" .. loading[math.floor(loadidx / (step * (speed / 100))) + 1]
end
return msg .. " %#CocstatusSucceed#✔"
end
local function debugstats()
local t = vim.fn.Debugstats()
return "ft:" .. t['filetype'] .. " bt:" .. t['buftype'] .. " wid:" .. t['winid']
end
local _section_x = {}
local _section_y = { 'encoding' }
if HasPlug('coc.nvim') then table.insert(_section_x, cocstatus) end
if debug_mode then _section_y = { debugstats } end
local disabled_filetypes_data = {}
if vim_version_minor < 7 then
-- globalstatus only work for nvim >= 0.7
disabled_filetypes_data = { -- Filetypes to disable lualine for.
disabled_filetypes_data = {
-- Filetypes to disable lualine for.
statusline = {}, -- only ignores the ft for statusline.
winbar = {}, -- only ignores the ft for winbar.
'NvimTree',
'vista'
'vista',
}
end
require('lualine').setup {
local opt = {
options = {
icons_enabled = show_icon,
theme = 'auto', -- lualine theme
-- theme = 'ayu', -- lualine theme
always_divide_middle = false, -- When set to true, left sections i.e. 'a','b' and 'c'
-- can't take over the entire statusline even
-- if neither of 'x', 'y' or 'z' are present.
-- component_separators = { left = '', right = ''},
-- section_separators = { left = '', right = ''},
component_separators = { left = '', right = '' },
section_separators = { left = '', right = '' },
always_divide_middle = false,
globalstatus = true,
disabled_filetypes = disabled_filetypes_data,
refresh = { statusline = 200 }
},
sections = {
lualine_a = {'mode'},
lualine_a = { 'mode' },
lualine_b = {},
lualine_c = {
{
@@ -177,35 +453,40 @@ local function lualine_config()
packer = 'Packer',
fzf = 'FZF',
alpha = 'Alpha',
NvimTree = ''
},
max_length = vim.o.columns - 27, -- Maximum width of buffers component,
-- it can also be a function that returns
-- the value of `max_length` dynamically.
symbols = {
modified = ' ●', -- Text to show when the buffer is modified
alternate_file = '', -- Text to show to identify the alternate file
directory = '', -- Text to show when the buffer is a directory
NvimTree = '',
vista = '',
},
}
},
-- lualine_x = {'encoding', 'fileformat', 'filetype'},
lualine_x = {},
lualine_y = {},
lualine_z = {'encoding', 'location'}
lualine_x = _section_x,
lualine_y = _section_y,
lualine_z = { 'location' }
},
}
require('lualine').setup(opt)
for i = 1, 9 do
-- :nnoremap <silent> <Leader>1 :LualineBuffersJump 1<CR>
vim.api.nvim_set_keymap('n', '<Leader>' .. i, ':LualineBuffersJump ' .. i .. '<CR>',
{ noremap = true, silent = true, nowait = true })
end
for i = 10, 20 do
-- :nnoremap <silent> <Leader>1 :LualineBuffersJump 1<CR>
vim.api.nvim_set_keymap('n', '<Space>' .. i, ':LualineBuffersJump ' .. i .. '<CR>',
{ noremap = true, silent = true, nowait = true })
end
end
local function nvim_treesitter_config()
if not vim.fn.HasPlug('nvim-treesitter') then
if not HasPlug('nvim-treesitter') then
return
end
require('nvim-treesitter.configs').setup {
-- ensure_installed = { "c", "bash", "lua" },
ensure_installed = { "c", "bash", "lua", "python", "vim" },
sync_install = false,
auto_install = true,
-- ignore_install = { "javascript" },
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
@@ -214,51 +495,60 @@ local function nvim_treesitter_config()
end
local function nvim_tree_config()
if not vim.fn.HasPlug('nvim-tree.lua') then
if not HasPlug('nvim-tree.lua') then
return
end
-- disable netrw at the very start of your init.lua (strongly advised)
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
-- set termguicolors to enable highlight groups
vim.opt.termguicolors = true
local api = require('nvim-tree.api')
local M = {}
-- setup with some options
function M.print_node_path()
local node = api.tree.get_node_under_cursor()
print(node.absolute_path)
end
function M.on_attach(bufnr)
local function opts(desc)
return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
end
-- vim.keymap.set('n', 'u', api.node.navigate.parent, opts('Parent Directory'))
vim.keymap.set('n', 'u', api.tree.change_root_to_parent, opts('Up'))
vim.keymap.set('n', 'a', api.fs.create, opts('Create'))
vim.keymap.set('n', 'dd', api.fs.remove, opts('Delete'))
vim.keymap.set('n', 'rn', api.fs.rename_basename, opts('Rename: Basename'))
vim.keymap.set('n', 'I', api.tree.toggle_gitignore_filter, opts('Toggle Git Ignore'))
vim.keymap.set('n', 'cd', api.tree.change_root_to_node, opts('CD'))
vim.keymap.set('n', 'X', api.tree.collapse_all, opts('Collapse'))
vim.keymap.set('n', 'O', api.tree.expand_all, opts('Expand All'))
vim.keymap.set('n', 'p', M.print_node_path, opts('Print node path'))
vim.keymap.set('n', 'o', api.node.open.edit, opts('Open'))
vim.keymap.set('n', '<CR>', api.node.open.edit, opts('Open'))
end
vim.api.nvim_set_keymap('n', '<Leader>e', ':NvimTreeFindFileToggle<CR>',
{ desc = 'Toggle nvim-tree', noremap = true, silent = true, nowait = true })
require("nvim-tree").setup({
sort_by = "case_sensitive",
on_attach = M.on_attach,
view = {
width = 30,
mappings = {
list = {
{ key = "C-[", action = "dir_up" },
{ key = "C-]", action = "cd" },
{ key = "<C-k>", action = "toggle_file_info" },
},
},
},
renderer = {
group_empty = true,
icons = {
show = {
file = show_icon,
folder = show_icon,
folder_arrow = show_icon,
git = show_icon,
modified = show_icon,
}
}
},
filters = {
dotfiles = false,
},
git = {
ignore = false,
},
actions = {
open_file = {
quit_on_open = true,
resize_window = true,
window_picker = {
exclude = {
filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" },
filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame", "vista" },
buftype = { "nofile", "terminal", "help" },
},
},
@@ -266,23 +556,31 @@ local function nvim_tree_config()
},
})
vim.api.nvim_set_keymap('n', '<Leader>e', ':NvimTreeFindFileToggle<CR>', { noremap = true, silent = true })
end
if vim_version_minor >= 5 then
vim_illuminate_config()
transparent_config()
lualine_config()
github_theme_config()
indent_blankline_config()
indentline_config()
which_key_config()
animate_config()
nvim_scrollbar_config()
lualine_config()
end
if vim_version_minor >= 7 then
nvim_treesitter_config()
telescope_config()
-- color_picker_nvim_config()
-- lsp_zero_config()
toggleterm_config()
end
if vim_version_minor >= 8 then
nvim_tree_config()
nvim_noice_config()
end
local function late_loading()
end
-- late loading
vim.api.nvim_create_autocmd({ "VimEnter" },
{ pattern = { "*" }, callback = late_loading, })
+9 -1
View File
@@ -1,6 +1,6 @@
" let g:coc_global_extensions = ['coc-pyright', 'coc-rls', 'coc-clangd', 'coc-tsserver', 'coc-html', 'coc-cmake', 'coc-json', 'coc-sh', 'coc-java']
let g:coc_global_extensions = ['coc-pyright', 'coc-tsserver']
" let g:coc_global_extensions = ['coc-pyright', 'coc-tsserver']
let g:coc_data_home = g:vim_dir . '/coc'
let g:coc_config_home = g:vim_dir . '/coc'
@@ -92,3 +92,11 @@ call coc#config("java.jdt.ls.vmargs", '-javaagent:' . g:mydotfiles_directory . '
call coc#config("java.jdt.ls.lombokSupport.enabled", v:false)
call coc#config("java.inlayHints.parameterNames.enabled", v:false)
call coc#config("inlayHint.enable", v:false)
for section in ['suggest', 'diagnostic', 'signature', 'hover']
call coc#config(section.'.floatConfig.border', v:true)
call coc#config(section.'.floatConfig.rounded', v:true)
call coc#config(section.'.floatConfig.highlight', 'Normal')
" transparent setting (only for neovim)
call coc#config(section.'.floatConfig.winblend', 6)
endfor
+1 -1
View File
@@ -1,4 +1,4 @@
#! /usr/bin/env python
#! /usr/bin/env python3
""" Convert values between RGB hex codes and xterm-256 color codes.
-69
View File
@@ -1,69 +0,0 @@
function! GetHi(group, term)
" Store output of group to variable
let output = execute('hi ' . a:group)
" Find the term we're looking for
return matchstr(output, a:term.'=\zs\S*')
endfunction
function! StrIsNr(input)
if a:input =~# '^\d\+$'
return v:true
endif
return v:false
endfunction
" Pick an appropriate 256 color base on old color
function! SuitableColor(oldColor)
return a:oldColor - 40
endfunction
function! ThemeFix()
let newValue = -1
let hiGroups = ['CocErrorFloat', 'CocFloating', 'NormalFloat']
if has('nvim')
for group in hiGroups
if hlexists(group)
let oldColor = GetHi(group, 'ctermbg')
if StrIsNr(oldColor)
let newValue = SuitableColor(str2nr(oldColor))
" execute('hi ' . group . ' ctermbg=' . newValue)
execute('autocmd! ColorScheme * hi ' . group . ' ctermbg=' . newValue)
endif
endif
endfor
end
endfunction
function! GetRidOfBg()
let hiGroups = ['CocErrorSign', 'CocWarningSign', 'CocHintSign']
for group in hiGroups
if hlexists(group)
execute('hi ' . group . ' ctermbg=none')
endif
endfor
endfunction
function! CocThemeFix()
hi CocErrorHighlight cterm=underline ctermfg=124 ctermbg=none " Keyword at the error position highlight
hi CocErrorSign ctermbg=none ctermfg=124 " Error Sign at the sign column highlight
hi CocWarningSign ctermbg=none ctermfg=214 " Warning Sign at the sign column highlight
hi CocHintSign ctermbg=none ctermfg=214 " Hint Sign at the sign column highlight
hi CocUnusedHighlight cterm=underline ctermfg=214 ctermbg=none " Unused variable/function etc. highlight
hi CocWarningHighlight cterm=underline ctermfg=214 ctermbg=none " Warning variable/function etc. highlight
hi CocInfoHighlight ctermfg=207 ctermbg=none " Info variable/function etc. highlight
hi CocInfoSign ctermbg=none ctermfg=207 " Info Sign at the sign column highlight
hi Todo ctermbg=none ctermfg=214 " Info Sign at the sign column highlight
hi Error cterm=underline ctermfg=124 ctermbg=none
hi javaError cterm=underline ctermfg=124 ctermbg=none
highlight CursorLineNr ctermbg=none
highlight SignColumn ctermbg=none
endfunction
call CocThemeFix()
au! ColorScheme * call CocThemeFix()
+267
View File
@@ -0,0 +1,267 @@
" This file stores helper functions
function! Notify(msg)
echo msg
endfunction
" Check if plugin exists
function! HasPlug(plug_name, ...)
let plug_dir_name = get(a:, 1, a:plug_name) " optional argument for the name of plug's folder
if has_key(g:plugs, a:plug_name) && isdirectory(g:plugin_dir . "/" . plug_dir_name)
if has_key(g:plugs[a:plug_name], 'for') || has_key(g:plugs[a:plug_name], 'on')
if (has_key(g:plugs[a:plug_name], 'for') && len(g:plugs[a:plug_name]['for']) == 0) ||
\ (has_key(g:plugs[a:plug_name], 'on') && len(g:plugs[a:plug_name]['on']) == 0)
return v:false
endif
endif
return v:true
endif
return v:false
endfunction
" This function is used to save a variable to a file
function! SaveVariable(var, file)
let serialized = string(a:var)
call writefile([serialized], a:file)
endfun
" This function is used to retrieve a variable from a file
" only first line is count
function! ReadVariable(file)
if !filereadable(a:file)
return v:null
endif
let serialized = readfile(a:file)
if(len(serialized) == 0)
return v:null
endif
execute "let result = " . serialized[0]
return result
endfun
" Merge two dictionaries, also recursively merging nested keys.
" Use extend() if you don't need to merge nested keys.
fun! Merge(defaults, override)
let l:new = copy(a:defaults)
for [l:k, l:v] in items(a:override)
let l:new[l:k] = (type(l:v) is v:t_dict && type(get(l:new, l:k)) is v:t_dict)
\ ? Merge(l:new[l:k], l:v)
\ : l:v
endfor
return l:new
endfun
function! Sh(pattern)
execute("filter /" . a:pattern . "/ highlight")
endfunc
" get current colorscheme name
function! ColourSchemeName()
try
return g:colors_name
catch /^Vim:E121/
return "default"
catch /.*/
return "default"
endtry
endfunction
" debug function print out highlight group of cursor position
function! ShowHighLightGroup()
if !exists("*synstack")
return
endif
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
:echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"
endfunc
" get highlight group information and return as dictionary
function! GetHighlight(group)
let output = execute('hi ' . a:group)
let list = split(output, '\s\+')
let dict = {}
for item in list
if match(item, '=') > 0
let splited = split(item, '=')
let dict[splited[0]] = splited[1]
endif
endfor
return dict
endfunction
function! InTransparentMode()
let dict = GetHighlight('Normal')
let isGui = &termguicolors
if isGui
if !has_key(dict, 'guibg')
return 1
endif
elseif !isGui
if !has_key(dict, 'ctermfg')
return 1
endif
endif
return 0
endfunction
function! HasColorscheme(name)
let scheme = a:name
let colors = globpath(&runtimepath, printf('colors/%s.vim', scheme), 1, 1)
if len(colors) > 0 | return 1 | endif
let colors += globpath(&packpath, printf('pack/*/start/*/colors/%s.vim', scheme), 1, 1)
if len(colors) > 0 | return 1 | endif
let colors += globpath(&packpath, printf('pack/*/opt/*/colors/%s.vim', scheme), 1, 1)
if len(colors) > 0 | return 1 | endif
if has('nvim')
let colors = globpath(&runtimepath, printf('colors/%s.lua', scheme), 1, 1)
if len(colors) > 0 | return 1 | endif
let colors += globpath(&packpath, printf('pack/*/start/*/colors/%s.lua', scheme), 1, 1)
if len(colors) > 0 | return 1 | endif
let colors += globpath(&packpath, printf('pack/*/opt/*/colors/%s.lua', scheme), 1, 1)
if len(colors) > 0 | return 1 | endif
endif
return 0
endfunction
" delete signal file if exist
function! DeleteSignalFile(name)
if filereadable(g:vim_dir . a:name)
call delete(g:vim_dir . a:name)
endif
endfunction
" Create signal file if not exist
function! CreateSignalFile(name)
call system("touch " . g:vim_dir . a:name)
endfunction
function! SignalFileExists(filename)
if filereadable(g:vim_dir . a:filename)
return v:true
endif
return v:false
endfunction
" Debug related
if g:debug_mode
let g:debug_logs = []
function! Debugstats()
let d = {}
let d['filetype'] = &ft
let d['buftype'] = &buftype
let d['winid'] = win_getid()
return d
endfunction
endif
" Swap values under cursor according to g:swap_dict
" {
function SwapWord()
let word = expand("<cword>")
let l1 = g:swap_dict[0]
let l2 = g:swap_dict[1]
let inx = index(l1, word)
if inx != -1
let newword = l2[inx]
else
let inx = index(l2, word)
if inx != -1
let newword = l1[inx]
endif
endif
if inx != -1
execute "normal ciw" . newword . "\<Esc>"
endif
endfunction
" }
function! GenVimAsciiArt(buffer_str_len)
let buf_str = repeat(' ', a:buffer_str_len)
if has('nvim')
let ascii_art = [
\ buf_str . ' __ __ ________ ______ __ __ ______ __ __ ',
\ buf_str . '| \ | \| \ / \ | \ | \| \| \ / \',
\ buf_str . '| $$\ | $$| $$$$$$$$| $$$$$$\| $$ | $$ \$$$$$$| $$\ / $$',
\ buf_str . '| $$$\| $$| $$__ | $$ | $$| $$ | $$ | $$ | $$$\ / $$$',
\ buf_str . '| $$$$\ $$| $$ \ | $$ | $$ \$$\ / $$ | $$ | $$$$\ $$$$',
\ buf_str . '| $$\$$ $$| $$$$$ | $$ | $$ \$$\ $$ | $$ | $$\$$ $$ $$',
\ buf_str . '| $$ \$$$$| $$_____ | $$__/ $$ \$$ $$ _| $$_ | $$ \$$$| $$',
\ buf_str . '| $$ \$$$| $$ \ \$$ $$ \$$$ | $$ \| $$ \$ | $$',
\ buf_str . ' \$$ \$$ \$$$$$$$$ \$$$$$$ \$ \$$$$$$ \$$ \$$',
\]
else
let ascii_art = [
\ buf_str . ' __ __ ______ __ __ ',
\ buf_str . '| \ | \| \| \ / \',
\ buf_str . '| $$ | $$ \$$$$$$| $$\ / $$',
\ buf_str . '| $$ | $$ | $$ | $$$\ / $$$',
\ buf_str . ' \$$\ / $$ | $$ | $$$$\ $$$$',
\ buf_str . ' \$$\ $$ | $$ | $$\$$ $$ $$',
\ buf_str . ' \$$ $$ _| $$_ | $$ \$$$| $$',
\ buf_str . ' \$$$ | $$ \| $$ \$ | $$',
\ buf_str . ' \$ \$$$$$$ \$$ \$$',
\]
endif
return ascii_art
endfunction
"Remove all trailing whitespace by pressing <leader>ws
fun! TrimWhitespace()
let l:save = winsaveview()
keeppatterns %s/\s\+$//e
call winrestview(l:save)
endfun
""" AIRLINE EXTENSIONS """
if HasPlug('vim-airline')
function! AirlineCocStatus()
if ! exists('*CocAction')
return
endif
" let loading = ["⢿", "⣻", "⣽", "⣾", "⣷", "⣯", "⣟", "⡿"]
let loading = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]
try
let result = CocAction('services')
catch
return
endtry
let state = ''
let id = ''
for e in result
if e['languageIds'][0] == &ft
let state = e['state']
let id = e['id']
endif
endfor
" messy way to get time in millisecond in vim
let time = float2nr(str2float(reltime()->reltimestr()[4:]) * 1000)
let speed = 800
let loadidx = time % speed
let msg = 'lsp:' . id
if state == "starting"
let s:coc_lsp_loading = 1
return msg . " " . loading[loadidx/(speed/10)] . " "
endif
if exists('s:coc_lsp_loading')
unlet s:coc_lsp_loading
endif
return msg . " ✔ "
endfunction
function! AirlineBufferNumber()
return len(g:index_to_buffer)
endfunction
endif
""" AIRLINE EXTENSIONS END """