feat: new config

This commit is contained in:
2024-02-20 21:19:43 +08:00
parent 3fad1b11f4
commit b49026c12e
45 changed files with 1072 additions and 427 deletions
+14
View File
@@ -0,0 +1,14 @@
-- Turn off paste mode when leaving insert
vim.api.nvim_create_autocmd("InsertLeave", {
pattern = "*",
command = "set nopaste",
})
-- Disable the concealing in some file formats
-- The default conceallevel is 3 in LazyVim
vim.api.nvim_create_autocmd("FileType", {
pattern = { "json", "jsonc", "markdown" },
callback = function()
vim.opt.conceallevel = 0
end,
})
+256
View File
@@ -0,0 +1,256 @@
local opts = {
mode = "n", -- NORMAL mode
prefix = "<leader>",
buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings
silent = true, -- use `silent` when creating keymaps
noremap = true, -- use `noremap` when creating keymaps
nowait = false -- use `nowait` when creating keymaps
}
local mappings = {
-- ["/"] = "Comment",
-- ["c"] = "Close Buffer",
["e"] = "Explorer",
-- ["f"] = "Find File",
["h"] = "No Highlight",
a = {
name = "+Action",
a = { "<cmd>@:<cr>", "execute last command again" }
},
b = {
name = "+Buffer",
n = { "<cmd>BufferNext<cr>", "next buffer" },
p = { "<cmd>BufferPrevious<cr>", "previous buffer" },
q = { "<cmd>q<cr>", "quit" },
s = { "<cmd>w<cr>", "save" },
r = { "<cmd>e!<cr>", "reload" },
d = { "<cmd>BufferClose<cr>", "close buffer" },
z = { "<cmd>CommentToggle<CR>", "toggle comment" },
},
D = {
name = "+Diagnostics",
t = { "<cmd>TroubleToggle<cr>", "trouble" },
w = { "<cmd>TroubleToggle lsp_workspace_diagnostics<cr>", "workspace" },
d = { "<cmd>TroubleToggle lsp_document_diagnostics<cr>", "document" },
q = { "<cmd>TroubleToggle quickfix<cr>", "quickfix" },
l = { "<cmd>TroubleToggle loclist<cr>", "loclist" },
r = { "<cmd>TroubleToggle lsp_references<cr>", "references" },
},
d = {
name = "+Debug",
-- b = {"<cmd>DebugToggleBreakpoint<cr>", "Toggle Breakpoint"},
-- c = {"<cmd>DebugContinue<cr>", "Continue"},
-- i = {"<cmd>DebugStepInto<cr>", "Step Into"},
-- o = {"<cmd>DebugStepOver<cr>", "Step Over"},
-- r = {"<cmd>DebugToggleRepl<cr>", "Toggle Repl"},
-- s = {"<cmd>DebugStart<cr>", "Start"}
d = { "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<cr>", "show diagnostics" },
c = { "<cmd>lua require'dap'.continue()<cr>", "continue" },
b = { ':lua require"dap".toggle_breakpoint()<CR>', "Toggle Breadpoint" },
j = { ':lua require"dap".step_over()<CR>', "step over" },
k = { ':lua require"dap".step_out()<CR>', "step out" },
l = { ':lua require"dap".step_into()<CR>', "step into" },
--<c-h>', ':lua require"dap".continue()<CR>')
u = { ':lua require"dap".up()<CR>', "up" },
-- d = {':lua require"dap".down()<CR>', "down"},
_ = { ':lua require"dap".disconnect();require"dap".stop();require"dap".run_last()<CR>', "disconnect" },
--r = {':lua require"dap".repl.open({}, "vsplit")<CR><C-w>l', "repl open"},
i = { ':lua require"dap.ui.variables".visual_hover()<CR>', "visual_hover" },
--? = {':lua require"dap.ui.variables".scopes()<CR>',"scopes"},
-- e = {':lua require"dap".set_exception_breakpoints({"all"})<CR>',"esception bp"},
-- a = {':lua require"debugHelper".attach()<CR>',"attach"},
-- A = {':lua require"debugHelper".attachToRemote()<CR>',"attach to remote"},
s = { ':lua local widgets=require"dap.ui.widgets";widgets.centered_float(widgets.scopes)<CR>', "centered_float" },
},
f = {
name = "+File",
m = { "<cmd>lua require'utils'.open_md()<cr>", "open a markdown file in vscode" },
s = { "<cmd>w<cr>", "save file" },
t = { "<cmd>NvimTreeToggle<cr>", "toggle nvim tree" },
r = { "<cmd>RnvimrToggle<cr>", "toggle rnvimr" },
y = { "<cmd>lua require'utils'.yank_filepath()<cr>", "copy the file path" },
d = { "<cmd>lua require'utils'.yank_file_dir()<cr>", "copy the file path" },
l = { "<cmd>NvimTreeFindFile<CR>", "find file" },
-- T = {"<cmd>let @+ = 'go test -v -run='+expand('<cword>')<cr>", "get current word in go test"},
},
g = {
name = "+Git",
m = {"<cmd>Gvdiff master:%<cr>", "Diff with master"},
j = { "<cmd>lua require 'gitsigns'.next_hunk()<cr>", "Next Hunk" },
k = { "<cmd>lua require 'gitsigns'.prev_hunk()<cr>", "Prev Hunk" },
l = { "<cmd>lua require 'gitsigns'.blame_line()<cr>", "Blame" },
p = { "<cmd>lua require 'gitsigns'.preview_hunk()<cr>", "Preview Hunk" },
r = { "<cmd>lua require 'gitsigns'.reset_hunk()<cr>", "Reset Hunk" },
R = { "<cmd>lua require 'gitsigns'.reset_buffer()<cr>", "Reset Buffer" },
s = { "<cmd>lua require 'gitsigns'.stage_hunk()<cr>", "Stage Hunk" },
S = { "<cmd>lua require 'gitsigns'.stage_buffer()<cr>", "Stage Buffer" },
u = {
"<cmd>lua require 'gitsigns'.undo_stage_hunk()<cr>",
"Undo Stage Hunk",
},
o = { "<cmd>Telescope git_status<cr>", "Open changed file" },
b = { "<cmd>Telescope git_branches<cr>", "Checkout branch" },
c = { "<cmd>Telescope git_commits<cr>", "Checkout commit" },
C = {
"<cmd>Telescope git_bcommits<cr>",
"Checkout commit(for current file)",
},
d = {
"<cmd>Gitsigns diffthis HEAD<cr>",
"Git Diff",
},
},
l = {
name = "+Language",
a = { "<cmd>Lspsaga code_action<cr>", "Code Action" },
A = { "<cmd>Lspsaga range_code_action<cr>", "Selected Action" },
d = { "<cmd>Telescope lsp_document_diagnostics<cr>", "Document Diagnostics" },
D = { "<cmd>Telescope lsp_workspace_diagnostics<cr>", "Workspace Diagnostics" },
f = { "<cmd>LspFormatting<cr>", "Format" },
F = { "<cmd>Lspsaga lsp_finder<cr>", "LSP Finder" },
-- i = {"<cmd>Telescope lsp_implementations<cr>", "implement"},
i = { "<cmd>lua vim.lsp.buf.implementation()<cr>", "implement" },
l = { "<cmd>lua vim.lsp.buf.hover()<cr>", "hover" },
L = { "<cmd>Lspsaga show_line_diagnostics<cr>", "Line Diagnostics" },
k = { "<cmd>: LspRestart<cr>", "restart lsp server" },
n = { "<cmd>lua vim.lsp.diagnostic.goto_next()<cr>", "next diagnostic" },
o = { "<cmd>: SymbolsOutline<cr>", "symbols outline" },
p = { "<cmd>lua vim.lsp.diagnostic.goto_prev()<cr>", "prev diagnostic" },
P = { "<cmd>Lspsaga preview_definition<cr>", "Preview Definition" },
q = { "<cmd>Telescope quickfix<cr>", "Quickfix" },
r = { "<cmd>lua vim.lsp.buf.references()<cr>", "references" },
R = { "<cmd>Lspsaga rename<cr>", "Rename" },
t = { "<cmd>LspTypeDefinition<cr>", "Type Definition" },
x = { "<cmd>cclose<cr>", "Close Quickfix" },
s = { "<cmd>Telescope lsp_document_symbols<cr>", "Document Symbols" },
S = { "<cmd>Telescope lsp_dynamic_workspace_symbols<cr>", "Workspace Symbols" },
z = { "<cmd>LspInfo<cr>", "Info" },
[","] = { "<cmd>LspInstallInfo<cr>", "LSP servers" }
},
p = {
name = "Packer",
c = { "<cmd>PackerCompile<cr>", "Compile" },
i = { "<cmd>PackerInstall<cr>", "Install" },
s = { "<cmd>PackerSync<cr>", "Sync" },
S = { "<cmd>PackerStatus<cr>", "Status" },
u = { "<cmd>PackerUpdate<cr>", "Update" },
},
q = {
name = "quit",
q = { "<cmd>qall<cr>", "quit" },
},
s = {
name = "+Search",
b = { "<cmd>Telescope git_branches<cr>", "Checkout branch" },
-- c = {"<cmd>Telescope colorscheme<cr>", "Colorscheme"},
c = { "<cmd>:nohl<cr>", "no highlight" },
d = { "<cmd>Telescope lsp_document_diagnostics<cr>", "Document Diagnostics" },
D = { "<cmd>Telescope lsp_workspace_diagnostics<cr>", "Workspace Diagnostics" },
f = { "<cmd>Fzflua files<cr>", "Find File" },
m = { "<cmd>Telescope marks<cr>", "Marks" },
M = { "<cmd>Telescope man_pages<cr>", "Man Pages" },
r = { "<cmd>FzfLua oldfiles<cr>", "Open Recent File" },
R = { "<cmd>Telescope registers<cr>", "Registers" },
t = { "<cmd>FzfLua live_grep<cr>", "Text" },
["#"] = { "<cmd>FzfLua grep_cword<cr>", "Search word under cursor" },
},
S = {
name = "+Session",
s = { "<cmd>SessionSave<cr>", "Save Session" },
l = { "<cmd>SessionLoad<cr>", "Load Session" },
},
t = {
name = "+Test",
a = { "<cmd>TestSuite -v -cover<cr>", "TestSuite" },
t = { "<cmd>lua require('neotest').run.run() <cr>", "TestNearest" },
f = { '<cmd>lua require("neotest").run.run(vim.fn.expand("%"))<cr>', "TestFile" },
c = { "<cmd>GoCover<cr>", "go coverage" },
C = { "<cmd>GoCoverClear<cr>", "go coverage clear" },
b = { "<cmd>lua require'dap'.toggle_breakpoint()<cr>", "set break point" },
r = { "<cmd>lua require'dap'.continue()<cr>", "continue" },
},
-- extras
z = {
name = "+Zen",
s = { "<cmd>TZBottom<cr>", "toggle status line" },
t = { "<cmd>TZTop<cr>", "toggle tab bar" },
z = { "<cmd>TZAtaraxis<cr>", "toggle zen" },
}
}
local wk = require("which-key")
wk.register(mappings, opts)
local keymap = vim.keymap
local opts = { noremap = true, silent = true }
-- no hl
keymap.set('n', '<Leader>h', ':set hlsearch!<CR>', { noremap = true, silent = true })
-- explorer
keymap.set('n', '<Leader>e', ':NvimTreeToggle<CR>', { noremap = true, silent = true })
-- telescope
-- keymap.set('n', '<C-p>', ":lua require'telescope.builtin'.find_files()<CR>", {noremap = true, silent = true})
keymap.set('n', '<C-p>', ":FzfLua files<CR>", { noremap = true, silent = true })
-- dashboard
keymap.set('n', '<Leader>;', ':Dashboard<CR>', { noremap = true, silent = true })
-- Comments
keymap.set("n", "<Leader>b/", ":CommentToggle<CR>", { noremap = true, silent = true })
keymap.set("v", "<Leader>b/", ":CommentToggle<CR>", { noremap = true, silent = true })
-- close buffer
keymap.set("n", "<leader>c", ":BufferClose<CR>", { noremap = true, silent = true })
keymap.set('n', '-', ':RnvimrToggle<CR>', opts )
-- better window movement
keymap.set('n', '<C-h>', '<C-w>h', { silent = true })
keymap.set('n', '<C-j>', '<C-w>j', { silent = true })
keymap.set('n', '<C-k>', '<C-w>k', { silent = true })
keymap.set('n', '<C-l>', '<C-w>l', { silent = true })
-- better edit
keymap.set('n', 'Y', 'y$', {})
-- resize with arrows
keymap.set('n', '<C-Up>', ':resize -2<CR>', { silent = true })
keymap.set('n', '<C-Down>', ':resize +2<CR>', { silent = true })
keymap.set('n', '<C-Left>', ':vertical resize -2<CR>', { silent = true })
keymap.set('n', '<C-Right>', ':vertical resize +2<CR>', { silent = true })
-- better indenting
keymap.set('v', '<', '<gv', { noremap = true, silent = true })
keymap.set('v', '>', '>gv', { noremap = true, silent = true })
-- I hate escape
keymap.set('i', 'jk', '<ESC>', { noremap = true, silent = true })
keymap.set('i', 'kj', '<ESC>', { noremap = true, silent = true })
keymap.set('i', 'jj', '<ESC>', { noremap = true, silent = true })
-- Tab switch buffer
keymap.set('n', '<TAB>', ':bnext<CR>', { noremap = true, silent = true })
keymap.set('n', '<S-TAB>', ':bprevious<CR>', { noremap = true, silent = true })
-- Move selected line / block of text in visual mode
keymap.set('x', 'K', ':move \'<-2<CR>gv-gv', { noremap = true, silent = true })
keymap.set('x', 'J', ':move \'>+1<CR>gv-gv', { noremap = true, silent = true })
keymap.set('', '<C-q>', ':call QuickFixToggle()<CR>', { noremap = true, silent = true })
-- -- Better nav for omnicomplete
-- vim.cmd('inoremap <expr> <c-j> (\"\\<C-n>\")')
-- vim.cmd('inoremap <expr> <c-k> (\"\\<C-p>\")')
-- vim.cmd('vnoremap p "0p')
-- vim.cmd('vnoremap P "0P')
+46
View File
@@ -0,0 +1,46 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
-- bootstrap lazy.nvim
-- stylua: ignore
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath })
end
vim.opt.rtp:prepend(vim.env.LAZY or lazypath)
require("lazy").setup({
spec = {
-- add LazyVim and import its plugins
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
-- import any extras modules here
-- { import = "lazyvim.plugins.extras.lang.typescript" },
-- { import = "lazyvim.plugins.extras.lang.json" },
-- { import = "lazyvim.plugins.extras.ui.mini-animate" },
-- import/override with your plugins
{ import = "plugins" },
},
defaults = {
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
-- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
lazy = false,
-- It's recommended to leave version=false for now, since a lot the plugin that support versioning,
-- have outdated releases, which may break your Neovim install.
version = false, -- always use the latest git commit
-- version = "*", -- try installing the latest stable version for plugins that support semver
},
install = { colorscheme = { "tokyonight", "habamax" } },
checker = { enabled = true }, -- automatically check for plugin updates
performance = {
rtp = {
-- disable some rtp plugins
disabled_plugins = {
"gzip",
-- "matchit",
-- "matchparen",
-- "netrwPlugin",
"tarPlugin",
"tohtml",
"tutor",
"zipPlugin",
},
},
},
})
+56
View File
@@ -0,0 +1,56 @@
vim.cmd('set iskeyword+=-') -- treat dash separated words as a word text object"
vim.cmd('set shortmess+=c') -- Don't pass messages to |ins-completion-menu|.
vim.cmd('set inccommand=split') -- Make substitution work in realtime
vim.o.hidden = true -- Required to keep multiple buffers open multiple buffers
vim.o.title = true
TERMINAL = vim.fn.expand('$TERMINAL')
vim.cmd('let &titleold="'..TERMINAL..'"')
vim.o.titlestring="%<%F%=%l/%L - nvim"
vim.wo.wrap = true -- Display long lines as just one line
vim.cmd('set whichwrap+=<,>,[,],h,l') -- move to next line with theses keys
vim.cmd('syntax on') -- syntax highlighting
vim.o.pumheight = 10 -- Makes popup menu smaller
vim.o.fileencoding = "utf-8" -- The encoding written to file
vim.o.cmdheight = 2 -- More space for displaying messages
vim.cmd('set colorcolumn=99999') -- fix indentline for now
vim.o.mouse = "a" -- Enable your mouse
vim.o.splitbelow = true -- Horizontal splits will automatically be below
vim.o.termguicolors = true -- set term gui colors most terminals support this
vim.o.splitright = true -- Vertical splits will automatically be to the right
-- vim.o.t_Co = "256" -- Support 256 colors
vim.o.conceallevel = 0 -- So that I can see `` in markdown files
-- vim.cmd('set ts=4') -- Insert 2 spaces for a tab
-- vim.cmd('set sw=4') -- Change the number of space characters inserted for indentation
-- vim.cmd('set expandtab') -- Converts tabs to spaces
vim.bo.smartindent = true -- Makes indenting smart
vim.wo.number = true -- set numbered lines
vim.wo.relativenumber = true -- set relative number
vim.wo.cursorline = true -- Enable highlighting of the current line
vim.o.showtabline = 2 -- Always show tabs
vim.o.showmode = false -- We don't need to see things like -- INSERT -- anymore
vim.o.backup = false -- This is recommended by coc
vim.o.writebackup = false -- This is recommended by coc
vim.wo.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time
vim.o.updatetime = 300 -- Faster completion
vim.o.timeoutlen = 100 -- By default timeoutlen is 1000 ms
vim.o.clipboard = "unnamedplus" -- Copy paste between vim and everything else
vim.cmd('filetype plugin on') -- filetype detection
-- vim.o.guifont = "JetBrainsMono\\ Nerd\\ Font\\ Mono:h18"
-- vim.o.guifont = "Hack\\ Nerd\\ Font\\ Mono"
-- vim.o.guifont = "SauceCodePro Nerd Font:h17"
vim.o.guifont = "FiraCode Nerd Font:h17"
-- vim.o.guifont = "JetBrains\\ Mono\\ Regular\\ Nerd\\ Font\\ Complete"
vim.g.vim_markdown_folding_disabled = 1
vim.g.vimspector_enable_mappings = 'HUMAN'
vim.g['test#go#rspec#options'] = { nearest= '--v', suite= '--v' }
-- git blame
vim.cmd('highlight default link gitblame SpecialComment')
vim.g.gitblame_enabled = 0
-- last position jump
vim.cmd([[
autocmd BufReadPost * if line("'\"") >= 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
]])