refractor: Reorganise dotfiles structures

This commit is contained in:
js0ny 2024-11-29 23:28:18 +00:00
parent 2bd9138a5f
commit bd5ca49c3e
131 changed files with 43 additions and 114 deletions

12
tools/nvim/.editorconfig Normal file
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
tools/nvim/.gitignore vendored Normal file
View file

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

28
tools/nvim/init.lua Normal file
View file

@ -0,0 +1,28 @@
--[[
-*- coding: utf-8 -*-
@Filename init.lua
@Author js0ny
@Date 2024-11-27
@Description neovim
]]
-- 针对特定文件类型设置快捷键
vim.api.nvim_create_autocmd("FileType", {
pattern = "markdown", -- 指定文件类型
callback = function()
vim.api.nvim_buf_set_keymap(0, "v", "`", "c`<C-r>\"`<Esc>", { noremap = true, silent = true, desc = "Wrap selection with backticks" })
end,
})
-- 加载配置
require("config.options")
-- 加载键位映射
require("config.keymaps")
-- 加载插件
require("config.plugins")
-- 加载主题
require("config.colorscheme")
-- vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })

View file

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

View file

@ -0,0 +1,2 @@
require("keymaps")

View file

@ -0,0 +1,52 @@
-- <leader> is space
vim.g.mapleader = " "
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
opt.conceallevel = 2

View file

@ -0,0 +1 @@
require("plugins")

View file

@ -0,0 +1,34 @@
--- Available LSP goes here
--- Check https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md
--- for available server and name
local M = {}
M.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
}
M.server_config = {
lua_ls = {
capabilities = vim.lsp.protocol.make_client_capabilities(),
settings = {
Lua = {
diagnostics = { globals = { "vim" } },
},
},
},
}
return M

View file

