feat(nvim): Build another nvim from scratch

* Neovim: Backup original LazyVim setup to .config/nvim.lazy.d
* Neovim: Currently done with basic completions and LSP
* Git: Always use ssh to connect github remote
* Zsh: Add more antidots config
This commit is contained in:
js0ny 2024-11-28 01:48:26 +00:00
parent 74f2883139
commit eeb3387112
53 changed files with 1617 additions and 682 deletions

View file

@ -20,3 +20,5 @@
required = true required = true
[safe] [safe]
directory = %(prefix)///wsl.localhost/Arch/home/js0ny/inf2c/coursework-2-mips-simulator-js0ny directory = %(prefix)///wsl.localhost/Arch/home/js0ny/inf2c/coursework-2-mips-simulator-js0ny
[url "git@github.com:"]
insteadOf = https://github.com/

View file

@ -0,0 +1,8 @@
-- bootstrap lazy.nvim, LazyVim and your plugins
if (vim.g.vscode) then
print("VSCode detected, skipping lazy loading")
require("vscode.code")
else
require("config.lazy")
-- require("config.lazy")
end

View file

@ -0,0 +1,8 @@
{
"lazy.nvim": { "branch": "main", "commit": "7967abe55752aa90532e6bb4bd4663fe27a264cb" },
"nvim-cmp": { "branch": "main", "commit": "be7bd4c5f860c79da97af3a26d489af50babfd4b" },
"nvim-lspconfig": { "branch": "master", "commit": "c646154d6e4db9b2979eeb517d0b817ad00c9c47" },
"nvim-treesitter": { "branch": "master", "commit": "efb2e9c607cab1e4f7171493b7c6f63bd39073fc" },
"plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" },
"telescope.nvim": { "branch": "master", "commit": "85922dde3767e01d42a08e750a773effbffaea3e" }
}

View file

@ -0,0 +1,10 @@
{
"extras": [
"lazyvim.plugins.extras.ai.copilot",
"lazyvim.plugins.extras.ai.copilot-chat"
],
"news": {
"NEWS.md": "7429"
},
"version": 7
}

View file

@ -0,0 +1,146 @@
-- Keymaps are automatically loaded on the VeryLazy event
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
-- Add any additional keymaps here
vim.g.mapleader = " "
-- ================= GENERAL KEYBINDS =================
-- SAVE/QUIT {{{
vim.keymap.set("n", "Q", "<cmd>q<CR>", { desc = "Q to quit" })
vim.keymap.set("n", "<C-s>", "<cmd>w<CR>", { desc = "S to write file" })
--}}}
-- NVIM CONFIG SHORTCUTS {{{
-- stylua: ignore
vim.keymap.set("n", "<leader>rc", "<cmd>e $HOME/.config/nvim/lua/config/options.lua<CR>", { desc = "Open nvim options.lua" })
vim.keymap.set("n", "<leader>rp", "<cmd>e $HOME/.config/nvim/lua/plugins/.<CR>", { desc = "lazy plugins dir" })
--}}}
-- UNDO
vim.keymap.set({ "n", "v" }, "l", "u", { desc = "Undo" })
-- INSERT
vim.keymap.set({ "n", "v" }, "l", "i", { desc = "Insert" })
vim.keymap.set({ "n", "v" }, "L", "I", { desc = "Insert at line start" })
-- YANK TO SYSTEM CLIPBOARD
vim.keymap.set("v", "Y", '"+y', { desc = "Copy to (System) Clipboard" })
-- SEARCH {{{
vim.keymap.set("n", "<LEADER><CR>", "<CMD>nohlsearch<CR>", { desc = "clear search highlight" })
--}}}
-- SPACE TO TAB{{{
vim.keymap.set("n", "<LEADER>tt", "<CMD>%s/ /\t/g<CR>", { desc = "space to tab" })
vim.keymap.set("v", "<LEADER>tt", "<CMD>s/ /\t/g<CR>", { desc = "space to tab" })
--}}}
-- MISC {{{
vim.keymap.set("n", "<LEADER>o", "za", { desc = "folding" })
vim.keymap.set("i", "<C-y>", "<ESC>A {}<ESC>i<CR><ESC>ko", { desc = "insert a pair of {} and goto next line" })
--}}}
-- ================= CURSOR MOVEMENT ===================== {{{
-- NEW CURSOR MOVEMENT (ARROW KEY RESIZE WINDOWS)
-- ^
-- e
-- < h i >
-- n
-- v
--
vim.keymap.set({ "n", "v", "", "s", "x" }, "e", "k", { desc = "move cursor ⇧" })
vim.keymap.set({ "n", "v", "", "s", "x" }, "n", "j", { desc = "move cursor ⇩" })
vim.keymap.set({ "n", "v", "", "s", "x" }, "h", "h", { desc = "move cursor ⇦" })
vim.keymap.set({ "n", "v", "", "s", "x" }, "i", "l", { desc = "move cursor ⇨" })
vim.keymap.set({ "n", "v" }, "E", "5k", { desc = "Move 5up K -> U" })
vim.keymap.set({ "n", "v" }, "N", "5j", { desc = "Move 5down J -> E" })
vim.keymap.set({ "n", "v" }, "H", "0", { desc = "Move start of line" })
vim.keymap.set({ "n", "v" }, "I", "$", { desc = "Move end of line" })
vim.keymap.set("n", "gu", "gk", { desc = "move up gk -> gu" })
vim.keymap.set("n", "ge", "gj", { desc = "move down gj -> ge" })
vim.keymap.set("n", "\v", "v$h", { desc = "???" })
-- FASTER IN-LINE NAVIGATION
-- SET h (SAME AS n, CURSOR LEFT) TO 'END OF WORD'
vim.keymap.set("n", "j", "e", { desc = "Move cursor to end of word" })
-- CTRL + U OR E WILL MOVE UP/DOWN THE VIEW PORT WITHOUT MOVING THE CURSOR
vim.keymap.set({ "n", "v" }, "<C-e>", "5<C-y>", { desc = "Move viewport ⇧" })
vim.keymap.set({ "n", "v" }, "<C-n>", "5<C-e>", { desc = "Move viewport ⇩" })
-- INSERT MODE CURSOR MOVEMENT
vim.keymap.set("i", "<C-a>", "<ESC>A")
-- COMMAND MODE CURSOR MOVEMENT
vim.keymap.set("c", "<C-a>", "<Home>")
vim.keymap.set("c", "<C-e>", "<End>")
vim.keymap.set("c", "<C-p>", "<Up>")
vim.keymap.set("c", "<C-n>", "<Down>")
vim.keymap.set("c", "<C-b>", "<Left>")
vim.keymap.set("c", "<C-f>", "<Right>")
vim.keymap.set("c", "<M-b>", "<S-Left>")
vim.keymap.set("c", "<M-w>", "<S-Right>")
--}}}
-- ================= SPLIT MANAGMENT ===================== {{{
vim.keymap.set("n", "<C-w>E", "<CMD>set nosplitbelow<CR><CMD>split<CR><CMD>set splitbelow<CR>", { desc = "Split ⇧" })
vim.keymap.set("n", "<C-w>N", "<CMD>set splitbelow<CR><CMD>split<CR>", { desc = "Split ⇩" })
vim.keymap.set("n", "<C-w>H", "<CMD>set nosplitright<CR><CMD>vsplit<CR><CMD>set splitright<CR>", { desc = "Split ⇦" })
vim.keymap.set("n", "<C-w>I", "<CMD>set splitright<CR><CMD>vsplit<CR>", { desc = "Split ⇨" })
vim.keymap.set({ "n", "t" }, "<C-w>e", "<C-w>k", { desc = "Move cursor to split ⇧" })
vim.keymap.set({ "n", "t" }, "<C-w>n", "<C-w>j", { desc = "Move cursor to split ⇩" })
vim.keymap.set({ "n", "t" }, "<C-w>h", "<C-w>h", { desc = "Move cursor to split ⇦" })
vim.keymap.set({ "n", "t" }, "<C-w>i", "<C-w>l", { desc = "Move cursor to split ⇨" })
vim.keymap.set({ "n", "t" }, "<C-e>", "<C-k>", { desc = "Move cursor to split ⇧" })
vim.keymap.set({ "n", "t" }, "<C-n>", "<C-j>", { desc = "Move cursor to split ⇩" })
vim.keymap.set({ "n", "t" }, "<C-h>", "<C-h>", { desc = "Move cursor to split ⇦" })
vim.keymap.set({ "n", "t" }, "<C-i>", "<C-l>", { desc = "Move cursor to split ⇨" })
vim.keymap.set("n", "<up>", "<CMD>res -5<CR>", { desc = "Resize split 0,-5" })
vim.keymap.set("n", "<down>", "<CMD>res +5<CR>", { desc = "Resize split 0,+5" })
vim.keymap.set("n", "<left>", "<CMD>vertical resize +5<CR>", { desc = "Resize split +5,0" })
vim.keymap.set("n", "<right>", "<CMD>vertical resize -5<CR>", { desc = "Resize split -5,0" })
vim.keymap.set("n", "<C-w>H", "<C-w>t<C-w>K", { desc = "Make splits [H]orizontal" })
vim.keymap.set("n", "<C-w>V", "<C-w>t<C-w>H", { desc = "Make splits [V]ertical" })
vim.keymap.set("n", "<C-w>ri", "<C-w>b<C-w>K", { desc = "Rotate splits 90" })
vim.keymap.set("n", "<C-w>rh", "<C-w>b<C-w>H", { desc = "Rotate splits -90" })
vim.keymap.set("n", "<LEADER>q", "<C-w>j<CMD>q<CR>", { desc = "Close Split ⇩ (Below)" })
--}}}
-- TAB MANAGEMENT {{{
vim.keymap.set("n", "<TAB><TAB>", "<CMD>tabe<CR>", { desc = "New [Tab]" })
vim.keymap.set("n", "<TAB>h", "<CMD>-tabnext<CR>", { desc = "Select Tab ⇦" })
vim.keymap.set("n", "<TAB>i", "<CMD>+tabnext<CR>", { desc = "Select Tab ⇨" })
vim.keymap.set("n", "<TAB>H", "<CMD>-tabmove<CR>", { desc = "Tab move ⇦" })
vim.keymap.set("n", "<TAB>I", "<CMD>+tabmove<CR>", { desc = "Tab move ⇨" })
-- NOTE: Doesn't seem to work:
-- vim.keymap.set("n", "<TAB>c", "<CMD>tab split<CR>", { desc = "New Tab from [C]urrent" })
-- vim.keymap.set('n', '<LEADER>dw', '/\(\<\w\+\>\)\_s*\1', {desc='adjacent duplicate words'})
--vim.keymap.del("n", "<C-w>j")
--vim.keymap.del("n", "<C-w>k")
--vim.keymap.del("n", "<C-w>l")
-- }}}
-- =================== TERM BEHAVIORS ====================
vim.keymap.set("t", "<C-n>", "<C-\\><C-n>", { desc = "escape terminal, allowing excmds" })
vim.keymap.set("t", "<C-o>", "<C-\\><C-n><C-o>", { desc = "close terminal" })
--vim: set fdm=marker fdl=0
-- buffers
vim.keymap.set("n", "<S-h>", "<cmd>bprevious<cr>", { desc = "Prev Buffer" })
vim.keymap.set("n", "<S-i>", "<cmd>bnext<cr>", { desc = "Next Buffer" })

