feat: big refactor.
This commit is contained in:
parent
91660e8890
commit
d0738bbf71
11 changed files with 268 additions and 26 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
Session.vim
|
||||
14
.luarc.json
Normal file
14
.luarc.json
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"runtime.version": "LuaJIT",
|
||||
"runtime.path": [
|
||||
"lua/?.lua",
|
||||
"lua/?.init.lua"
|
||||
],
|
||||
"diagnostics.globals": [
|
||||
"vim"
|
||||
],
|
||||
"workspace.checkThirdParty": false,
|
||||
"workspace.library": [
|
||||
"$VIMRUNTIME"
|
||||
]
|
||||
}
|
||||
2
init.lua
2
init.lua
|
|
@ -1,2 +1,4 @@
|
|||
-- speed up neovim startup time
|
||||
vim.loader.enable()
|
||||
require("config")
|
||||
require("plugins")
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
require('config.settings')
|
||||
require('config.keybindings')
|
||||
require('config.pack')
|
||||
require('config.autocommands')
|
||||
|
|
|
|||
|
|
@ -8,26 +8,20 @@ vim.keymap.set("n", "<Leader> ", ":update<CR> :source<CR>", { desc = "Source cur
|
|||
-- format
|
||||
vim.keymap.set("n", "<Leader>lf", vim.lsp.buf.format, { desc = "Format buffer with available lsp" })
|
||||
|
||||
-- setup mini.pick
|
||||
vim.keymap.set("n", "<Leader>ff", ":Pick files<CR>", { desc = "Search file in directory" })
|
||||
vim.keymap.set("n", "<Leader>fh", ":Pick help<CR>", { desc = "Searcch neovim help" })
|
||||
|
||||
-- move lines up or down
|
||||
vim.keymap.set("n", "<A-j>", ":m .+1<CR>==", { desc = "Move line down" })
|
||||
vim.keymap.set("n", "<A-k>", ":m .-2<CR>==", { desc = "Move line up" })
|
||||
vim.keymap.set("v", "<A-j>", ":m '>+1<CR>gv=gv", { desc = "Move selection down" })
|
||||
vim.keymap.set("v", "<A-k>", ":m '<-2<CR>gv=gv", { desc = "Move selection up" })
|
||||
-- easy copy/cut/paste from system clipboard
|
||||
vim.keymap.set({ "n", "v", "x" }, "<Leader>y", '"+y', { desc = "Yank to system clipboard" })
|
||||
vim.keymap.set({ "n", "v", "x" }, "<Leader>d", '"+d', { desc = "Cut to system clipboard" })
|
||||
vim.keymap.set({ "n", "v", "x" }, "<Leader>p", '"+p', { desc = "Paste from system clipboard" })
|
||||
|
||||
-- better indenting in visual mode
|
||||
vim.keymap.set("v", "<", "<gv", { desc = "Indent left and reselect" })
|
||||
vim.keymap.set("v", ">", ">gv", { desc = "Indent right and reselect" })
|
||||
|
||||
-- file exploring
|
||||
vim.keymap.set("n", "<Leader>e", ":Oil<CR>", { desc = "Open oil file explorer" })
|
||||
|
||||
-- Copy Full File-Path
|
||||
vim.keymap.set("n", "<leader>yp", function()
|
||||
local path = vim.fn.expand("%:p")
|
||||
vim.fn.setreg("+", path)
|
||||
print("file:", path)
|
||||
local path = vim.fn.expand("%:p")
|
||||
vim.fn.setreg("+", path)
|
||||
print("file:", path)
|
||||
end)
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
vim.pack.add({
|
||||
-- Colorscheme
|
||||
{src = "https://github.com/ellisonleao/gruvbox.nvim"},
|
||||
{ src = "https://github.com/ellisonleao/gruvbox.nvim" },
|
||||
-- Treesitter parsers
|
||||
{src = "https://github.com/nvim-treesitter/nvim-treesitter"},
|
||||
{ src = "https://github.com/nvim-treesitter/nvim-treesitter" },
|
||||
-- Preconfigured lsp's
|
||||
{src = "https://github.com/neovim/nvim-lspconfig"},
|
||||
-- Nice file manager
|
||||
{src = "https://github.com/stevearc/oil.nvim"},
|
||||
{ src = "https://github.com/neovim/nvim-lspconfig" },
|
||||
-- Amazing neovim bundle of plugins that are super nice
|
||||
{src = "https://github.com/nvim-mini/mini.nvim"},
|
||||
{ src = "https://github.com/nvim-mini/mini.nvim" },
|
||||
-- Fix the annoying neovim+lua errors
|
||||
{src = "https://github.com/folke/lazydev.nvim"},
|
||||
{ src = "https://github.com/folke/lazydev.nvim" },
|
||||
})
|
||||
|
|
|
|||
|
|
@ -83,3 +83,22 @@ vim.opt.encoding = "UTF8"
|
|||
vim.opt.wildmenu = true
|
||||
vim.opt.wildmode = "longest:full,full"
|
||||
vim.opt.wildignore:append({ "*.o", "*.obj", "*.pyc", "*.class", "*.jar" })
|
||||
|
||||
-- disable builtin plugins that I don't use
|
||||
local builtin_plugs = {
|
||||
"gzip",
|
||||
"matchit",
|
||||
"matchparen",
|
||||
"netrwPlugin",
|
||||
"tarPlugin",
|
||||
"tohtml",
|
||||
"tutor",
|
||||
"zipPlugin",
|
||||
"2html_plugin",
|
||||
"getscript",
|
||||
"getscriptPlugin",
|
||||
}
|
||||
|
||||
for i = 1, #builtin_plugs do
|
||||
vim.g['loaded_' .. builtin_plugs[i]] = true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
require("plugins.colorscheme")
|
||||
require("plugins.treesitter")
|
||||
require("plugins.lsp")
|
||||
require("plugins.oil")
|
||||
require("plugins.mini")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,32 @@
|
|||
-- Enable some settings globally
|
||||
vim.lsp.config("*", {
|
||||
-- allow for multiline token support
|
||||
capabilities = {
|
||||
textDocument = {
|
||||
semanticTokens = {
|
||||
multilineTokenSupport = true,
|
||||
}
|
||||
}
|
||||
},
|
||||
-- make .git always be a root marker
|
||||
root_markers = { '.git' },
|
||||
-- setup autocompletion
|
||||
-- on_attach = function(client, bufnr)
|
||||
-- vim.lsp.completion.enable(true, client.id, bufnr, {
|
||||
-- autotrigger = true,
|
||||
-- convert = function(item)
|
||||
-- return { abbr = item.label:gsub('%b()', '') }
|
||||
-- end,
|
||||
-- })
|
||||
-- end,
|
||||
})
|
||||
|
||||
-- enable specific language servers
|
||||
vim.lsp.enable({
|
||||
"nixd",
|
||||
"lua_ls",
|
||||
"jsonls",
|
||||
})
|
||||
|
||||
-- fix stupid lua error with neovim
|
||||
require("lazydev").setup()
|
||||
-- diagnostic settings
|
||||
vim.diagnostic.config({ virtual_text = true })
|
||||
|
|
|
|||
|
|
@ -1,5 +1,195 @@
|
|||
require("mini.pick").setup()
|
||||
-- setup picker with icons
|
||||
require("mini.icons").setup()
|
||||
require("mini.statusline").setup()
|
||||
require("mini.pick").setup({
|
||||
options = {
|
||||
use_cache = true,
|
||||
},
|
||||
})
|
||||
|
||||
-- additional mini.pick pickers
|
||||
require("mini.extra").setup()
|
||||
|
||||
-- amazing highlight plugin, also used with mini.pick
|
||||
local hipatterns = require("mini.hipatterns")
|
||||
hipatterns.setup({
|
||||
highlighters = {
|
||||
fixme = { pattern = '%f[%w]()FIXME()%f[%W]', group = 'MiniHipatternsFixme' },
|
||||
hack = { pattern = '%f[%w]()HACK()%f[%W]', group = 'MiniHipatternsHack' },
|
||||
todo = { pattern = '%f[%w]()TODO()%f[%W]', group = 'MiniHipatternsTodo' },
|
||||
note = { pattern = '%f[%w]()NOTE()%f[%W]', group = 'MiniHipatternsNote' },
|
||||
|
||||
hex_color = hipatterns.gen_highlighter.hex_color(),
|
||||
},
|
||||
})
|
||||
|
||||
-- mini.pick keybindings
|
||||
local patterns = { "fixme", "hack", "todo", "note", }
|
||||
vim.keymap.set("n", "<Leader>ff", ":Pick files<CR>", { desc = "Search file in directory" })
|
||||
vim.keymap.set("n", "<Leader>fh", ":Pick help<CR>", { desc = "Search neovim help" })
|
||||
vim.keymap.set("n", "<Leader>fd", ":Pick diagnostic<CR>", { desc = "Search diagnostics" })
|
||||
vim.keymap.set("n", "<Leader>fgb", ":Pick git_branches scope='local'<CR>", { desc = "Search git branches" })
|
||||
vim.keymap.set("n", "<Leader>fgc", ":Pick git_commits<CR>", { desc = "Search git commits" })
|
||||
vim.keymap.set("n", "<Leader>fgh", ":Pick git_hunks<CR>", { desc = "Search git hunks" })
|
||||
vim.keymap.set("n", "<Leader>fp", function()
|
||||
MiniExtra.pickers.hipatterns({ highlighters = patterns })
|
||||
end, { desc = "Search git hunks" })
|
||||
|
||||
-- git related stuff
|
||||
require("mini.git").setup()
|
||||
require("mini.diff").setup()
|
||||
|
||||
-- setup statusline
|
||||
require("mini.statusline").setup()
|
||||
|
||||
-- setup snippets
|
||||
local gen_loader = require("mini.snippets").gen_loader
|
||||
require("mini.snippets").setup({
|
||||
snippets = {
|
||||
gen_loader.from_lang(),
|
||||
},
|
||||
mappings = {
|
||||
jump_next = "<C-j>",
|
||||
jump_prev = "<C-k>",
|
||||
},
|
||||
})
|
||||
|
||||
-- setup completion
|
||||
require("mini.completion").setup()
|
||||
|
||||
-- move lines
|
||||
require("mini.move").setup()
|
||||
|
||||
-- easy split args
|
||||
require("mini.splitjoin").setup()
|
||||
|
||||
-- surround actions
|
||||
require("mini.surround").setup()
|
||||
|
||||
-- super simple but amazing file manager
|
||||
require("mini.files").setup()
|
||||
|
||||
-- setup simple function for toggling mini.files
|
||||
local minifiles_toggle = function(...)
|
||||
if not MiniFiles.close() then MiniFiles.open(...) end
|
||||
end
|
||||
|
||||
-- Set focused directory as current working directory
|
||||
local set_cwd = function()
|
||||
local path = (MiniFiles.get_fs_entry() or {}).path
|
||||
if path == nil then return vim.notify('Cursor is not on valid entry') end
|
||||
vim.fn.chdir(vim.fs.dirname(path))
|
||||
end
|
||||
|
||||
-- Yank in register full path of entry under cursor
|
||||
local yank_path = function()
|
||||
local path = (MiniFiles.get_fs_entry() or {}).path
|
||||
if path == nil then return vim.notify('Cursor is not on valid entry') end
|
||||
vim.fn.setreg(vim.v.register, path)
|
||||
end
|
||||
|
||||
-- Open path with system default handler (useful for non-text files)
|
||||
local ui_open = function() vim.ui.open(MiniFiles.get_fs_entry().path) end
|
||||
|
||||
vim.api.nvim_create_autocmd('User', {
|
||||
pattern = 'MiniFilesBufferCreate',
|
||||
callback = function(args)
|
||||
local b = args.data.buf_id
|
||||
vim.keymap.set('n', 'g~', set_cwd, { buffer = b, desc = 'Set cwd' })
|
||||
vim.keymap.set('n', 'gX', ui_open, { buffer = b, desc = 'OS open' })
|
||||
vim.keymap.set('n', 'gy', yank_path, { buffer = b, desc = 'Yank path' })
|
||||
end,
|
||||
})
|
||||
|
||||
-- setup keybinding for mini.files
|
||||
vim.keymap.set("n", "<Leader>e", function() minifiles_toggle() end, { desc = "Toggle mini.files explorer" })
|
||||
|
||||
-- setup mini.clues, whickey but much simpler
|
||||
local miniclue = require('mini.clue')
|
||||
miniclue.setup({
|
||||
triggers = {
|
||||
-- Leader triggers
|
||||
{ mode = 'n', keys = '<Leader>' },
|
||||
{ mode = 'x', keys = '<Leader>' },
|
||||
|
||||
-- Built-in completion
|
||||
{ mode = 'i', keys = '<C-x>' },
|
||||
|
||||
-- `g` key
|
||||
{ mode = 'n', keys = 'g' },
|
||||
{ mode = 'x', keys = 'g' },
|
||||
|
||||
-- Marks
|
||||
{ mode = 'n', keys = "'" },
|
||||
{ mode = 'n', keys = '`' },
|
||||
{ mode = 'x', keys = "'" },
|
||||
{ mode = 'x', keys = '`' },
|
||||
|
||||
-- Registers
|
||||
{ mode = 'n', keys = '"' },
|
||||
{ mode = 'x', keys = '"' },
|
||||
{ mode = 'i', keys = '<C-r>' },
|
||||
{ mode = 'c', keys = '<C-r>' },
|
||||
|
||||
-- Window commands
|
||||
{ mode = 'n', keys = '<C-w>' },
|
||||
|
||||
-- `z` key
|
||||
{ mode = 'n', keys = 'z' },
|
||||
{ mode = 'x', keys = 'z' },
|
||||
},
|
||||
|
||||
clues = {
|
||||
-- Enhance this by adding descriptions for <Leader> mapping groups
|
||||
miniclue.gen_clues.builtin_completion(),
|
||||
miniclue.gen_clues.g(),
|
||||
miniclue.gen_clues.marks(),
|
||||
miniclue.gen_clues.registers(),
|
||||
miniclue.gen_clues.windows(),
|
||||
miniclue.gen_clues.z(),
|
||||
},
|
||||
})
|
||||
|
||||
-- minimal session manager
|
||||
require("mini.sessions").setup()
|
||||
|
||||
vim.keymap.set("n", "<Leader>pc", function() MiniSessions.write() end, { desc = "Create new session/project" })
|
||||
vim.keymap.set("n", "<Leader>ps", function() MiniSessions.select("read") end, { desc = "Select session/project" })
|
||||
|
||||
-- nice file/directory visit tracker
|
||||
require("mini.visits").setup()
|
||||
|
||||
-- setup some basic label keybindings
|
||||
local map_vis = function(keys, call, desc)
|
||||
local rhs = '<Cmd>lua MiniVisits.' .. call .. '<CR>'
|
||||
vim.keymap.set('n', '<Leader>' .. keys, rhs, { desc = desc })
|
||||
end
|
||||
|
||||
map_vis('vv', 'add_label()', 'Add label')
|
||||
map_vis('vV', 'remove_label()', 'Remove label')
|
||||
map_vis('vc', 'add_label("core")', 'Add to core')
|
||||
map_vis('vC', 'remove_label("core")', 'Remove from core')
|
||||
vim.keymap.set("n", "<Leader>fv", ":Pick visit_paths<CR>", { desc = "Search visited files" })
|
||||
vim.keymap.set("n", "<Leader>fc", ":Pick visit_paths filter='core'<CR>",
|
||||
{ desc = "Search visited files with tag 'core'" })
|
||||
|
||||
-- amazing fast indent scope highlight plugin
|
||||
require("mini.indentscope").setup()
|
||||
|
||||
-- nice simple notifications inside neovim
|
||||
require("mini.notify").setup()
|
||||
|
||||
-- simple startup startup screen
|
||||
local starter = require('mini.starter')
|
||||
starter.setup({
|
||||
evaluate_single = true,
|
||||
items = {
|
||||
starter.sections.builtin_actions(),
|
||||
starter.sections.sessions(5, true),
|
||||
starter.sections.recent_files(5, true),
|
||||
starter.sections.recent_files(5, false),
|
||||
},
|
||||
content_hooks = {
|
||||
starter.gen_hook.adding_bullet(),
|
||||
starter.gen_hook.aligning("center", "center")
|
||||
},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
require("oil").setup()
|
||||
Loading…
Add table
Add a link
Reference in a new issue