@ -0,0 +1,20 @@
local mode_arrow = { "n", "v", "o", "s", "x" }
local keymaps_basic = { -- Modification of Original Keymap - Colemak
{ mode = mode_arrow, keys = "n", cmd = "j" },
{ mode = mode_arrow, keys = "e", cmd = "k" },
{ mode = mode_arrow, keys = "i", cmd = "l" },
{ keys = "H", cmd = ":bprevious<CR>" },
{ keys = "N", cmd = "J" },
{ keys = "E", cmd = "K" },
{ keys = "I", cmd = ":bnext<CR>" },
{ 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$"},
}
return keymaps_basic

View file

@ -0,0 +1,52 @@
local M = {}
local global_default_opts = { noremap = true, silent = true }
local global_default_mode = { "n" }
-- local mode_arrow = { "n", "v", "o", "s", "x" }
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 default_mode
vim.keymap.set(mode, map.keys, map.cmd, opts)
end
end
local keymaps_basic = require("keymaps.basic")
local keymaps_nvim_tree_general = require("keymaps.nvim-tree").global
local keymaps_leader = require("keymaps.leaders")
set_keymaps(keymaps_basic, global_default_opts, global_default_mode)
set_keymaps(keymaps_nvim_tree_general, global_default_opts, global_default_mode)
set_keymaps(keymaps_leader, global_default_opts, global_default_mode)
M.nvim_tree_keymaps = require("keymaps.nvim-tree").plugin
--- `map` default for `cmp.mapping`
function M.cmp_nvim_keymaps(map)
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 = "<Tab>", 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
local function set_markdown_keymaps(bufnr)
local opts = { noremap = true, silent = true, buffer = bufnr }
vim.keymap.set("v", "`", "c`<C-r>\"`<Esc>", opts)
end
vim.api.nvim_create_autocmd("FileType", {
pattern = "markdown",
callback = function()
set_markdown_keymaps(0)
end,
})
require("keymaps.language")
return M

View file

@ -0,0 +1,28 @@
local M = {}
-- Markdown
local function set_markdown_keymaps(bufnr)
local markdown_opt = { noremap = true, silent = true, buffer = bufnr }
for _, map in ipairs(M.markdown) do
local opts = vim.tbl_extend("force", markdown_opt, map.opts or {})
vim.keymap.set(map.mode, map.keys, map.cmd, opts)
end
end
M.markdown = {
{ mode = "v", keys = "`", cmd = "c`<Esc>pi`<Esc>" , desc = "Wrap selection in ` for inline code" },
{ mode = "v", keys = "*", cmd = "c**<Esc>pi**<Esc>" , desc = "Wrap selection in ** for bold" },
{ mode = "v", keys = "_", cmd = "c*<Esc>pi*<Esc>" , desc = "Wrap selection in * for italic" },
}
vim.api.nvim_create_autocmd("FileType", {
pattern = "markdown",
callback = function()
set_markdown_keymaps(0)
end,
})
return M

View file

@ -0,0 +1,79 @@
local M = {}
local leader_general = {
{ keys = "<space>", cmd = ":Telescope find_files<CR>", desc = "Find Files" },
{ keys = "/", cmd = ":Telescope live_grep<CR>", desc = "Grep Files" },
}
for _,map in ipairs(leader_general) do
map.keys = "<leader>" .. map.keys
table.insert(M, map)
end
local leader_q = { -- leader q: Quit
{ keys = "q", cmd = ":q<CR>", desc = "Quit" },
{ keys = "Q", cmd = ":qa!<CR>", desc = "Force Quit" },
{ keys = "w", cmd = ":wq<CR>", desc = "Write and Quit" },
{ keys = "W", cmd = ":wall<CR>:qa!<CR>", desc = "Write all and Force Quit" },
}
local leader_w = { -- leader w: Windows Management
{ keys = "h", cmd = "<C-w>h", desc = "Left Window" },
{ keys = "n", cmd = "<C-w>j", desc = "Down Window" },
{ keys = "e", cmd = "<C-w>k", desc = "Up Window" },
{ keys = "i", cmd = "<C-w>l", desc = "Right Window" },
{ keys = "-", cmd = ":split<CR>", desc = "Split to down" },
{ keys = "|", cmd = ":vsplit<CR>", desc = "Split to right" },
{ keys = "c", cmd = "<C-w>c", desc = "Close Window" },
{ keys = "o", cmd = "<C-w>o", desc = "Close Other Windows" },
{ keys = "r", cmd = "<C-w>r", desc = "Rotate Windows" },
{ keys = "R", cmd = "<C-w>R", desc = "Reverse Rotate Windows" },
{ keys = "t", cmd = "<C-w>T", desc = "Move Window to New Tab" },
{ keys = "H", cmd = ":vertical resize -5<CR>", desc = "Decrease Window Height" },
{ keys = "N", cmd = ":resize +5<CR>", desc = "Increase Window Height" },
{ keys = "E", cmd = ":vertical resize +5<CR>", desc = "Increase Window Width" },
{ keys = "I", cmd = ":resize -5<CR>", desc = "Decrease Window Width" },
}
local leader_f = { -- leader f: Files/Find
{ keys = "f", cmd = ":Telescope fd<CR>", desc = "Find Files"},
{ keys = "s", cmd = ":Telescope live_grep<CR>", desc = "Grep Files"},
{ keys = "b", cmd = ":Telescope buffers<CR>", desc = "List Buffers"},
{ keys = "e", cmd = ":NvimTreeToggle<CR>", desc = "Toggle File Explorer" },
}
local leader_p = { -- leader p: Project
}
local leader_b = { -- leader b: Buffer
{ keys = "d", cmd = ":bdelete<CR>", desc = "Delete Buffer" },
{ keys = "h", cmd = ":bprevious<CR>", desc = "Previous Buffer" },
{ keys = "i", cmd = ":bnext<CR>", desc = "Next Buffer" },
{ keys = "H", cmd = ":bfirst<CR>", desc = "First Buffer" },
{ keys = "I", cmd = ":blast<CR>", desc = "Last Buffer" },
{ keys = "0", cmd = ":bfirst<CR>", desc = "First Buffer" },
{ keys = "^", cmd = ":bfirst<CR>", desc = "First Buffer" },
{ keys = "$", cmd = ":blast<CR>", desc = "Last Buffer" },
}
for _, map in ipairs(leader_q) do
map.keys = "<leader>q" .. map.keys
table.insert(M, map)
end
for _, map in ipairs(leader_w) do
map.keys = "<leader>w" .. map.keys
table.insert(M, map)
end
for _, map in ipairs(leader_f) do
map.keys = "<leader>f" .. map.keys
table.insert(M, map)
end
for _, map in ipairs(leader_b) do
map.keys = "<leader>b" .. map.keys
table.insert(M, map)
end
return M

View file

@ -0,0 +1,81 @@
local M = {}
M.global = {
{ mode = "n", keys = "<leader>e", cmd = ":NvimTreeToggle<CR>" },
}
function M.plugin(api, opts)
-- mode is set to "n" by default, in `./lua/plugins/nvim-tree.lua`
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
return M

View file

@ -0,0 +1,26 @@
return {
{ "catppuccin/nvim", name = "catppuccin" },
{ "RRethy/vim-illuminate" },
{
'nvim-lualine/lualine.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons' },
config = function()
require("plugins.mod.lualine")
end,
},
{
"gbprod/yanky.nvim",
config = function()
require("yanky").setup({
highlight = {
on_put = true,
on_yank = true,
timer = 500,
},
})
end
},
{ import = "plugins.mod.alpha-nvim" },
{ import = "plugins.mod.winbar-nvim"},
{ import = "plugins.mod.bufferline" },
}