View file

@ -0,0 +1,3 @@
-- Options are automatically loaded before lazy.nvim startup
-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua
-- Add any additional options here

View file

@ -0,0 +1,65 @@
return {
"nvimdev/dashboard-nvim",
lazy = false, -- As https://github.com/nvimdev/dashboard-nvim/pull/450, dashboard-nvim shouldn't be lazy-loaded to properly handle stdin.
opts = function()
local logo = [[
Z
Z
z
z
]]
-- logo = string.rep("\n", 8) .. logo .. "\n\n"
local opts = {
theme = "doom",
hide = {
-- this is taken care of by lualine
-- enabling this messes up the actual laststatus setting after loading a file
statusline = false,
},
config = {
header = vim.split(logo, "\n"),
-- stylua: ignore
center = {
{ action = 'lua LazyVim.pick()()', desc = " Find File", icon = "", key = "f" },
{ action = "ene | startinsert", desc = " New File", icon = "", key = "n" },
{ action = 'lua LazyVim.pick("oldfiles")()', desc = " Recent Files", icon = "", key = "r" },
{ action = 'lua LazyVim.pick("live_grep")()', desc = " Find Text", icon = "", key = "g" },
{ action = 'lua LazyVim.pick.config_files()()', desc = " Config", icon = "", key = "c" },
{ action = 'lua require("persistence").load()', desc = " Restore Session", icon = "", key = "s" },
{ action = "LazyExtras", desc = " Lazy Extras", icon = "", key = "x" },
{ action = "Lazy", desc = " Lazy", icon = "󰒲 ", key = "l" },
{ action = function() vim.api.nvim_input("<cmd>qa<cr>") end, desc = " Quit", icon = "", key = "q" },
},
footer = function()
local stats = require("lazy").stats()
local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100)
return { "⚡ Neovim loaded " .. stats.loaded .. "/" .. stats.count .. " plugins in " .. ms .. "ms" }
end,
},
}
for _, button in ipairs(opts.config.center) do
button.desc = button.desc .. string.rep(" ", 43 - #button.desc)
button.key_format = " %s"
end
-- open dashboard after closing lazy
if vim.o.filetype == "lazy" then
vim.api.nvim_create_autocmd("WinClosed", {
pattern = tostring(vim.api.nvim_get_current_win()),
once = true,
callback = function()
vim.schedule(function()
vim.api.nvim_exec_autocmds("UIEnter", { group = "dashboard" })
end)
end,
})
end
return opts
end,
}

View file

