structure change. Colorscheme picker. etc.
This commit is contained in:
+440
-427
@@ -6,9 +6,10 @@
|
||||
-- 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
|
||||
local classic_vim_ui = vim.g.classic_vim_ui
|
||||
|
||||
-------------------------------------------------
|
||||
------------------UTILITIES----------------------
|
||||
@@ -22,30 +23,29 @@ end
|
||||
-- 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
|
||||
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
|
||||
local objects = {}
|
||||
for i = 1, select('#', ...) do
|
||||
local v = select(i, ...)
|
||||
table.insert(objects, vim.inspect(v))
|
||||
end
|
||||
|
||||
print(table.concat(objects, '\n'))
|
||||
return ...
|
||||
print(table.concat(objects, '\n'))
|
||||
return ...
|
||||
end
|
||||
|
||||
local wk = nil
|
||||
local function wk_register(opt)
|
||||
if wk == nil then
|
||||
return
|
||||
end
|
||||
wk.register(opt)
|
||||
if wk == nil then
|
||||
return
|
||||
end
|
||||
wk.register(opt)
|
||||
end
|
||||
|
||||
-------------------------------------------------
|
||||
@@ -58,494 +58,507 @@ local vim_version_minor = vim_version['minor']
|
||||
|
||||
local show_icon = false
|
||||
if HasPlug('nvim-web-devicons') then
|
||||
show_icon = true
|
||||
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
|
||||
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
|
||||
},
|
||||
})
|
||||
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",
|
||||
},
|
||||
})
|
||||
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-\>]],
|
||||
})
|
||||
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
|
||||
if not HasPlug('toggleterm.nvim') then
|
||||
return
|
||||
end
|
||||
require("toggleterm").setup({
|
||||
open_mapping = [[<c-\>]],
|
||||
})
|
||||
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()')
|
||||
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',
|
||||
'regex',
|
||||
},
|
||||
delay = 0,
|
||||
filetype_overrides = {},
|
||||
filetypes_denylist = {
|
||||
'dirvish',
|
||||
'fugitive',
|
||||
'NvimTree',
|
||||
'help',
|
||||
'vista',
|
||||
},
|
||||
filetypes_allowlist = {},
|
||||
modes_denylist = {},
|
||||
modes_allowlist = {},
|
||||
providers_regex_syntax_denylist = {},
|
||||
providers_regex_syntax_allowlist = {},
|
||||
under_cursor = true,
|
||||
large_file_cutoff = nil,
|
||||
large_file_overrides = nil,
|
||||
min_count_to_highlight = 1,
|
||||
})
|
||||
if not HasPlug('vim-illuminate') then
|
||||
return
|
||||
end
|
||||
local illuminate = require('illuminate')
|
||||
illuminate.configure({
|
||||
providers = {
|
||||
'lsp',
|
||||
'treesitter',
|
||||
'regex',
|
||||
},
|
||||
delay = 0,
|
||||
filetype_overrides = {},
|
||||
filetypes_denylist = {
|
||||
'dirvish',
|
||||
'fugitive',
|
||||
'NvimTree',
|
||||
'help',
|
||||
'vista',
|
||||
},
|
||||
filetypes_allowlist = {},
|
||||
modes_denylist = {},
|
||||
modes_allowlist = {},
|
||||
providers_regex_syntax_denylist = {},
|
||||
providers_regex_syntax_allowlist = {},
|
||||
under_cursor = true,
|
||||
large_file_cutoff = nil,
|
||||
large_file_overrides = nil,
|
||||
min_count_to_highlight = 1,
|
||||
})
|
||||
end
|
||||
|
||||
local function which_key_config()
|
||||
if not HasPlug('which-key.nvim') then
|
||||
return
|
||||
end
|
||||
wk = require("which-key")
|
||||
wk.setup()
|
||||
if not HasPlug('which-key.nvim') then
|
||||
return
|
||||
end
|
||||
wk = require("which-key")
|
||||
wk.setup()
|
||||
end
|
||||
|
||||
vim.g.hhx = ''
|
||||
local function telescope_config()
|
||||
if not HasPlug('telescope.nvim') then
|
||||
return
|
||||
end
|
||||
if HasPlug('telescope-fzf-native.nvim') then
|
||||
require('telescope').setup {
|
||||
pickers = {
|
||||
colorscheme = {
|
||||
enable_preview = true
|
||||
}
|
||||
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
|
||||
override_generic_sorter = true,
|
||||
override_file_sorter = true,
|
||||
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
require('telescope').load_extension('fzf')
|
||||
end
|
||||
},
|
||||
extensions = {
|
||||
fzf = {
|
||||
fuzzy = true, -- false will only do exact matching
|
||||
override_generic_sorter = true,
|
||||
override_file_sorter = true,
|
||||
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
|
||||
}
|
||||
}
|
||||
}
|
||||
require('telescope').load_extension('fzf')
|
||||
end
|
||||
|
||||
local builtin = require('telescope.builtin')
|
||||
local builtin = require('telescope.builtin')
|
||||
|
||||
vim.keymap.set('n', '<leader>ff', builtin.find_files, { desc = "Search files inside cwd" })
|
||||
-- need to install ripgrep
|
||||
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.keymap.set('n', '<leader>ff', builtin.find_files, { desc = "Search files inside cwd" })
|
||||
-- need to install ripgrep
|
||||
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" })
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "TelescopePreviewerLoaded",
|
||||
command = "setlocal wrap number"
|
||||
})
|
||||
end
|
||||
|
||||
local function github_theme_config()
|
||||
if not HasPlug('github-nvim-theme') then
|
||||
return
|
||||
if not HasPlug('github-nvim-theme') then
|
||||
return
|
||||
end
|
||||
-- Example config in Lua
|
||||
require("github-theme").setup({
|
||||
-- Overwrite the highlight groups
|
||||
overrides = function(c)
|
||||
return {
|
||||
NormalFloat = { link = 'Pmenu' },
|
||||
}
|
||||
end
|
||||
-- Example config in Lua
|
||||
require("github-theme").setup({
|
||||
-- Overwrite the highlight groups
|
||||
overrides = function(c)
|
||||
return {
|
||||
NormalFloat = { link = 'Pmenu' },
|
||||
}
|
||||
end
|
||||
})
|
||||
})
|
||||
end
|
||||
|
||||
local function animate_config()
|
||||
if not animation_enable then
|
||||
return
|
||||
end
|
||||
if not animation_enable then
|
||||
return
|
||||
end
|
||||
|
||||
if HasPlug('mini.animate') then
|
||||
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
|
||||
|
||||
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>',
|
||||
-- },
|
||||
-- })
|
||||
|
||||
-- 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'}}
|
||||
|
||||
-- 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
|
||||
-- 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", }
|
||||
-- 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
|
||||
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", }
|
||||
-- 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 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
|
||||
})
|
||||
if not HasPlug('nvim-transparent') then
|
||||
return
|
||||
end
|
||||
require("transparent").setup({
|
||||
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_groups = {}, -- table: groups you don't want to clear
|
||||
})
|
||||
end
|
||||
|
||||
local function lualine_config()
|
||||
if not HasPlug('lualine.nvim') then
|
||||
return
|
||||
if not HasPlug('lualine.nvim') then
|
||||
return
|
||||
end
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
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
|
||||
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#✔"
|
||||
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 disabled_filetypes_data = {}
|
||||
if vim_version_minor < 7 then
|
||||
-- globalstatus only work for nvim >= 0.7
|
||||
disabled_filetypes_data = { -- Filetypes to disable lualine for.
|
||||
statusline = {}, -- only ignores the ft for statusline.
|
||||
winbar = {}, -- only ignores the ft for winbar.
|
||||
'NvimTree',
|
||||
'vista'
|
||||
}
|
||||
end
|
||||
local function debugstats()
|
||||
local t = vim.fn.Debugstats()
|
||||
return "ft:" .. t['filetype'] .. " bt:" .. t['buftype'] .. " wid:" .. t['winid']
|
||||
end
|
||||
|
||||
local opt = {
|
||||
options = {
|
||||
icons_enabled = show_icon,
|
||||
theme = 'auto', -- lualine theme
|
||||
-- theme = 'ayu', -- lualine theme
|
||||
-- component_separators = { left = '', right = ''},
|
||||
-- section_separators = { left = '', right = ''},
|
||||
component_separators = { left = '', right = ''},
|
||||
section_separators = { left = '', right = ''},
|
||||
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
|
||||
|
||||
always_divide_middle = false,
|
||||
globalstatus = true,
|
||||
disabled_filetypes = disabled_filetypes_data,
|
||||
refresh = {statusline = 200}
|
||||
},
|
||||
sections = {
|
||||
lualine_a = { 'mode' },
|
||||
lualine_b = {},
|
||||
lualine_c = {
|
||||
{
|
||||
'buffers',
|
||||
mode = 2,
|
||||
filetype_names = {
|
||||
TelescopePrompt = 'Telescope',
|
||||
dashboard = 'Dashboard',
|
||||
packer = 'Packer',
|
||||
fzf = 'FZF',
|
||||
alpha = 'Alpha',
|
||||
NvimTree = '',
|
||||
vista = ''
|
||||
},
|
||||
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
|
||||
},
|
||||
}
|
||||
},
|
||||
-- lualine_x = {'encoding', 'fileformat', 'filetype'},
|
||||
lualine_x = { cocstatus },
|
||||
lualine_y = {'encoding'},
|
||||
lualine_z = {'location' }
|
||||
},
|
||||
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.
|
||||
statusline = {}, -- only ignores the ft for statusline.
|
||||
winbar = {}, -- only ignores the ft for winbar.
|
||||
'NvimTree',
|
||||
'vista',
|
||||
}
|
||||
end
|
||||
|
||||
require('lualine').setup(opt)
|
||||
local opt = {
|
||||
options = {
|
||||
icons_enabled = show_icon,
|
||||
theme = 'auto', -- lualine theme
|
||||
-- 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_b = {},
|
||||
lualine_c = {
|
||||
{
|
||||
'buffers',
|
||||
mode = 2,
|
||||
filetype_names = {
|
||||
TelescopePrompt = 'Telescope',
|
||||
dashboard = 'Dashboard',
|
||||
packer = 'Packer',
|
||||
fzf = 'FZF',
|
||||
alpha = 'Alpha',
|
||||
NvimTree = '',
|
||||
vista = '',
|
||||
},
|
||||
}
|
||||
},
|
||||
-- lualine_x = {'encoding', 'fileformat', 'filetype'},
|
||||
lualine_x = _section_x,
|
||||
lualine_y = _section_y,
|
||||
lualine_z = { 'location' }
|
||||
},
|
||||
}
|
||||
|
||||
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
|
||||
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 HasPlug('nvim-treesitter') then
|
||||
return
|
||||
end
|
||||
require('nvim-treesitter.configs').setup {
|
||||
-- ensure_installed = { "c", "bash", "lua" },
|
||||
sync_install = false,
|
||||
auto_install = true,
|
||||
-- ignore_install = { "javascript" },
|
||||
highlight = {
|
||||
enable = true,
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
}
|
||||
if not HasPlug('nvim-treesitter') then
|
||||
return
|
||||
end
|
||||
require('nvim-treesitter.configs').setup {
|
||||
ensure_installed = { "c", "bash", "lua", "python", "vim" },
|
||||
sync_install = false,
|
||||
auto_install = true,
|
||||
highlight = {
|
||||
enable = true,
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
local function nvim_tree_config()
|
||||
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
|
||||
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
|
||||
-- set termguicolors to enable highlight groups
|
||||
vim.opt.termguicolors = true
|
||||
|
||||
-- setup with some options
|
||||
require("nvim-tree").setup({
|
||||
sort_by = "case_sensitive",
|
||||
view = {
|
||||
width = 30,
|
||||
mappings = {
|
||||
list = {
|
||||
{ key = "C-[", action = "dir_up" },
|
||||
{ key = "C-]", action = "cd" },
|
||||
{ key = "<C-k>", action = "toggle_file_info" },
|
||||
},
|
||||
},
|
||||
-- setup with some options
|
||||
require("nvim-tree").setup({
|
||||
sort_by = "case_sensitive",
|
||||
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,
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
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,
|
||||
},
|
||||
actions = {
|
||||
open_file = {
|
||||
quit_on_open = true,
|
||||
resize_window = true,
|
||||
window_picker = {
|
||||
exclude = {
|
||||
filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" },
|
||||
buftype = { "nofile", "terminal", "help" },
|
||||
},
|
||||
},
|
||||
filters = {
|
||||
dotfiles = false,
|
||||
},
|
||||
actions = {
|
||||
open_file = {
|
||||
quit_on_open = true,
|
||||
resize_window = true,
|
||||
window_picker = {
|
||||
exclude = {
|
||||
filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" },
|
||||
buftype = { "nofile", "terminal", "help" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
vim.api.nvim_set_keymap('n', '<Leader>e', ':NvimTreeFindFileToggle<CR>', { noremap = true, silent = true })
|
||||
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()
|
||||
github_theme_config()
|
||||
indentline_config()
|
||||
which_key_config()
|
||||
animate_config()
|
||||
nvim_scrollbar_config()
|
||||
vim_illuminate_config()
|
||||
transparent_config()
|
||||
github_theme_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()
|
||||
toggleterm_config()
|
||||
nvim_treesitter_config()
|
||||
telescope_config()
|
||||
toggleterm_config()
|
||||
end
|
||||
if vim_version_minor >= 8 then
|
||||
nvim_tree_config()
|
||||
nvim_noice_config()
|
||||
nvim_tree_config()
|
||||
nvim_noice_config()
|
||||
end
|
||||
|
||||
local function late_loading()
|
||||
lualine_config()
|
||||
end
|
||||
|
||||
-- late loading
|
||||
vim.api.nvim_create_autocmd({ "VimEnter" },
|
||||
{ pattern = { "*" }, callback = late_loading, })
|
||||
{ pattern = { "*" }, callback = late_loading, })
|
||||
|
||||
Reference in New Issue
Block a user