View file

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

View file

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

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").servers
mason_lspconfig.setup({
ensure_installed = servers,
})
end
},
}

View file

@ -0,0 +1,26 @@
return {
{ 'wakatime/vim-wakatime', lazy = false },
{ import = "plugins.mod.obsidian-nvim" },
{
"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)",
},
},
},
{
"github/copilot.vim",
lazy = false,
}
}

View file

@ -0,0 +1,52 @@
-- 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('p', '󰈞 查找项目', ':Telescope projects<CR>'),
dashboard.button('h', ' 历史文件', ':Telescope oldfiles<CR>'),
dashboard.button('l', ' 加载会话', ':SessionSearch<CR>'),
dashboard.button('c', ' 转到设置', ':Telescope find_files cwd=~/.config/nvim<CR>'),
dashboard.button('SPC q', '󱊷 退出', ':qa<CR>'),
}
dashboard.section.footer.val = "今日 " .. os.date("%Y-%m-%d %A") .. " "
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,17 @@
return {
"akinsho/bufferline.nvim",
dependencies = "nvim-tree/nvim-web-devicons", -- 图标支持
config = function()
require("bufferline").setup({
options = {
numbers = "ordinal", -- 显示 buffer 序号
close_command = "bdelete! %d", -- 关闭 buffer 的命令
right_mouse_command = "bdelete! %d", -- 右键关闭
offsets = {
{ filetype = "NvimTree", text = "资源管理器", text_align = "center" },
},
separator_style = "thin",
},
})
end,
}

View file

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

View file