@ -0,0 +1,126 @@
return {
"nvim-lualine/lualine.nvim",
event = "VeryLazy",
init = function()
vim.g.lualine_laststatus = vim.o.laststatus
if vim.fn.argc(-1) > 0 then
-- set an empty statusline till lualine loads
vim.o.statusline = " "
else
-- hide the statusline on the starter page
vim.o.laststatus = 0
end
end,
opts = function()
-- PERF: we don't need this lualine require madness 🤷
local lualine_require = require("lualine_require")
lualine_require.require = require
local icons = LazyVim.config.icons
vim.o.laststatus = vim.g.lualine_laststatus
local opts = {
options = {
theme = "auto",
globalstatus = vim.o.laststatus == 3,
disabled_filetypes = { statusline = { "dashboard", "alpha", "ministarter", "snacks_dashboard", "NvimTree_1" } },
},
sections = {
lualine_a = { "mode" },
lualine_b = { "branch" },
lualine_c = {
LazyVim.lualine.root_dir(),
{
"diagnostics",
symbols = {
error = icons.diagnostics.Error,
warn = icons.diagnostics.Warn,
info = icons.diagnostics.Info,
hint = icons.diagnostics.Hint,
},
},
{ "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } },
{ LazyVim.lualine.pretty_path() },
},
lualine_x = {
-- stylua: ignore
{
function() return require("noice").api.status.command.get() end,
cond = function() return package.loaded["noice"] and require("noice").api.status.command.has() end,
color = function() return LazyVim.ui.fg("Statement") end,
},
-- stylua: ignore
{
function() return require("noice").api.status.mode.get() end,
cond = function() return package.loaded["noice"] and require("noice").api.status.mode.has() end,
color = function() return LazyVim.ui.fg("Constant") end,
},
-- stylua: ignore
{
function() return "" .. require("dap").status() end,
cond = function() return package.loaded["dap"] and require("dap").status() ~= "" end,
color = function() return LazyVim.ui.fg("Debug") end,
},
-- stylua: ignore
{
require("lazy.status").updates,
cond = require("lazy.status").has_updates,
color = function() return LazyVim.ui.fg("Special") end,
},
{
"diff",
symbols = {
added = icons.git.added,
modified = icons.git.modified,
removed = icons.git.removed,
},
source = function()
local gitsigns = vim.b.gitsigns_status_dict
if gitsigns then
return {
added = gitsigns.added,
modified = gitsigns.changed,
removed = gitsigns.removed,
}
end
end,
},
},
lualine_y = {
{ "progress", separator = " ", padding = { left = 1, right = 0 } },
{ "location", padding = { left = 0, right = 1 } },
},
lualine_z = {
function()
return "" .. os.date("%R")
end,
},
},
extensions = { "neo-tree", "lazy" },
}
-- do not add trouble symbols if aerial is enabled
-- And allow it to be overriden for some buffer types (see autocmds)
if vim.g.trouble_lualine and LazyVim.has("trouble.nvim") then
local trouble = require("trouble")
local symbols = trouble.statusline({
mode = "symbols",
groups = {},
title = false,
filter = { range = true },
format = "{kind_icon}{symbol.name:Normal}",
hl_group = "lualine_c_normal",
})
table.insert(opts.sections.lualine_c, {
symbols and symbols.get,
cond = function()
return vim.b.trouble_lualine ~= false and symbols.has()
end,
})
end
return opts
end,
}

View file

@ -59,9 +59,20 @@ return {
sources = { "filesystem", "buffers", "git_status" }, sources = { "filesystem", "buffers", "git_status" },
open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", "qf", "Outline" }, open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", "qf", "Outline" },
filesystem = { filesystem = {
hide_dotfiles = false,
hide_hidden = false,
bind_to_cwd = false, bind_to_cwd = false,
follow_current_file = { enabled = true }, follow_current_file = { enabled = true },
use_libuv_file_watcher = true, use_libuv_file_watcher = true,
hide_by_name = {
".git",
"node_modules",
"requirements.txt",
"desktop.ini",
},
never_show = {
".DS_Store",
},
}, },
window = { window = {
mappings = { mappings = {

View file

@ -0,0 +1,11 @@
return {
"nvim-tree/nvim-tree.lua",
version = "*",
lazy = false,
dependencies = {
"nvim-tree/nvim-web-devicons",
},
config = function()
require("nvim-tree").setup({})
end,
}

View file

@ -0,0 +1,22 @@
return {
"epwalsh/obsidian.nvim",
version = "*", -- recommended, use latest release instead of latest commit
lazy = true,
ft = "markdown",
dependencies = {
-- Required.
"nvim-lua/plenary.nvim",
-- see below for full list of optional dependencies 👇
},
opts = {
workspaces = {
{
name = "Obsidian",
path = "/mnt/c/Users/citoy/Obsidian",
},
},
-- see below for full list of options 👇
},
}

View file

@ -0,0 +1,3 @@
indent_type = "Spaces"
indent_width = 2
column_width = 120

BIN
.config/nvim/.DS_Store vendored

Binary file not shown.

View file

@ -0,0 +1,12 @@
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.lua]
indent_type = "Spaces"
indent_width = 2
column_width = 120

1
.config/nvim/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
lazy-lock.json

View file

@ -1,8 +1,20 @@
-- bootstrap lazy.nvim, LazyVim and your plugins --[[
if (vim.g.vscode) then -*- coding: utf-8 -*-
print("VSCode detected, skipping lazy loading") @Filename init.lua
require("vscode.code") @Author js0ny
else @Date 2024-11-27
require("config.lazy") @Description neovim
-- require("config.lazy") ]]
end -- 加载配置
require("config.options")
-- 加载键位映射
require("config.keymaps")
-- 加载插件
require("plugins")
-- 加载主题
require("config.colorscheme")
-- vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })

Binary file not shown.

View file

@ -0,0 +1 @@
vim.cmd.colorscheme("catppuccin")

View file

@ -1,146 +1,128 @@
-- Keymaps are automatically loaded on the VeryLazy event local M = {}
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua local global_default_opts = { noremap = true, silent = true }
-- Add any additional keymaps here local global_default_mode = { "n" }
local mode_arrow = { "n", "v", "o", "s", "x" }
vim.g.mapleader = " " local function set_keymaps(maps, default_opts, default_mode)
for _, map in ipairs(maps) do
local opts = vim.tbl_extend("force", default_opts, map.opts or {})
local mode = map.mode or global_default_mode
vim.keymap.set(mode, map.keys, map.cmd, opts)
end
end
-- ================= GENERAL KEYBINDS =================
-- SAVE/QUIT {{{
vim.keymap.set("n", "Q", "<cmd>q<CR>", { desc = "Q to quit" })
vim.keymap.set("n", "<C-s>", "<cmd>w<CR>", { desc = "S to write file" })
--}}}
-- NVIM CONFIG SHORTCUTS {{{
-- stylua: ignore
vim.keymap.set("n", "<leader>rc", "<cmd>e $HOME/.config/nvim/lua/config/options.lua<CR>", { desc = "Open nvim options.lua" })
vim.keymap.set("n", "<leader>rp", "<cmd>e $HOME/.config/nvim/lua/plugins/.<CR>", { desc = "lazy plugins dir" })
--}}}
-- UNDO local keymaps_basic = { -- Modification of Original Keymap - Colemak
vim.keymap.set({ "n", "v" }, "l", "u", { desc = "Undo" }) { mode = mode_arrow, keys = "n", cmd = "j" },
{ mode = mode_arrow, keys = "e", cmd = "k" },
{ mode = mode_arrow, keys = "i", cmd = "l" },
{ keys = "N", cmd = "J" },
{ keys = "E", cmd = "K" },
{ keys = "I", cmd = "L" },
{ keys = "l", cmd = "i" },
{ keys = "L", cmd = "I" },
{ keys = "k", cmd = "n" },
{ keys = "K", cmd = "N" },
{ keys = "j", cmd = "e" },
{ keys = "J", cmd = "E" },
{ keys = "Y", cmd = "y$"},
}
-- INSERT local keymaps_lsp = {
vim.keymap.set({ "n", "v" }, "l", "i", { desc = "Insert" }) }
vim.keymap.set({ "n", "v" }, "L", "I", { desc = "Insert at line start" })
-- YANK TO SYSTEM CLIPBOARD local keymaps_nvim_tree_general = {
vim.keymap.set("v", "Y", '"+y', { desc = "Copy to (System) Clipboard" }) { mode = "n", keys = "<leader>e", cmd = ":NvimTreeToggle<CR>" },
}
-- SEARCH {{{ set_keymaps(keymaps_basic, global_default_opts, global_default_mode)
vim.keymap.set("n", "<LEADER><CR>", "<CMD>nohlsearch<CR>", { desc = "clear search highlight" }) set_keymaps(keymaps_lsp, global_default_opts, global_default_mode)
--}}} set_keymaps(keymaps_nvim_tree_general, global_default_opts, global_default_mode)
-- SPACE TO TAB{{{ function M.nvim_tree_keymaps(api, opts)
vim.keymap.set("n", "<LEADER>tt", "<CMD>%s/ /\t/g<CR>", { desc = "space to tab" }) -- mode is set to "n" by default, in `./lua/plugins/nvim-tree.lua`
vim.keymap.set("v", "<LEADER>tt", "<CMD>s/ /\t/g<CR>", { desc = "space to tab" }) return {
--}}} -- Toggle
{ keys = "<leader>e", cmd = ":NvimTreeToggle<CR>", opts = opts("Toggle") },
-- Arrow 箭头 hnei
{ keys = "h", cmd = api.node.navigate.parent_close, opts = opts("Close node") },
{ keys = "i", cmd = api.node.open.edit, opts = opts("Open") },
{ keys = "H", cmd = api.tree.toggle_hidden_filter, opts = opts("Toggle Dotfiles") },
{ keys = "N", cmd = api.node.navigate.sibling.next, opts = opts("Next Sibling") },
{ keys = "E", cmd = api.node.navigate.sibling.prev, opts = opts("Previous Sibling") },
{ keys = "I", cmd = api.tree.toggle_gitignore_filter, opts = opts("Toggle GitIgnored") },
-- CONTROL KEYS 控制键
{ keys = "<BS>", cmd = api.node.navigate.parent_close, opts = opts("Close node") },
{ keys = "<CR>", cmd = api.node.open.edit, opts = opts("Open") },
{ keys = "<Tab>", cmd = api.node.open.preview, opts = opts("Open Preview") },
-- Alpha 字母键
{ keys = "a", cmd = api.fs.create, opts = opts("Create") },
{ keys = "A", cmd = api.fs.create, opts = opts("Create") },
{ keys = "bd", cmd = api.marks.bulk.delete, opts = opts("Delete Bookmarked") },
{ keys = "bt", cmd = api.marks.bulk.trash, opts = opts("Trash Bookmarked") },
{ keys = "bmv", cmd = api.marks.bulk.move, opts = opts("Move Bookmarked") },
{ keys = "B", cmd = api.tree.toggle_no_buffer_filter, opts = opts("Toggle Filter: No Buffer") },
{ keys = "c", cmd = api.fs.copy.node, opts = opts("Copy") },
{ keys = "C", cmd = api.fs.copy.filename, opts = opts("Copy") },
{ keys = "d", cmd = api.fs.remove, opts = opts("Delete") },
{ keys = "D", cmd = api.fs.trash, opts = opts("Trash") },
{ keys = "]e", cmd = api.node.navigate.diagnostics.next, opts = opts("Next Diagnostic") },
{ keys = "[e", cmd = api.node.navigate.diagnostics.prev, opts = opts("Prev Diagnostic") },
{ keys = "F", cmd = api.live_filter.clear, opts = opts("Live Filter: Clear") },
{ keys = "f", cmd = api.live_filter.start, opts = opts("Live Filter: Start") },
{ keys = "[g", cmd = api.node.navigate.git.prev, opts = opts("Prev Git") },
{ keys = "]g", cmd = api.node.navigate.git.next, opts = opts("Next Git") },
{ keys = "L", cmd = api.node.open.toggle_group_empty, opts = opts("Toggle Group Empty") },
{ keys = "M", cmd = api.tree.toggle_no_bookmark_filter, opts = opts("Toggle Filter: No Bookmark") },
{ keys = "m", cmd = api.marks.toggle, opts = opts("Toggle Bookmark") },
{ keys = "o", cmd = api.node.open.edit, opts = opts("Open") },
{ keys = "O", cmd = api.node.open.no_window_picker, opts = opts("Open: No Window Picker") },
{ keys = "p", cmd = api.fs.paste, opts = opts("Paste") },
{ keys = "P", cmd = api.node.navigate.parent, opts = opts("Parent Directory") },
{ keys = "q", cmd = api.tree.close, opts = opts("Close") },
{ keys = "r", cmd = api.fs.rename, opts = opts("Rename") },
{ keys = "R", cmd = api.tree.reload, opts = opts("Refresh") },
{ keys = "s", cmd = api.node.run.system, opts = opts("Run System") },
{ keys = "S", cmd = api.tree.search_node, opts = opts("Search") },
{ keys = "u", cmd = api.fs.rename_full, opts = opts("Rename: Full Path") },
{ keys = "U", cmd = api.tree.toggle_custom_filter, opts = opts("Toggle Filter: Hidden") },
{ keys = "W", cmd = api.tree.collapse_all, opts = opts("Collapse") },
{ keys = "x", cmd = api.fs.cut, opts = opts("Cut") },
{ keys = "y", cmd = api.fs.copy.relative_path, opts = opts("Copy Relative Path") },
{ keys = "Y", cmd = api.fs.copy.absolute_path, opts = opts("Copy Absolute Path") },
-- Numeric 数字键
{ keys = "!", cmd = api.node.run.cmd, opts = opts("Run Command") },
-- Non-Alphanumeric 非字母数字键
{ keys = "?", cmd = api.tree.toggle_help, opts = opts("Help") },
{ keys = ">", cmd = api.node.navigate.sibling.next, opts = opts("Next Sibling") },
{ keys = "<", cmd = api.node.navigate.sibling.prev, opts = opts("Previous Sibling") },
{ keys = ".", cmd = api.node.run.cmd, opts = opts("Run Command") },
{ keys = ";", cmd = api.node.run.cmd, opts = opts("Run Command") },
{ keys = "-", cmd = api.tree.change_root_to_parent, opts = opts("Up") },
-- MOD KEYS Ctrl+
{ keys = "<C-]>", cmd = api.tree.change_root_to_node, opts = opts("CD") },
{ keys = "<C-e>", cmd = api.node.open.replace_tree_buffer, opts = opts("Open: In Place") },
{ keys = "<C-k>", cmd = api.node.show_info_popup, opts = opts("Info") },
{ keys = "<C-r>", cmd = api.fs.rename_sub, opts = opts("Rename: Omit Filename") },
{ keys = "<C-t>", cmd = api.node.open.tab, opts = opts("Open: New Tab") },
{ keys = "<C-v>", cmd = api.node.open.vertical, opts = opts("Open: Vertical Split") },
{ keys = "<C-h>", cmd = api.node.open.horizontal, opts = opts("Open: Horizontal Split") },
-- Mouse 鼠标键
{ keys = "<2-LeftMouse>", cmd = api.node.open.edit, opts = opts("Open") },
{ keys = "<2-RightMouse>",cmd = api.tree.change_root_to_node, opts = opts("CD") },
}
end
-- MISC {{{ --- `map` default for `cmp.mapping`
vim.keymap.set("n", "<LEADER>o", "za", { desc = "folding" }) function M.cmp_nvim_keymaps(map)
vim.keymap.set("i", "<C-y>", "<ESC>A {}<ESC>i<CR><ESC>ko", { desc = "insert a pair of {} and goto next line" }) return {
--}}} { keys = "<C-n>", cmd = map.select_next_item(), desc = "Select next completion item" },
{ keys = "<C-p>", cmd = map.select_prev_item(), desc = "Select previous completion item" },
{ keys = "<C-y>", cmd = map.confirm({ select = true }), desc = "Confirm completion" },
{ keys = "<C-Space>", cmd = map.complete(), desc = "Trigger completion" },
{ keys = "<C-e>", cmd = map.abort(), desc = "Abort completion" },
}
end
-- ================= CURSOR MOVEMENT ===================== {{{ return M
-- NEW CURSOR MOVEMENT (ARROW KEY RESIZE WINDOWS)
-- ^
-- e
-- < h i >
-- n
-- v
--
vim.keymap.set({ "n", "v", "", "s", "x" }, "e", "k", { desc = "move cursor ⇧" })
vim.keymap.set({ "n", "v", "", "s", "x" }, "n", "j", { desc = "move cursor ⇩" })
vim.keymap.set({ "n", "v", "", "s", "x" }, "h", "h", { desc = "move cursor ⇦" })
vim.keymap.set({ "n", "v", "", "s", "x" }, "i", "l", { desc = "move cursor ⇨" })
vim.keymap.set({ "n", "v" }, "E", "5k", { desc = "Move 5up K -> U" })
vim.keymap.set({ "n", "v" }, "N", "5j", { desc = "Move 5down J -> E" })
vim.keymap.set({ "n", "v" }, "H", "0", { desc = "Move start of line" })
vim.keymap.set({ "n", "v" }, "I", "$", { desc = "Move end of line" })
vim.keymap.set("n", "gu", "gk", { desc = "move up gk -> gu" })
vim.keymap.set("n", "ge", "gj", { desc = "move down gj -> ge" })
vim.keymap.set("n", "\v", "v$h", { desc = "???" })
-- FASTER IN-LINE NAVIGATION
-- SET h (SAME AS n, CURSOR LEFT) TO 'END OF WORD'
vim.keymap.set("n", "j", "e", { desc = "Move cursor to end of word" })
-- CTRL + U OR E WILL MOVE UP/DOWN THE VIEW PORT WITHOUT MOVING THE CURSOR
vim.keymap.set({ "n", "v" }, "<C-e>", "5<C-y>", { desc = "Move viewport ⇧" })
vim.keymap.set({ "n", "v" }, "<C-n>", "5<C-e>", { desc = "Move viewport ⇩" })
-- INSERT MODE CURSOR MOVEMENT
vim.keymap.set("i", "<C-a>", "<ESC>A")
-- COMMAND MODE CURSOR MOVEMENT
vim.keymap.set("c", "<C-a>", "<Home>")
vim.keymap.set("c", "<C-e>", "<End>")
vim.keymap.set("c", "<C-p>", "<Up>")
vim.keymap.set("c", "<C-n>", "<Down>")
vim.keymap.set("c", "<C-b>", "<Left>")
vim.keymap.set("c", "<C-f>", "<Right>")
vim.keymap.set("c", "<M-b>", "<S-Left>")
vim.keymap.set("c", "<M-w>", "<S-Right>")
--}}}
-- ================= SPLIT MANAGMENT ===================== {{{
vim.keymap.set("n", "<C-w>E", "<CMD>set nosplitbelow<CR><CMD>split<CR><CMD>set splitbelow<CR>", { desc = "Split ⇧" })
vim.keymap.set("n", "<C-w>N", "<CMD>set splitbelow<CR><CMD>split<CR>", { desc = "Split ⇩" })
vim.keymap.set("n", "<C-w>H", "<CMD>set nosplitright<CR><CMD>vsplit<CR><CMD>set splitright<CR>", { desc = "Split ⇦" })
vim.keymap.set("n", "<C-w>I", "<CMD>set splitright<CR><CMD>vsplit<CR>", { desc = "Split ⇨" })
vim.keymap.set({ "n", "t" }, "<C-w>e", "<C-w>k", { desc = "Move cursor to split ⇧" })
vim.keymap.set({ "n", "t" }, "<C-w>n", "<C-w>j", { desc = "Move cursor to split ⇩" })
vim.keymap.set({ "n", "t" }, "<C-w>h", "<C-w>h", { desc = "Move cursor to split ⇦" })
vim.keymap.set({ "n", "t" }, "<C-w>i", "<C-w>l", { desc = "Move cursor to split ⇨" })
vim.keymap.set({ "n", "t" }, "<C-e>", "<C-k>", { desc = "Move cursor to split ⇧" })
vim.keymap.set({ "n", "t" }, "<C-n>", "<C-j>", { desc = "Move cursor to split ⇩" })
vim.keymap.set({ "n", "t" }, "<C-h>", "<C-h>", { desc = "Move cursor to split ⇦" })
vim.keymap.set({ "n", "t" }, "<C-i>", "<C-l>", { desc = "Move cursor to split ⇨" })
vim.keymap.set("n", "<up>", "<CMD>res -5<CR>", { desc = "Resize split 0,-5" })
vim.keymap.set("n", "<down>", "<CMD>res +5<CR>", { desc = "Resize split 0,+5" })
vim.keymap.set("n", "<left>", "<CMD>vertical resize +5<CR>", { desc = "Resize split +5,0" })
vim.keymap.set("n", "<right>", "<CMD>vertical resize -5<CR>", { desc = "Resize split -5,0" })
vim.keymap.set("n", "<C-w>H", "<C-w>t<C-w>K", { desc = "Make splits [H]orizontal" })
vim.keymap.set("n", "<C-w>V", "<C-w>t<C-w>H", { desc = "Make splits [V]ertical" })
vim.keymap.set("n", "<C-w>ri", "<C-w>b<C-w>K", { desc = "Rotate splits 90" })
vim.keymap.set("n", "<C-w>rh", "<C-w>b<C-w>H", { desc = "Rotate splits -90" })
vim.keymap.set("n", "<LEADER>q", "<C-w>j<CMD>q<CR>", { desc = "Close Split ⇩ (Below)" })
--}}}
-- TAB MANAGEMENT {{{
vim.keymap.set("n", "<TAB><TAB>", "<CMD>tabe<CR>", { desc = "New [Tab]" })
vim.keymap.set("n", "<TAB>h", "<CMD>-tabnext<CR>", { desc = "Select Tab ⇦" })
vim.keymap.set("n", "<TAB>i", "<CMD>+tabnext<CR>", { desc = "Select Tab ⇨" })
vim.keymap.set("n", "<TAB>H", "<CMD>-tabmove<CR>", { desc = "Tab move ⇦" })
vim.keymap.set("n", "<TAB>I", "<CMD>+tabmove<CR>", { desc = "Tab move ⇨" })
-- NOTE: Doesn't seem to work:
-- vim.keymap.set("n", "<TAB>c", "<CMD>tab split<CR>", { desc = "New Tab from [C]urrent" })
-- vim.keymap.set('n', '<LEADER>dw', '/\(\<\w\+\>\)\_s*\1', {desc='adjacent duplicate words'})
--vim.keymap.del("n", "<C-w>j")
--vim.keymap.del("n", "<C-w>k")
--vim.keymap.del("n", "<C-w>l")
-- }}}
-- =================== TERM BEHAVIORS ====================
vim.keymap.set("t", "<C-n>", "<C-\\><C-n>", { desc = "escape terminal, allowing excmds" })
vim.keymap.set("t", "<C-o>", "<C-\\><C-n><C-o>", { desc = "close terminal" })
--vim: set fdm=marker fdl=0
-- buffers
vim.keymap.set("n", "<S-h>", "<cmd>bprevious<cr>", { desc = "Prev Buffer" })
vim.keymap.set("n", "<S-i>", "<cmd>bnext<cr>", { desc = "Next Buffer" })

View file

@ -1,3 +1,50 @@
-- Options are automatically loaded before lazy.nvim startup -- <leader> is space
-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua vim.g.mapleader = " "
-- Add any additional options here vim.g.maplocalleader = "\\"
-- Disable netrw
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
-- Disable Perl
vim.g.loaded_perl_provider = 0 -- Don't load Perl
vim.g.autoformat = true
local opt = vim.opt
-- Clipboard
opt.clipboard = vim.env.SSH_TTY and "" or "unnamedplus"
-- Line number
opt.number = true
opt.relativenumber = true
opt.confirm = true
-- Word wrap
opt.linebreak = true
-- Indentation
opt.expandtab = true
opt.shiftwidth = 4
opt.shiftround = true
-- Case
opt.ignorecase = true
opt.smartcase = true
opt.cursorline = true
-- Terminal GUI
opt.termguicolors = true
-- Fold
opt.foldlevel = 99
opt.foldmethod = "expr"
-- Statusline
opt.laststatus = 0
-- Hide Command Line if empty
opt.cmdheight = 0
-- Scroll
opt.scrolloff = 5
opt.sidescrolloff = 10

View file

@ -0,0 +1,22 @@
--- Available LSP goes here
--- Check https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md
--- for available server and name
local servers = {
"arduino_language_server", -- Arduino
"bashls", -- Bash
"clangd", -- C/C++
"cmake", -- CMake
"eslint", -- JavaScript
"gopls", -- Go
"html", -- HTML
"julials", -- Julia
"lua_ls", -- Lua
"omnisharp", -- C# & F#
"powershell_es", -- PowerShell
"pyright", -- Python
"rust_analyzer", -- Rust
"taplo", -- TOML
"vimls", -- vimscript
}
return servers

View file

@ -0,0 +1,12 @@
return {
{ "catppuccin/nvim", name = "catppuccin" },
{
'nvim-lualine/lualine.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons' },
config = function()
require("plugins.mod.lualine")
end,
},
{ import = "plugins.mod.alpha-nvim" },
}

View file

@ -0,0 +1,8 @@
return {
{ import = "plugins.mod.nvim-cmp" },
{
"L3MON4D3/LuaSnip",
dependencies = { "rafamadriz/friendly-snippets" },
},
{ "rafamadriz/friendly-snippets" }
}

View file

@ -1,68 +0,0 @@
return {
{
"nvimdev/dashboard-nvim",
lazy = false, -- As https://github.com/nvimdev/dashboard-nvim/pull/450, dashboard-nvim shouldn't be lazy-loaded to properly handle stdin.
opts = function()
local logo = [[
]]
logo = string.rep("\n", 8) .. logo .. "\n\n"
local opts = {
theme = "doom",
hide = {
-- this is taken care of by lualine
-- enabling this messes up the actual laststatus setting after loading a file
statusline = false,
},
config = {
header = vim.split(logo, "\n"),
-- stylua: ignore
center = {
{ action = 'lua LazyVim.pick()()', desc = " Find File", icon = "", key = "f" },
{ action = 'lua LazyVim.pick("oldfiles")()', desc = " Recent Files", icon = "", key = "r" },
{ action = 'lua LazyVim.pick("live_grep")()', desc = " Find Text", icon = "", key = "g" },
{ action = 'lua LazyVim.pick.config_files()()', desc = " Config", icon = "", key = "c" },
{ action = 'lua require("persistence").load()', desc = " Restore Session", icon = "", key = "s" },
{ action = "LazyExtras", desc = " Lazy Extras", icon = "", key = "x" },
{ action = "Lazy", desc = " Lazy", icon = "󰒲 ", key = "l" },
{ action = function() vim.api.nvim_input("<cmd>qa<cr>") end, desc = " Quit", icon = "", key = "q" },
},
footer = function()
local stats = require("lazy").stats()
local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100)
return {
"⚡ Neovim loaded " .. stats.loaded .. "/" .. stats.count .. " plugins in " .. ms .. "ms",
}
end,
},
}
for _, button in ipairs(opts.config.center) do
button.desc = button.desc .. string.rep(" ", 43 - #button.desc)
button.key_format = " %s"
end
-- open dashboard after closing lazy
if vim.o.filetype == "lazy" then
vim.api.nvim_create_autocmd("WinClosed", {
pattern = tostring(vim.api.nvim_get_current_win()),
once = true,
callback = function()
vim.schedule(function()
vim.api.nvim_exec_autocmds("UIEnter", { group = "dashboard" })
end)
end,
})
end
return opts
end,
},
}

View file

@ -0,0 +1,5 @@
return {
{ import = "plugins.mod.auto-session" },
{ import = "plugins.mod.nvim-tree" },
{ "nvim-telescope/telescope.nvim", dependencies = { "nvim-lua/plenary.nvim" } },
}

View file

@ -0,0 +1,22 @@
-- Entry point of the plugin manager
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable",
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
{ import = "plugins.appearance" },
{ import = "plugins.completion" },
{ import = "plugins.fileutils" },
{ import = "plugins.lsp" },
{ import = "plugins.syntax" },
{ import = "plugins.misc" },
})

