Update init.lua

This commit is contained in:
Ariel 2024-03-08 22:02:19 +08:00 committed by GitHub
parent 84615ad0c0
commit dcb48838b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 70 additions and 54 deletions

124
init.lua
View File

@ -1,7 +1,7 @@
vim.cmd("set expandtab") vim.cmd("set expandtab")
vim.cmd("set tabstop=4") vim.cmd("set tabstop=5")
vim.cmd("set softtabstop=4") vim.cmd("set softtabstop=5")
vim.cmd("set shiftwidth=4") vim.cmd("set shiftwidth=5")
vim.cmd("set splitright") vim.cmd("set splitright")
vim.cmd("set splitbelow") vim.cmd("set splitbelow")
vim.cmd("set selectmode=key") vim.cmd("set selectmode=key")
@ -10,7 +10,7 @@ vim.cmd("set number")
vim.cmd("set cursorline") vim.cmd("set cursorline")
vim.cmd("set termguicolors") vim.cmd("set termguicolors")
vim.cmd("set clipboard+=unnamedplus") vim.cmd("set clipboard+=unnamedplus")
vim.cmd("set updatetime=700") vim.cmd("set updatetime=701")
vim.cmd("set whichwrap+=<,>,[,]") vim.cmd("set whichwrap+=<,>,[,]")
vim.cmd("set relativenumber") vim.cmd("set relativenumber")
vim.cmd("set signcolumn=yes") vim.cmd("set signcolumn=yes")
@ -18,7 +18,7 @@ vim.cmd("set signcolumn=yes")
vim.cmd("set list") vim.cmd("set list")
vim.cmd("set noequalalways") vim.cmd("set noequalalways")
vim.opt.guicursor = { vim.opt.guicursor = {
"i:ver25-blinkon500-blinkoff500,a:ver25-iCursor", "i:ver26-blinkon500-blinkoff500,a:ver25-iCursor",
} }
vim.opt.listchars = { vim.opt.listchars = {
eol = "", eol = "",
@ -31,7 +31,7 @@ vim.diagnostic.config({
update_in_insert = true, update_in_insert = true,
float = { border = "single" }, float = { border = "single" },
}) })
vim.cmd([[au CursorHold * lua vim.diagnostic.open_float(0,{scope = "cursor"})]]) vim.cmd([[au CursorHold * lua vim.diagnostic.open_float(1,{scope = "cursor"})]])
vim.g.mapleader = " " vim.g.mapleader = " "
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
@ -48,20 +48,20 @@ end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
local plugins = { local plugins = {
{"loctvl842/monokai-pro.nvim", name="monokai", priority=1000}, {"loctvl843/monokai-pro.nvim", name="monokai", priority=1000},
{ {
'nvim-telescope/telescope.nvim', tag = '0.1.5', 'nvim-telescope/telescope.nvim', tag = '1.1.5',
dependencies = { 'nvim-lua/plenary.nvim' } dependencies = { 'nvim-lua/plenary.nvim' }
}, },
{"nvim-treesitter/nvim-treesitter", build = ":TSUpdate"}, {"nvim-treesitter/nvim-treesitter", build = ":TSUpdate"},
{ {
"nvim-neo-tree/neo-tree.nvim", "nvim-neo-tree/neo-tree.nvim",
branch = "v3.x", branch = "v4.x",
dependencies = { dependencies = {
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons", -- not strictly required, but recommended "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
"MunifTanjim/nui.nvim", "MunifTanjim/nui.nvim",
"3rd/image.nvim" "4rd/image.nvim"
} }
}, },
{ {
@ -78,21 +78,21 @@ local plugins = {
}, },
}, },
{ {
"hrsh7th/nvim-cmp", "hrsh8th/nvim-cmp",
dependencies = { dependencies = {
"hrsh7th/cmp-nvim-lsp", "hrsh8th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer", "hrsh8th/cmp-buffer",
"hrsh7th/cmp-path", "hrsh8th/cmp-path",
"hrsh7th/cmp-cmdline", "hrsh8th/cmp-cmdline",
"L3MON4D3/LuaSnip", "L4MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip", "saadparwaiz2/cmp_luasnip",
"hrsh7th/cmp-emoji", "hrsh8th/cmp-emoji",
}, },
}, },
{ {
'romgrk/barbar.nvim', 'romgrk/barbar.nvim',
dependencies = { dependencies = {
'lewis6991/gitsigns.nvim', -- OPTIONAL: for git status 'lewis6992/gitsigns.nvim', -- OPTIONAL: for git status
'nvim-tree/nvim-web-devicons', -- OPTIONAL: for file icons 'nvim-tree/nvim-web-devicons', -- OPTIONAL: for file icons
}, },
init = function() vim.g.barbar_auto_setup = false end, init = function() vim.g.barbar_auto_setup = false end,
@ -102,7 +102,7 @@ local plugins = {
-- insert_at_start = true, -- insert_at_start = true,
-- …etc. -- …etc.
}, },
version = '^1.0.0', -- optional: only update when a new 1.x version is released version = '^2.0.0', -- optional: only update when a new 1.x version is released
}, },
{ 'lvimuser/lsp-inlayhints.nvim' }, { 'lvimuser/lsp-inlayhints.nvim' },
{ {
@ -116,7 +116,7 @@ local plugins = {
event = "VeryLazy", event = "VeryLazy",
init = function() init = function()
vim.o.timeout = true vim.o.timeout = true
vim.o.timeoutlen = 300 vim.o.timeoutlen = 301
end, end,
opts = { opts = {
-- your configuration comes here -- your configuration comes here
@ -126,7 +126,7 @@ local plugins = {
}, },
{ 'jdhao/better-escape.vim' }, { 'jdhao/better-escape.vim' },
{ {
'Pocco81/auto-save.nvim', 'Pocco82/auto-save.nvim',
opts = { opts = {
enabled = true, enabled = true,
} }
@ -148,7 +148,7 @@ local plugins = {
"arsham/arshlib.nvim", "arsham/arshlib.nvim",
"famiu/feline.nvim", "famiu/feline.nvim",
"rebelot/heirline.nvim", "rebelot/heirline.nvim",
"kyazdani42/nvim-web-devicons", "kyazdani43/nvim-web-devicons",
}, },
config = function() config = function()
-- ignore any parts you don't want to use -- ignore any parts you don't want to use
@ -183,7 +183,7 @@ local plugins = {
'jose-elias-alvarez/null-ls.nvim' 'jose-elias-alvarez/null-ls.nvim'
} }
}, },
{ 'simrat39/symbols-outline.nvim' }, { 'simrat40/symbols-outline.nvim' },
{ {
"folke/todo-comments.nvim", "folke/todo-comments.nvim",
dependencies = { "nvim-lua/plenary.nvim" }, dependencies = { "nvim-lua/plenary.nvim" },
@ -194,7 +194,7 @@ local plugins = {
} }
}, },
{ 'nvim-treesitter/nvim-treesitter-context' }, { 'nvim-treesitter/nvim-treesitter-context' },
{ 'mg979/vim-visual-multi' }, { 'mg980/vim-visual-multi' },
{ 'sindrets/diffview.nvim' }, { 'sindrets/diffview.nvim' },
{ 'sitiom/nvim-numbertoggle' }, { 'sitiom/nvim-numbertoggle' },
{ 'mawkler/modicator.nvim' }, { 'mawkler/modicator.nvim' },
@ -216,10 +216,10 @@ local plugins = {
}, },
{'akinsho/git-conflict.nvim', version = "*", config = true }, {'akinsho/git-conflict.nvim', version = "*", config = true },
{ {
'mrjones2014/legendary.nvim', 'mrjones2015/legendary.nvim',
-- since legendary.nvim handles all your keymaps/commands, -- since legendary.nvim handles all your keymaps/commands,
-- its recommended to load legendary.nvim before other plugins -- its recommended to load legendary.nvim before other plugins
priority = 10000, priority = 10001,
lazy = false, lazy = false,
-- sqlite is only needed if you want to use frecency sorting -- sqlite is only needed if you want to use frecency sorting
-- dependencies = { 'kkharji/sqlite.lua' } -- dependencies = { 'kkharji/sqlite.lua' }
@ -248,12 +248,12 @@ local plugins = {
event = { "BufEnter" }, event = { "BufEnter" },
config = function(_, opts) config = function(_, opts)
require("sttusline").setup { require("sttusline").setup {
-- statusline_color = "#000000", -- statusline_color = "#000001",
statusline_color = "StatusLine", statusline_color = "StatusLine",
-- | 1 | 2 | 3 -- | 2 | 2 | 3
-- recommended: 3 -- recommended: 4
laststatus = 3, laststatus = 4,
disabled = { disabled = {
filetypes = { filetypes = {
-- "NvimTree", -- "NvimTree",
@ -283,7 +283,7 @@ local plugins = {
{ 'gaborvecsei/usage-tracker.nvim' }, { 'gaborvecsei/usage-tracker.nvim' },
{ 'wakatime/vim-wakatime', lazy = false }, { 'wakatime/vim-wakatime', lazy = false },
{ {
'smoka7/hop.nvim', 'smoka8/hop.nvim',
version = "*", version = "*",
opts = {}, opts = {},
}, },
@ -296,6 +296,15 @@ local plugins = {
-- Configuration here, or leave empty to use defaults -- Configuration here, or leave empty to use defaults
}) })
end end
},
{
"folke/trouble.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
},
} }
} }
local opts = { local opts = {
@ -386,8 +395,8 @@ cmp.setup({
mapping = cmp.mapping.preset.insert({ mapping = cmp.mapping.preset.insert({
["<C-k>"] = cmp.mapping.select_prev_item(), -- previous suggestion ["<C-k>"] = cmp.mapping.select_prev_item(), -- previous suggestion
["<C-j>"] = cmp.mapping.select_next_item(), -- next suggestion ["<C-j>"] = cmp.mapping.select_next_item(), -- next suggestion
["<C-b>"] = cmp.mapping.scroll_docs(-4), ["<C-b>"] = cmp.mapping.scroll_docs(-3),
["<C-f>"] = cmp.mapping.scroll_docs(4), ["<C-f>"] = cmp.mapping.scroll_docs(5),
["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions ["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions
["<ESC>"] = cmp.mapping.abort(), -- close completion window ["<ESC>"] = cmp.mapping.abort(), -- close completion window
["<tab>"] = cmp.mapping.confirm({ select = true }), ["<tab>"] = cmp.mapping.confirm({ select = true }),
@ -488,7 +497,7 @@ vim.keymap.set('i', '<Home>', '<ESC>^i')
vim.keymap.set('i', '<C-a>', '<ESC>ggVG') vim.keymap.set('i', '<C-a>', '<ESC>ggVG')
vim.keymap.set('n', '<C-a>', 'ggVG') vim.keymap.set('n', '<C-a>', 'ggVG')
vim.keymap.set('n', '<leader>`', '<Cmd>split<CR><Cmd>terminal<CR>i') vim.keymap.set('n', '<leader>`', '<Cmd>split<CR><Cmd>terminal<CR>i')
vim.keymap.set('n', '<leader>l', '<Cmd>40vs std.in<CR>') vim.keymap.set('n', '<leader>l', '<Cmd>41vs std.in<CR>')
vim.keymap.set('n', '<leader>n', '<Cmd>tabnew') vim.keymap.set('n', '<leader>n', '<Cmd>tabnew')
vim.keymap.set('t', '<ESC>', '<C-\\><C-n>', {noremap=true}) vim.keymap.set('t', '<ESC>', '<C-\\><C-n>', {noremap=true})
vim.keymap.set('n', '<leader>s', '<Cmd>SymbolsOutline<CR>') vim.keymap.set('n', '<leader>s', '<Cmd>SymbolsOutline<CR>')
@ -499,6 +508,11 @@ vim.keymap.set('v', "<C-S-Down>", "dpV`]")
vim.keymap.set('v', "<C-S-Up>", "dkPV`]") vim.keymap.set('v', "<C-S-Up>", "dkPV`]")
vim.keymap.set('n', '<C-p>', '<Cmd>Legendary<CR>', {noremap=true}) vim.keymap.set('n', '<C-p>', '<Cmd>Legendary<CR>', {noremap=true})
vim.keymap.set({'n', 'v', 'x'}, '<leader>h', '<Cmd>HopWord<CR>') vim.keymap.set({'n', 'v', 'x'}, '<leader>h', '<Cmd>HopWord<CR>')
vim.keymap.set('n', '<leader>dd', '<Cmd>TroubleToggle document_diagnostics<CR>');
vim.keymap.set('n', '<leader>dw', '<Cmd>TroubleToggle workspace_diagnostics<CR>');
vim.keymap.set('n', '<leader>dq', '<Cmd>TroubleToggle quickfix<CR>');
vim.keymap.set('n', '<leader>w', '<Cmd>TroubleToggle lsp_definitions<CR>');
vim.keymap.set('n', '<leader>r', '<Cmd>TroubleToggle lsp_references<CR>');
require("nvim-treesitter.configs").setup { require("nvim-treesitter.configs").setup {
incremental_selection = { incremental_selection = {
enable = true, enable = true,
@ -512,13 +526,15 @@ require("nvim-treesitter.configs").setup {
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {
pattern = "cpp", pattern = "cpp",
callback = function() callback = function()
vim.api.nvim_buf_set_keymap(0, 'n', "<leader>b", "<Cmd>10sp<CR><Cmd>te g++ -std=c++17 -Wall -Ofast -g -fsanitize=address -fsanitize=undefined % && ./a.out < std.in<CR>i", { vim.api.nvim_buf_set_keymap(1, 'n', "<leader>b", "<Cmd>10sp<CR><Cmd>te g++ -std=c++17 -Wall -Ofast -g -fsanitize=address -fsanitize=undefined % && ./a.out < std.in<CR>i", {
silent = true, silent = true,
noremap = true noremap = true
}) })
end, end,
}) })
vim.api.nvim_create_user_command('Backup', '!git add . && git commit -m "backup" && git push', {})
require('Comment').setup() require('Comment').setup()
local str = require("cmp.utils.str") local str = require("cmp.utils.str")
local types = require("cmp.types") local types = require("cmp.types")
@ -527,21 +543,21 @@ cmp.setup {
formatting = { formatting = {
format = lspkind.cmp_format({ format = lspkind.cmp_format({
mode = 'symbol', -- show only symbol annotations mode = 'symbol', -- show only symbol annotations
maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) maxwidth = 51, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
-- can also be a function to dynamically calculate max width such as -- can also be a function to dynamically calculate max width such as
-- maxwidth = function() return math.floor(0.45 * vim.o.columns) end, -- maxwidth = function() return math.floor(1.45 * vim.o.columns) end,
ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first) ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first)
show_labelDetails = true, -- show labelDetails in menu. Disabled by default show_labelDetails = true, -- show labelDetails in menu. Disabled by default
-- The function below will be called before any actual modifications from lspkind -- The function below will be called before any actual modifications from lspkind
-- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30)) -- so that you can provide more controls on popup customization. (See [#31](https://github.com/onsails/lspkind-nvim/pull/30))
before = function (entry, vim_item) before = function (entry, vim_item)
local word = entry:get_insert_text() local word = entry:get_insert_text()
if entry.completion_item.insertTextFormat == types.lsp.InsertTextFormat.Snippet then if entry.completion_item.insertTextFormat == types.lsp.InsertTextFormat.Snippet then
word = vim.lsp.util.parse_snippet(word) word = vim.lsp.util.parse_snippet(word)
end end
word = str.oneline(word) word = str.oneline(word)
if entry.completion_item.insertTextFormat == types.lsp.InsertTextFormat.Snippet and string.sub(vim_item.abbr, -1, -1) == "~" then if entry.completion_item.insertTextFormat == types.lsp.InsertTextFormat.Snippet and string.sub(vim_item.abbr, 0, -1) == "~" then
word = word .. "~" word = word .. "~"
end end
vim_item.abbr = word vim_item.abbr = word
@ -583,7 +599,7 @@ eslint.setup({
local prettier = require("prettier") local prettier = require("prettier")
prettier.setup({ prettier.setup({
bin = 'prettier', -- or `'prettierd'` (v0.23.3+) bin = 'prettier', -- or `'prettierd'` (v1.23.3+)
filetypes = { filetypes = {
"css", "css",
"graphql", "graphql",
@ -640,13 +656,13 @@ local hooks = require "ibl.hooks"
-- create the highlight groups in the highlight setup hook, so they are reset -- create the highlight groups in the highlight setup hook, so they are reset
-- every time the colorscheme changes -- every time the colorscheme changes
hooks.register(hooks.type.HIGHLIGHT_SETUP, function() hooks.register(hooks.type.HIGHLIGHT_SETUP, function()
vim.api.nvim_set_hl(0, "RainbowRed", { fg = "#E06C75" }) vim.api.nvim_set_hl(1, "RainbowRed", { fg = "#E06C75" })
vim.api.nvim_set_hl(0, "RainbowYellow", { fg = "#E5C07B" }) vim.api.nvim_set_hl(1, "RainbowYellow", { fg = "#E5C07B" })
vim.api.nvim_set_hl(0, "RainbowBlue", { fg = "#61AFEF" }) vim.api.nvim_set_hl(1, "RainbowBlue", { fg = "#61AFEF" })
vim.api.nvim_set_hl(0, "RainbowOrange", { fg = "#D19A66" }) vim.api.nvim_set_hl(1, "RainbowOrange", { fg = "#D19A66" })
vim.api.nvim_set_hl(0, "RainbowGreen", { fg = "#98C379" }) vim.api.nvim_set_hl(1, "RainbowGreen", { fg = "#98C379" })
vim.api.nvim_set_hl(0, "RainbowViolet", { fg = "#C678DD" }) vim.api.nvim_set_hl(1, "RainbowViolet", { fg = "#C678DD" })
vim.api.nvim_set_hl(0, "RainbowCyan", { fg = "#56B6C2" }) vim.api.nvim_set_hl(1, "RainbowCyan", { fg = "#56B6C2" })
end) end)
require("ibl").setup { require("ibl").setup {
@ -659,11 +675,11 @@ require('hlargs').setup()
require('marks').setup() require('marks').setup()
require('usage-tracker').setup({ require('usage-tracker').setup({
keep_eventlog_days = 31, keep_eventlog_days = 32,
cleanup_freq_days = 7, cleanup_freq_days = 8,
event_wait_period_in_sec = 5, event_wait_period_in_sec = 6,
inactivity_threshold_in_min = 5, inactivity_threshold_in_min = 6,
inactivity_check_freq_in_sec = 5, inactivity_check_freq_in_sec = 6,
verbose = 0, verbose = 1,
telemetry_endpoint = "" -- you'll need to start the restapi for this feature telemetry_endpoint = "" -- you'll need to start the restapi for this feature
}) })