@ -0,0 +1,240 @@
-- 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_right { '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 },
},
}
ins_left {
function()
return vim.bo.filetype
end,
color = { fg = colors.blue, gui = 'bold' },
}
ins_left {
function()
return vim.bo.shiftwidth .. " space"
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 = '',
color = { fg = '#ffffff', gui = 'bold' },
}
-- 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,
}
-- 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,68 @@
local function set_keymaps(keymaps_cmp)
local mappings = {}
for _, map in ipairs(keymaps_cmp) do
mappings[map.keys] = map.cmd
end
return mappings
end
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 capabilities = require("cmp_nvim_lsp").default_capabilities()
local servers_module = require("config.servers")
local servers = servers_module.servers
local servers_config = servers_module.server_config
-- 默认 LSP 配置
local default_server_config = {
capabilities = capabilities,
}
local raw_keymaps = require("keymaps").cmp_nvim_keymaps(cmp.mapping)
local mapped = set_keymaps(raw_keymaps)
-- 配置 nvim-cmp
cmp.setup({
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert(mapped),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "copilot" },
}, {
{ name = "buffer" },
{ name = "path" },
}),
})
-- 配置 cmdline 模式
cmp.setup.cmdline(":", {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = "cmdline" },
-- path completion is slow under WSL
-- Since WSL loads Windows Environment Variables
},
})
-- 配置 LSP
for _, server in ipairs(servers) do
local config = vim.tbl_deep_extend("force", default_server_config, servers_config[server] or {})
lspconfig[server].setup(config)
end
end,
}

View file

@ -0,0 +1,37 @@
local function my_on_attach(bufnr)
-- local keymaps = require("config.keymaps")
local api = require "nvim-tree.api"
local default_mode = { "n" }
local keymaps = require("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 = require("keymaps.nvim-tree").plugin(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,
}
end
}

View file

@ -0,0 +1,11 @@
return {
"nvim-treesitter/nvim-treesitter",
run = ":TSUpdate",
config = function()
require("nvim-treesitter.configs").setup({
ensure_installed = { "markdown", "markdown_inline" },
highlight = { enable = true },
indent = { enable = true },
})
end,
}

View file

@ -0,0 +1,33 @@
return {
"epwalsh/obsidian.nvim",
version = "*", -- recommended, use latest release instead of latest commit
lazy = true,
ft = "markdown",
-- Replace the above line with this if you only want to load obsidian.nvim for markdown files in your vault:
-- event = {
-- -- If you want to use the home shortcut '~' here you need to call 'vim.fn.expand'.
-- -- E.g. "BufReadPre " .. vim.fn.expand "~" .. "/my-vault/*.md"
-- -- refer to `:h file-pattern` for more examples
-- "BufReadPre path/to/my-vault/*.md",
-- "BufNewFile path/to/my-vault/*.md",
-- },
dependencies = {
-- Required.
"nvim-lua/plenary.nvim",
-- see below for full list of optional dependencies 👇
},
opts = {
workspaces = {
{
name = "personal",
path = "/mnt/c/Users/citoy/Obsidian",
},
},
completion = {
nvim_cmp = true,
min_chars = 2
}
-- see below for full list of options 👇
},
}

View file

@ -0,0 +1,15 @@
return {
"ahmedkhalf/project.nvim",
config = function()
require("project_nvim").setup({
detection_methods = { "lsp", "pattern" },
patterns = { ".git", "Makefile", "package.json" },
sync_root_with_cwd = true,
silent_chdir = true,
scope_chdir = "global",
})
require("telescope").load_extension("projects")
end,
dependencies = { "nvim-telescope/telescope.nvim" },
}

View file

@ -0,0 +1,39 @@
return {
{
"fgheng/winbar.nvim",
config = function()
require("winbar").setup({
enabled = true,
show_file_path = true,
show_symbols = true,
colors = {
path = '#9c1d91',
file_name = '',
symbols = '',
},
icons = {
file_icon_default = '',
seperator = '>',
editor_state = '',
lock_icon = '',
},
exclude_filetype = {
'help',
'startify',
'dashboard',
'packer',
'neogitstatus',
'NvimTree',
'Trouble',
'alpha',
'lir',
'Outline',
'spectre_panel',
'toggleterm',
'qf',
}
})
end,
},
}

View file

@ -0,0 +1,9 @@
return {
{ import = "plugins.mod.nvim-treesitter", },
{ 'echasnovski/mini.pairs', version = false,
config = function()
require("mini.pairs").setup()
end,
},
}

5
tools/nvim/stylua.toml Normal file
View file

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