View file

@ -0,0 +1,21 @@
return {
{ import = "plugins.mod.lspconfig" },
{ "williamboman/mason.nvim", config = true },
{
"williamboman/mason-lspconfig.nvim",
lazy = false,
dependencies = {
{ "williamboman/mason.nvim" },
{ "neovim/nvim-lspconfig" },
},
config = function()
local mason_lspconfig = require("mason-lspconfig")
local servers = require("config.servers")
mason_lspconfig.setup({
ensure_installed = servers,
})
end
},
}

View file

@ -0,0 +1,22 @@
return {
{ 'wakatime/vim-wakatime', lazy = false },
{ 'epwalsh/obsidian.nvim', lazy = true },
{
"folke/which-key.nvim",
event = "VeryLazy",
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
},
keys = {
{
"<leader>?",
function()
require("which-key").show({ global = false })
end,
desc = "Buffer Local Keymaps (which-key)",
},
},
}
}

View file

@ -0,0 +1,59 @@
-- alpha-nvim.lua
return {
{
'goolord/alpha-nvim',
dependencies = {
-- 'echasnovski/mini.icons',
-- 'nvim-lua/plenary.nvim'
},
config = function ()
local alpha = require'alpha'
local dashboard = require'alpha.themes.dashboard'
dashboard.section.header.val = {
" ",
"================= =============== =============== ======== ========",
"\\\\ . . . . . . .\\\\ //. . . . . . .\\\\ //. . . . . . .\\\\ \\\\. . .\\\\// . . //",
"||. . ._____. . .|| ||. . ._____. . .|| ||. . ._____. . .|| || . . .\\/ . . .||",
"|| . .|| ||. . || || . .|| ||. . || || . .|| ||. . || ||. . . . . . . ||",
"||. . || || . .|| ||. . || || . .|| ||. . || || . .|| || . | . . . . .||",
"|| . .|| ||. _-|| ||-_ .|| ||. . || || . .|| ||. _-|| ||-_.|\\ . . . . ||",
"||. . || ||-' || || `-|| || . .|| ||. . || ||-' || || `|\\_ . .|. .||",
"|| . _|| || || || || ||_ . || || . _|| || || || |\\ `-_/| . ||",
"||_-' || .|/ || || \\|. || `-_|| ||_-' || .|/ || || | \\ / |-_.||",
"|| ||_-' || || `-_|| || || ||_-' || || | \\ / | `||",
"|| `' || || `' || || `' || || | \\ / | ||",
"|| .===' `===. .==='.`===. .===' /==. | \\/ | ||",
"|| .==' \\_|-_ `===. .===' _|_ `===. .===' _-|/ `== \\/ | ||",
"|| .==' _-' `-_ `=' _-' `-_ `=' _-' `-_ /| \\/ | ||",
"|| .==' _-' `-__\\._-' `-_./__-' `' |. /| | ||",
"||.==' _-' `' | /==.||",
"==' _-' j s 0 n y N E O V I M \\/ `==",
"\\ _-' `-_ /",
" `'' ``' ",
}
dashboard.section.buttons.val.leader = "SPC"
dashboard.section.buttons.val = {
-- leader = "SPC",
dashboard.button('c', ' 新建文件', ':enew<CR>'),
dashboard.button('SPC f f', '󰈞 查找文件', ':Telescope find_files<CR>'),
dashboard.button('SPC f h', ' 历史文件', ':Telescope oldfiles<CR>'),
dashboard.button('SPC s l', ' 加载会话', ':SessionSearch<CR>'), -- 加载会话
dashboard.button('SPC q', '󱊷 退出', ':qa<CR>'),
}
local handle = io.popen('fortune')
--- Handle the case where fortune is not installed
local fortune = ""
if handle then
fortune = handle:read("*a")
handle:close()
end
dashboard.section.footer.val = "今日 " .. os.date("%Y-%m-%d %A") .. " " .. fortune
dashboard.config.opts.noautocmd = true
-- vim.cmd[[autocmd User AlphaReady echo 'Alpha ready!']]
alpha.setup(dashboard.config)
end
};
}

View file

@ -0,0 +1,15 @@
---@diagnostic disable: undefined-doc-name
return {
{
'rmagatti/auto-session',
lazy = false,
---enables autocomplete for opts
---@module "auto-session"
---@type AutoSession.Config
opts = {
suppressed_dirs = { '~/', '~/Projects', '~/Downloads', '/' },
-- log_level = 'debug',
}
}
}

View file

@ -0,0 +1,4 @@
return {
"neovim/nvim-lspconfig",
lazy = false
}

View file

@ -0,0 +1,223 @@
-- Author: shadmansaleh
-- Credit: glepnir
local lualine = require('lualine')
-- Color table for highlights
-- stylua: ignore
local colors = {
bg = '#202328',
fg = '#bbc2cf',
yellow = '#ECBE7B',
cyan = '#008080',
darkblue = '#081633',
green = '#98be65',
orange = '#FF8800',
violet = '#a9a1e1',
magenta = '#c678dd',
blue = '#51afef',
red = '#ec5f67',
}
local conditions = {
buffer_not_empty = function()
return vim.fn.empty(vim.fn.expand('%:t')) ~= 1
end,
hide_in_width = function()
return vim.fn.winwidth(0) > 80
end,
check_git_workspace = function()
local filepath = vim.fn.expand('%:p:h')
local gitdir = vim.fn.finddir('.git', filepath .. ';')
return gitdir and #gitdir > 0 and #gitdir < #filepath
end,
}
-- Config
local config = {
options = {
disabled_filetypes = {
statusline = { "NvimTree", "alpha" }
},
-- Disable sections and component separators
component_separators = '',
section_separators = '',
theme = {
-- We are going to use lualine_c an lualine_x as left and
-- right section. Both are highlighted by c theme . So we
-- are just setting default looks o statusline
normal = { c = { fg = colors.fg, bg = colors.bg } },
inactive = { c = { fg = colors.fg, bg = colors.bg } },
},
},
sections = {
-- these are to remove the defaults
lualine_a = {},
lualine_b = {},
lualine_y = {},
lualine_z = {},
-- These will be filled later
lualine_c = {},
lualine_x = {},
},
inactive_sections = {
-- these are to remove the defaults
lualine_a = {},
lualine_b = {},
lualine_y = {},
lualine_z = {},
lualine_c = {},
lualine_x = {},
},
}
-- Inserts a component in lualine_c at left section
local function ins_left(component)
table.insert(config.sections.lualine_c, component)
end
-- Inserts a component in lualine_x at right section
local function ins_right(component)
table.insert(config.sections.lualine_x, component)
end
ins_left {
function()
return ''
end,
color = { fg = colors.blue }, -- Sets highlighting of component
padding = { left = 0, right = 1 }, -- We don't need space before this
}
ins_left {
-- mode component
function()
return ''
end,
color = function()
-- auto change color according to neovims mode
local mode_color = {
n = colors.red,
i = colors.green,
v = colors.blue,
[''] = colors.blue,
V = colors.blue,
c = colors.magenta,
no = colors.red,
s = colors.orange,
S = colors.orange,
[''] = colors.orange,
ic = colors.yellow,
R = colors.violet,
Rv = colors.violet,
cv = colors.red,
ce = colors.red,
r = colors.cyan,
rm = colors.cyan,
['r?'] = colors.cyan,
['!'] = colors.red,
t = colors.red,
}
return { fg = mode_color[vim.fn.mode()] }
end,
padding = { right = 1 },
}
ins_left {
-- filesize component
'filesize',
cond = conditions.buffer_not_empty,
}
ins_left {
'filename',
cond = conditions.buffer_not_empty,
color = { fg = colors.magenta, gui = 'bold' },
}
ins_left { 'location' }
ins_left { 'progress', color = { fg = colors.fg, gui = 'bold' } }
ins_left {
'diagnostics',
sources = { 'nvim_diagnostic' },
symbols = { error = '', warn = '', info = '' },
diagnostics_color = {
error = { fg = colors.red },
warn = { fg = colors.yellow },
info = { fg = colors.cyan },
},
}
-- Insert mid section. You can make any number of sections in neovim :)
-- for lualine it's any number greater then 2
ins_left {
function()
return '%='
end,
}
ins_left {
-- Lsp server name .
function()
local msg = 'No Active Lsp'
local buf_ft = vim.api.nvim_get_option_value('filetype', { buf = 0 })
local clients = vim.lsp.get_clients()
if next(clients) == nil then
return msg
end
for _, client in ipairs(clients) do
local filetypes = client.config.filetypes
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
return client.name
end
end
return msg
end,
icon = ' LSP:',
color = { fg = '#ffffff', gui = 'bold' },
}
-- Add components to right sections
ins_right {
'o:encoding', -- option component same as &encoding in viml
fmt = string.upper, -- I'm not sure why it's upper case either ;)
cond = conditions.hide_in_width,
color = { fg = colors.green, gui = 'bold' },
}
ins_right {
'fileformat',
fmt = string.upper,
icons_enabled = false, -- I think icons are cool but Eviline doesn't have them. sigh
color = { fg = colors.green, gui = 'bold' },
}
ins_right {
'branch',
icon = '',
color = { fg = colors.violet, gui = 'bold' },
}
ins_right {
'diff',
-- Is it me or the symbol for modified us really weird
symbols = { added = '', modified = '󰝤 ', removed = '' },
diff_color = {
added = { fg = colors.green },
modified = { fg = colors.orange },
removed = { fg = colors.red },
},
cond = conditions.hide_in_width,
}
ins_right {
function()
return ''
end,
color = { fg = colors.blue },
padding = { left = 1 },
}
-- Now don't forget to initialize lualine
lualine.setup(config)

View file

@ -0,0 +1,71 @@
--- Available LSP goes here
--- Check https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md
--- for available server and name
return {
"hrsh7th/nvim-cmp",
lazy = false,
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
},
config = function()
local cmp = require("cmp")
local lspconfig = require("lspconfig")
local capabitilies = require("cmp_nvim_lsp").default_capabilities()
local servers = require("config.servers")
cmp.setup({
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
sources = cmp.config.sources(
-- This order defines the priority of sources.
{
{ name = "nvim_lsp" },
{ name = "luasnip" },
},
{
{ name = "buffer" },
{ name = "path" },
}
),
})
local keymaps = require("config.keymaps")
local keymaps_cmp = keymaps.cmp_nvim_keymaps(cmp.mapping)
local function set_keymaps()
local mappings = {}
for _, map in ipairs(keymaps_cmp) do
mappings[map.keys] = map.cmd
end
return mappings
end
cmp.setup.mapping = cmp.mapping.preset.insert(set_keymaps())
cmp.setup.cmdline(":", {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = "cmdline" },
-- Use `path` is slow under WSL since WSL loads Windows paths
-- https://github.com/zsh-users/zsh-syntax-highlighting/issues/790
-- { name = "path" },
}
})
for _, server in ipairs(servers) do
lspconfig[server].setup({
capabilities = capabitilies,
})
end
end,
}

View file

@ -0,0 +1,41 @@
local function my_on_attach(bufnr)
-- local keymaps = require("config.keymaps")
local api = require "nvim-tree.api"
local default_mode = { "n" }
local keymaps = require("config.keymaps")
local function opts(desc)
return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
end
local function set_keymaps(maps)
for _, map in ipairs(maps) do
local mode = map.mode or default_mode
vim.keymap.set(mode, map.keys, map.cmd, map.opts)
end
end
local raw_keymaps = keymaps.nvim_tree_keymaps(api, opts)
set_keymaps(raw_keymaps)
end
return {
"nvim-tree/nvim-tree.lua",
version = "*",
lazy = false,
dependencies = {
"nvim-tree/nvim-web-devicons",
},
config = function()
require("nvim-tree").setup {
on_attach = my_on_attach,
sync_root_with_cwd = true,
respect_buf_cwd = true,
update_focused_file = {
enable = true,
update_cwd = true,
},
}
end
}

View file

@ -0,0 +1,6 @@
return {
{
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
},
}

View file

@ -1,40 +0,0 @@
local keymap = vim.keymap.set
vim.g.mapleader = " "
vim.keymap.set({ "n", "v", "", "s", "x" }, "e", "k", { desc = "move cursor ⇧" })
vim.keymap.set({ "n", "v", "", "s", "x" }, "n", "j", { desc = "move cursor ⇩" })
vim.keymap.set({ "n", "v", "", "s", "x" }, "h", "h", { desc = "move cursor ⇦" })
vim.keymap.set({ "n", "v", "", "s", "x" }, "i", "l", { desc = "move cursor ⇨" })
vim.keymap.set({ "n", "v", "", "s", "x" }, "N", "J", { desc = "Insert at the line start" })
vim.keymap.set({ "n", "v", "", "s", "x" }, "E", "K", { desc = "Insert at the line start" })
vim.keymap.set({ "n", "v", "", "s", "x" }, "I", "L", { desc = "Insert at the line start" })
vim.keymap.set({ "n", "v", "", "s", "x" }, "l", "i", { desc = "Insert mode" })
vim.keymap.set({ "n", "v", "", "s", "x" }, "L", "I", { desc = "Insert at the line start" })
vim.keymap.set({ "n", "v", "", "s", "x" }, "k", "n", { desc = "Insert at the line start" })
vim.keymap.set({ "n", "v", "", "s", "x" }, "K", "N", { desc = "Insert at the line start" })
vim.keymap.set({ "n", "v", "", "s", "x" }, "j", "e", { desc = "Insert at the line start" })
vim.keymap.set({ "n", "v", "", "s", "x" }, "J", "E", { desc = "Insert at the line start" })
vim.opt.clipboard = "unnamedplus"
vim.opt.expandtab = true
vim.opt.tabstop = 5
vim.opt.shiftwidth = 4
vim.opt.autoindent = true
vim.opt.smartindent = true
vim.opt.wrap = true
vim.opt.scrolloff = 3
vim.opt.hlsearch = true
vim.opt.incsearch = true
vim.opt.ignorecase = true
vim.opt.smartcase = true
vim.opt.number = true
vim.opt.relativenumber = true
-- VSCode commands
keymap({ "n", "v" }, "<leader>pp", "<cmd>lua require('vscode').action('workbench.view.extension.project-manager')<CR>")
keymap({ "n", "v" }, "<leader>pP", "<cmd>lua require('vscode').action('projectManager.listProjects')<CR>")

View file

@ -1,3 +1,5 @@
indent_type = "Spaces" indent_type = "Spaces"
indent_width = 2 indent_width = 2
column_width = 120 column_width = 120
[sort_requires]
enabled = true

19
.config/readline/inputrc Normal file
View file

@ -0,0 +1,19 @@
# $XDG_CONFIG_HOME/readline/inputrc
# Colemak Key Remaps
set editing-mode vi
set keymap vi
set show-mode-in-prompt on
set mark-directories on
set completion-ignore-case on
set show-all-if-ambiguous on
set bell-style none
$if mode=vi
"n": next-history
"e": previous-history
"l": vi-insertion-mode
"L": vi-insert-beg
"i": forward-char
$endif

View file

@ -49,7 +49,7 @@ bind -r N resize-pane -D 5
bind -r E resize-pane -U 5 bind -r E resize-pane -U 5
bind -r I resize-pane -R 5 bind -r I resize-pane -R 5
bind C-h select-window -t :- bind C-h select-window -t :-
bind C-l select-window -t :+ bind C-i select-window -t :+
bind ` resize-pane -Z bind ` resize-pane -Z
# Status Bar # Status Bar

View file

@ -40,6 +40,11 @@ set smartcase
set number set number
set relativenumber set relativenumber
set laststatus=2
set showcmd
set statusline=%<%f\ %h%m%r\ %=\ [%l,%v]\ [%p%%]\ [\ %Y]\ [󱑉\ %{strftime('%H:%M:%S')}]
" XDG Directory Specifications " XDG Directory Specifications
" Reference to https://jorenar.com/blog/vim-xdg " Reference to https://jorenar.com/blog/vim-xdg

View file

@ -1,18 +1,16 @@
# Append to original bashrc for minimal setup # Append to original bashrc for minimal setup
# echo $DOTFILES/wsl/.bashrc >> ~/.bashrc # echo $DOTFILES/wsl/.bashrc >> ~/.bashrc
bind 'set show-mode-in-prompt on'
set -o vi set -o vi
bind '"\en": "\C-j"' bind -m vi-command '"n": next-history'
bind '"\ee": "\C-k"' bind -m vi-command '"e": previous-history'
bind '"\ei": "\C-l"' bind -m vi-command '"l": vi-insertion-mode'
bind -m vi-command '"L": vi-insert-beg'
bind -m vi-command '"i": forward-char'
bind '"\el": "\ei"' # bind -m vi-insert '"\C-r": reverse-search-history"'
bind '"\eL": "\eI"' # bind -m vi-insert '"\C-l": clear-screen'
bind '"\ek": "\en"' bind -m vi-command '"j": vi-end-word'
bind '"\eK": "\eN"' bind -m vi-command '"J": vi-end-word'
bind '"\ej": "\ee"'
bind '"\eJ": "\eE"'
bind '"\eY": "\ey$"'

View file

@ -11,8 +11,8 @@ alias clpp='clang++ -std=c++2b'
alias python=python3 # Set the default Python version to Python 3 alias python=python3 # Set the default Python version to Python 3
alias py=python # Alias for Python alias py=python # Alias for Python
alias pip=pip3 # Alias for pip alias pip=pip3 # Alias for pip
alias bashcfg="nvim ~/.bashrc" # alias bashcfg="nvim ~/.bashrc"
alias zshcfg="nvim ~/.zshrc" alias zshcfg="nvim $ZDOTDIR/.zshrc"
alias shcfg=zshcfg alias shcfg=zshcfg
alias reload="source $ZDOTDIR/.zshrc" alias reload="source $ZDOTDIR/.zshrc"
alias nvimrc="nvim $XDG_CONFIG_HOME/nvim/" alias nvimrc="nvim $XDG_CONFIG_HOME/nvim/"

View file

@ -1,6 +1,11 @@
# ZSH Config # # ZSH Config #
export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH
export PATH=$HOME/.local/share/gem/ruby/3.3.0/bin:$PATH # Ruby Executables
HIST_STAMPS="yyyy-mm-dd" HIST_STAMPS="yyyy-mm-dd"
export NVM_DIR="$HOME/.config/nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
# plugins=(git web-search jsontools z vi-mode zsh-syntax-highlighting zsh-autosuggestions) # plugins=(git web-search jsontools z vi-mode zsh-syntax-highlighting zsh-autosuggestions)
# Plugins (Manually Managed) # # Plugins (Manually Managed) #
@ -24,21 +29,21 @@ VISUAL="nvim"
# ~/.azure/ -> $XDG_DATA_HOME/azure/ # ~/.azure/ -> $XDG_DATA_HOME/azure/
export AZURE_CONFIG_DIR="$XDG_DATA_HOME"/azure export AZURE_CONFIG_DIR="$XDG_DATA_HOME"/azure
# ~/.cargo/ -> $XDG_DATA_HOME/cargo
export CARGO_HOME="$XDG_DATA_HOME"/cargo
# ~/.cgdb/ -> $XDG_CONFIG_HOME/cgdb/ # ~/.cgdb/ -> $XDG_CONFIG_HOME/cgdb/
export CGDB_DIR="$XDG_CONFIG_HOME"/cgdb export CGDB_DIR="$XDG_CONFIG_HOME"/cgdb
# ~/.nv -> $XDG_CACHE_HOME/nv (CUDA)
# macOS does not have Cuda; Check if CUDA is installed
if [ "$(uname)" != "Darwin" ] && [ -d "/usr/local/cuda" ]; then
export CUDA_CACHE_PATH="$XDG_CACHE_HOME"/nv
fi
# ~/.docker -> $XDG_CONFIG_HOME/docker # ~/.docker -> $XDG_CONFIG_HOME/docker
export DOCKER_CONFIG="$XDG_CONFIG_HOME"/docker export DOCKER_CONFIG="$XDG_CONFIG_HOME"/docker
# ~/.dotnet -> $XDG_DATA_HOME/dotnet # ~/.dotnet -> $XDG_DATA_HOME/dotnet
export DOTNET_CLI_HOME="$XDG_DATA_HOME"/dotnet # Not working
# export DOTNET_CLI_HOME="$XDG_DATA_HOME"/dotnet
# ~/.gnupg -> $XDG_CONFIG_HOME/gnupg # ~/.gnupg -> $XDG_CONFIG_HOME/gnupg
export GNUPGHOME="$XDG_DATA_HOME"/gnupg export GNUPGHOME="$XDG_DATA_HOME"/gnupg
# ~/go -> $XDG_DATA_HOME/go # ~/go -> $XDG_DATA_HOME/go
export GOPATH="$XDG_DATA_HOME"/go export GOPATH="$XDG_DATA_HOME"/go
# ~/.inputrc -> $XDG_CONFIG_HOME/readline/inputrc
export INPUTRC="$XDG_CONFIG_HOME"/readline/inputrc
# ~/.juliaup/ -> $XDG_DATA_HOME/julia/ # ~/.juliaup/ -> $XDG_DATA_HOME/julia/
export JULIA_DEPOT_PATH="$XDG_DATA_HOME/julia:$JULIA_DEPOT_PATH" export JULIA_DEPOT_PATH="$XDG_DATA_HOME/julia:$JULIA_DEPOT_PATH"
# Check if node is installed # Check if node is installed
@ -54,9 +59,22 @@ if command -v node > /dev/null; then
export NPM_CONFIG_CACHE="$XDG_CACHE_HOME"/npm export NPM_CONFIG_CACHE="$XDG_CACHE_HOME"/npm
export NPM_CONFIG_TMP="$XDG_RUNTIME_DIR"/npm export NPM_CONFIG_TMP="$XDG_RUNTIME_DIR"/npm
fi fi
# ~/.nv -> $XDG_CACHE_HOME/nv (CUDA)
# macOS does not have Cuda; Check if CUDA is installed
if [ "$(uname)" != "Darwin" ] && [ -d "/usr/local/cuda" ]; then
export CUDA_CACHE_PATH="$XDG_CACHE_HOME"/nv
fi
# ~/,parallel -> $XDG_CONFIG_HOME/parallel
export PARALLEL_HOME="$XDG_CONFIG_HOME"/parallel
# ~/.python_history -> $XDG_DATA_HOME/python/history # ~/.python_history -> $XDG_DATA_HOME/python/history
# Works only with Python 3.13.0a3 and later # Works only with Python 3.13.0a3 and later
export PYTHON_HISTORY="$XDG_DATA_HOME"/python/history export PYTHON_HISTORY="$XDG_DATA_HOME"/python/history
# ~/.screenrc -> $XDG_CONFIG_HOME/screen/screenrc
export SCREENRC="$XDG_CONFIG_HOME"/screen/screenrc
# ~/.screen/ -> $XDG_RUNTIME_DIR/screen
export SCREENDIR="${XDG_RUNTIME_DIR}/screen"
# ~/.spacemacs/ -> $XDG_CONFIG_HOME/spacemacs
export SPACEMACSDIR="$XDG_CONFIG_HOME"/spacemacs
# ~/.tldrc/ -> $XDG_CACHE_HOME/tldr # ~/.tldrc/ -> $XDG_CACHE_HOME/tldr
export TLDR_CACHE_DIR="$XDG_CACHE_HOME"/tldr export TLDR_CACHE_DIR="$XDG_CACHE_HOME"/tldr
# ~/.w3m -> $XDG_DATA_HOME/w3m # ~/.w3m -> $XDG_DATA_HOME/w3m