initialize
This commit is contained in:
commit
7ee1e5bfb4
12 changed files with 1781 additions and 0 deletions
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
tt.*
|
||||||
|
.tests
|
||||||
|
doc/tags
|
||||||
|
debug
|
||||||
|
.repro
|
||||||
|
foo.*
|
||||||
|
*.log
|
||||||
|
data
|
||||||
3
init.lua
Normal file
3
init.lua
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
local ray = require("rayandrew")
|
||||||
|
|
||||||
|
ray.setup()
|
||||||
47
lazy-lock.json
Normal file
47
lazy-lock.json
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
{
|
||||||
|
"LuaSnip": { "branch": "master", "commit": "e81cbe6004051c390721d8570a4a0541ceb0df10" },
|
||||||
|
"bufferline.nvim": { "branch": "main", "commit": "99f0932365b34e22549ff58e1bea388465d15e99" },
|
||||||
|
"cellular-automaton.nvim": { "branch": "main", "commit": "679943b8e1e5ef79aaeeaf4b00782c52eb4e928f" },
|
||||||
|
"cloak.nvim": { "branch": "main", "commit": "c6a92e2fbc6b931bc9ed0d07e80931c2324e05cb" },
|
||||||
|
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" },
|
||||||
|
"copilot-cmp": { "branch": "master", "commit": "c2cdb3c0f5078b0619055af192295830a7987790" },
|
||||||
|
"copilot.lua": { "branch": "master", "commit": "e48bd7020a98be217d85c006a298656294fd6210" },
|
||||||
|
"dressing.nvim": { "branch": "master", "commit": "829bc80400651aea31b03d8fc9a99135512fe67a" },
|
||||||
|
"flash.nvim": { "branch": "main", "commit": "967117690bd677cb7b6a87f0bc0077d2c0be3a27" },
|
||||||
|
"harpoon": { "branch": "master", "commit": "21f4c47c6803d64ddb934a5b314dcb1b8e7365dc" },
|
||||||
|
"indent-blankline.nvim": { "branch": "master", "commit": "4541d690816cb99a7fc248f1486aa87f3abce91c" },
|
||||||
|
"lazy.nvim": { "branch": "main", "commit": "3ad55ae678876516156cca2f361c51f7952a924b" },
|
||||||
|
"lsp-zero.nvim": { "branch": "v2.x", "commit": "73bc33fe9ad5a1d4501536fdd4755b3aa18c3392" },
|
||||||
|
"lualine.nvim": { "branch": "master", "commit": "05d78e9fd0cdfb4545974a5aa14b1be95a86e9c9" },
|
||||||
|
"mason-lspconfig.nvim": { "branch": "main", "commit": "e86a4c84ff35240639643ffed56ee1c4d55f538e" },
|
||||||
|
"mason-null-ls.nvim": { "branch": "main", "commit": "ae0c5fa57468ac65617f1bf821ba0c3a1e251f0c" },
|
||||||
|
"mason.nvim": { "branch": "main", "commit": "fe9e34a9ab4d64321cdc3ecab4ea1809239bb73f" },
|
||||||
|
"mini.bufremove": { "branch": "main", "commit": "7821606e35c1ac931b56d8e3155f45ffe76ee7e5" },
|
||||||
|
"mini.comment": { "branch": "main", "commit": "877acea5b2a32ff55f808fc0ebe9aa898648318c" },
|
||||||
|
"neo-tree.nvim": { "branch": "v3.x", "commit": "981a43adcca25e7ccc3c589902d49f25e4d48ebc" },
|
||||||
|
"noice.nvim": { "branch": "main", "commit": "894db25ec726d32047799d4d0a982b701bec453b" },
|
||||||
|
"nui.nvim": { "branch": "main", "commit": "9e3916e784660f55f47daa6f26053ad044db5d6a" },
|
||||||
|
"null-ls.nvim": { "branch": "main", "commit": "db09b6c691def0038c456551e4e2772186449f35" },
|
||||||
|
"nvim-cmp": { "branch": "main", "commit": "c4e491a87eeacf0408902c32f031d802c7eafce8" },
|
||||||
|
"nvim-lspconfig": { "branch": "master", "commit": "b6091272422bb0fbd729f7f5d17a56d37499c54f" },
|
||||||
|
"nvim-navic": { "branch": "master", "commit": "9c89730da6a05acfeb6a197e212dfadf5aa60ca0" },
|
||||||
|
"nvim-spectre": { "branch": "master", "commit": "3ba6edeea1390457caaf73e96ab9c086ff6f90e9" },
|
||||||
|
"nvim-treesitter": { "branch": "master", "commit": "1c79da3300951e934f635eaf8703480b57644e7e" },
|
||||||
|
"nvim-treesitter-context": { "branch": "master", "commit": "6f8f788738b968f24a108ee599c5be0031f94f06" },
|
||||||
|
"nvim-treesitter-textobjects": { "branch": "master", "commit": "9e519b6146512c8e2e702faf8ac48420f4f5deec" },
|
||||||
|
"nvim-ts-context-commentstring": { "branch": "main", "commit": "e9062e2dfb9854e6a927370f2d720de354c88524" },
|
||||||
|
"nvim-web-devicons": { "branch": "master", "commit": "efbfed0567ef4bfac3ce630524a0f6c8451c5534" },
|
||||||
|
"playground": { "branch": "master", "commit": "2b81a018a49f8e476341dfcb228b7b808baba68b" },
|
||||||
|
"plenary.nvim": { "branch": "master", "commit": "267282a9ce242bbb0c5dc31445b6d353bed978bb" },
|
||||||
|
"refactoring.nvim": { "branch": "master", "commit": "5359e74291164fcaeaaecdea9ba753ad54eb53d0" },
|
||||||
|
"rose-pine": { "branch": "main", "commit": "e29002cbee4854a9c8c4b148d8a52fae3176070f" },
|
||||||
|
"telescope.nvim": { "branch": "master", "commit": "b6fccfb0f7589a87587875206786daccba62acc3" },
|
||||||
|
"todo-comments.nvim": { "branch": "main", "commit": "3094ead8edfa9040de2421deddec55d3762f64d1" },
|
||||||
|
"trouble.nvim": { "branch": "main", "commit": "40aad004f53ae1d1ba91bcc5c29d59f07c5f01d3" },
|
||||||
|
"undotree": { "branch": "master", "commit": "0e11ba7325efbbb3f3bebe06213afa3e7ec75131" },
|
||||||
|
"vim-fugitive": { "branch": "master", "commit": "b3b838d690f315a503ec4af8c634bdff3b200aaf" },
|
||||||
|
"vim-illuminate": { "branch": "master", "commit": "a2907275a6899c570d16e95b9db5fd921c167502" },
|
||||||
|
"vim-tmux-navigator": { "branch": "master", "commit": "cdd66d6a37d991bba7997d593586fc51a5b37aa8" },
|
||||||
|
"which-key.nvim": { "branch": "main", "commit": "7ccf476ebe0445a741b64e36c78a682c1c6118b7" },
|
||||||
|
"zen-mode.nvim": { "branch": "main", "commit": "68f554702de63f4b7b6b6d4bcb10178f41a0acc7" }
|
||||||
|
}
|
||||||
96
lua/rayandrew/autocmds.lua
Normal file
96
lua/rayandrew/autocmds.lua
Normal file
|
|
@ -0,0 +1,96 @@
|
||||||
|
-- Taken from
|
||||||
|
-- https://github.com/LazyVim/LazyVim/blob/566049aa4a26a86219dd1ad1624f9a1bf18831b6/lua/lazyvim/config/autocmds.lua
|
||||||
|
|
||||||
|
local function augroup(name)
|
||||||
|
return vim.api.nvim_create_augroup("lazyvim_" .. name, { clear = true })
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check if we need to reload the file when it changed
|
||||||
|
vim.api.nvim_create_autocmd({ "FocusGained", "TermClose", "TermLeave" }, {
|
||||||
|
group = augroup("checktime"),
|
||||||
|
command = "checktime",
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Highlight on yank
|
||||||
|
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||||
|
group = augroup("highlight_yank"),
|
||||||
|
callback = function()
|
||||||
|
vim.highlight.on_yank()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- resize splits if window got resized
|
||||||
|
vim.api.nvim_create_autocmd({ "VimResized" }, {
|
||||||
|
group = augroup("resize_splits"),
|
||||||
|
callback = function()
|
||||||
|
vim.cmd("tabdo wincmd =")
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- go to last loc when opening a buffer
|
||||||
|
vim.api.nvim_create_autocmd("BufReadPost", {
|
||||||
|
group = augroup("last_loc"),
|
||||||
|
callback = function()
|
||||||
|
local exclude = { "gitcommit" }
|
||||||
|
local buf = vim.api.nvim_get_current_buf()
|
||||||
|
if vim.tbl_contains(exclude, vim.bo[buf].filetype) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local mark = vim.api.nvim_buf_get_mark(buf, '"')
|
||||||
|
local lcount = vim.api.nvim_buf_line_count(buf)
|
||||||
|
if mark[1] > 0 and mark[1] <= lcount then
|
||||||
|
pcall(vim.api.nvim_win_set_cursor, 0, mark)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- close some filetypes with <q>
|
||||||
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
|
group = augroup("close_with_q"),
|
||||||
|
pattern = {
|
||||||
|
"PlenaryTestPopup",
|
||||||
|
"help",
|
||||||
|
"lspinfo",
|
||||||
|
"man",
|
||||||
|
"notify",
|
||||||
|
"qf",
|
||||||
|
"spectre_panel",
|
||||||
|
"startuptime",
|
||||||
|
"tsplayground",
|
||||||
|
"neotest-output",
|
||||||
|
"checkhealth",
|
||||||
|
"neotest-summary",
|
||||||
|
"neotest-output-panel",
|
||||||
|
},
|
||||||
|
callback = function(event)
|
||||||
|
vim.bo[event.buf].buflisted = false
|
||||||
|
vim.keymap.set(
|
||||||
|
"n",
|
||||||
|
"q",
|
||||||
|
"<cmd>close<cr>",
|
||||||
|
{ buffer = event.buf, silent = true }
|
||||||
|
)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- wrap and check for spell in text filetypes
|
||||||
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
|
group = augroup("wrap_spell"),
|
||||||
|
pattern = { "gitcommit", "markdown" },
|
||||||
|
callback = function()
|
||||||
|
vim.opt_local.wrap = true
|
||||||
|
vim.opt_local.spell = true
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Auto create dir when saving a file, in case some intermediate directory does not exist
|
||||||
|
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
|
||||||
|
group = augroup("auto_create_dir"),
|
||||||
|
callback = function(event)
|
||||||
|
if event.match:match("^%w%w+://") then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local file = vim.loop.fs_realpath(event.match) or event.match
|
||||||
|
vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p")
|
||||||
|
end,
|
||||||
|
})
|
||||||
11
lua/rayandrew/init.lua
Normal file
11
lua/rayandrew/init.lua
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
function M.setup()
|
||||||
|
require("rayandrew.set")
|
||||||
|
require("rayandrew.lazy")
|
||||||
|
require("rayandrew.autocmds")
|
||||||
|
require("rayandrew.remap")
|
||||||
|
require("rayandrew.theme").setup()
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
43
lua/rayandrew/lazy.lua
Normal file
43
lua/rayandrew/lazy.lua
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
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", -- latest stable release
|
||||||
|
lazypath,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.opt.rtp:prepend(lazypath)
|
||||||
|
|
||||||
|
require("lazy").setup({
|
||||||
|
spec = {
|
||||||
|
{ import = "rayandrew.plugins" },
|
||||||
|
},
|
||||||
|
defaults = {
|
||||||
|
lazy = false,
|
||||||
|
version = false,
|
||||||
|
},
|
||||||
|
change_detection = {
|
||||||
|
enabled = true,
|
||||||
|
notify = false,
|
||||||
|
},
|
||||||
|
checker = { enabled = true },
|
||||||
|
performance = {
|
||||||
|
rtp = {
|
||||||
|
-- disable some rtp plugins
|
||||||
|
disabled_plugins = {
|
||||||
|
"gzip",
|
||||||
|
-- "matchit",
|
||||||
|
-- "matchparen",
|
||||||
|
-- "netrwPlugin",
|
||||||
|
"tarPlugin",
|
||||||
|
"tohtml",
|
||||||
|
"tutor",
|
||||||
|
"zipPlugin",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
1036
lua/rayandrew/plugins.lua
Normal file
1036
lua/rayandrew/plugins.lua
Normal file
File diff suppressed because it is too large
Load diff
216
lua/rayandrew/remap.lua
Normal file
216
lua/rayandrew/remap.lua
Normal file
|
|
@ -0,0 +1,216 @@
|
||||||
|
local Util = require("rayandrew.util")
|
||||||
|
|
||||||
|
------------------------------
|
||||||
|
-- Buffers
|
||||||
|
------------------------------
|
||||||
|
|
||||||
|
Util.map("n", "<leader>fs", "<cmd>w<cr><esc>", { desc = "Save file" })
|
||||||
|
|
||||||
|
Util.map(
|
||||||
|
{ "i", "v", "n", "s" },
|
||||||
|
"<C-s>",
|
||||||
|
"<cmd>w<cr><esc>",
|
||||||
|
{ desc = "Save file" }
|
||||||
|
)
|
||||||
|
|
||||||
|
-- Move Lines
|
||||||
|
Util.map("n", "<A-j>", "<cmd>m .+1<cr>==", { desc = "Move down" })
|
||||||
|
Util.map("n", "<A-k>", "<cmd>m .-2<cr>==", { desc = "Move up" })
|
||||||
|
Util.map("i", "<A-j>", "<esc><cmd>m .+1<cr>==gi", { desc = "Move down" })
|
||||||
|
Util.map("i", "<A-k>", "<esc><cmd>m .-2<cr>==gi", { desc = "Move up" })
|
||||||
|
Util.map("v", "<A-j>", ":m '>+1<cr>gv=gv", { desc = "Move down" })
|
||||||
|
Util.map("v", "<A-k>", ":m '<-2<cr>gv=gv", { desc = "Move up" })
|
||||||
|
|
||||||
|
------------------------------
|
||||||
|
-- Windowing + Navigation
|
||||||
|
------------------------------
|
||||||
|
|
||||||
|
-- better up/down
|
||||||
|
Util.map(
|
||||||
|
{ "n", "x" },
|
||||||
|
"j",
|
||||||
|
"v:count == 0 ? 'gj' : 'j'",
|
||||||
|
{ expr = true, silent = true }
|
||||||
|
)
|
||||||
|
Util.map(
|
||||||
|
{ "n", "x" },
|
||||||
|
"k",
|
||||||
|
"v:count == 0 ? 'gk' : 'k'",
|
||||||
|
{ expr = true, silent = true }
|
||||||
|
)
|
||||||
|
|
||||||
|
-- resize
|
||||||
|
Util.map(
|
||||||
|
"n",
|
||||||
|
"<C-Up>",
|
||||||
|
"<cmd>resize +2<cr>",
|
||||||
|
{ desc = "Increase window height" }
|
||||||
|
)
|
||||||
|
Util.map(
|
||||||
|
"n",
|
||||||
|
"<C-Down>",
|
||||||
|
"<cmd>resize -2<cr>",
|
||||||
|
{ desc = "Decrease window height" }
|
||||||
|
)
|
||||||
|
Util.map(
|
||||||
|
"n",
|
||||||
|
"<C-Left>",
|
||||||
|
"<cmd>vertical resize -2<cr>",
|
||||||
|
{ desc = "Decrease window width" }
|
||||||
|
)
|
||||||
|
Util.map(
|
||||||
|
"n",
|
||||||
|
"<C-Right>",
|
||||||
|
"<cmd>vertical resize +2<cr>",
|
||||||
|
{ desc = "Increase window width" }
|
||||||
|
)
|
||||||
|
|
||||||
|
-- split
|
||||||
|
Util.map(
|
||||||
|
"n",
|
||||||
|
"<leader>ws",
|
||||||
|
"<cmd>split<cr>",
|
||||||
|
{ desc = "[W]indow Horizontal [S]plit" }
|
||||||
|
) -- split horizontal
|
||||||
|
Util.map(
|
||||||
|
"n",
|
||||||
|
"<leader>wv",
|
||||||
|
"<cmd>vsplit<cr>",
|
||||||
|
{ desc = "[W]indow [V]ertical Split" }
|
||||||
|
) -- split vertical
|
||||||
|
|
||||||
|
-- move
|
||||||
|
Util.map(
|
||||||
|
"n",
|
||||||
|
"<leader>wh",
|
||||||
|
"<cmd>TmuxNavigateLeft<cr>",
|
||||||
|
{ desc = "Go to Left [W]indow" }
|
||||||
|
)
|
||||||
|
Util.map(
|
||||||
|
"n",
|
||||||
|
"<leader>wj",
|
||||||
|
"<cmd>TmuxNavigateDown<cr>",
|
||||||
|
{ desc = "Go to [W]indow Below" }
|
||||||
|
)
|
||||||
|
Util.map(
|
||||||
|
"n",
|
||||||
|
"<leader>wk",
|
||||||
|
"<cmd>TmuxNavigateUp<cr>",
|
||||||
|
{ desc = "Go to Top [W]indow" }
|
||||||
|
)
|
||||||
|
Util.map(
|
||||||
|
"n",
|
||||||
|
"<leader>wl",
|
||||||
|
"<cmd>TmuxNavigateRight<cr>",
|
||||||
|
{ desc = "Go to Right [W]indow" }
|
||||||
|
)
|
||||||
|
|
||||||
|
if Util.has("bufferline.nvim") then
|
||||||
|
Util.map(
|
||||||
|
"n",
|
||||||
|
"<S-h>",
|
||||||
|
"<cmd>BufferLineCyclePrev<cr>",
|
||||||
|
{ desc = "Prev buffer" }
|
||||||
|
)
|
||||||
|
Util.map(
|
||||||
|
"n",
|
||||||
|
"<S-l>",
|
||||||
|
"<cmd>BufferLineCycleNext<cr>",
|
||||||
|
{ desc = "Next buffer" }
|
||||||
|
)
|
||||||
|
Util.map("n", "[b", "<cmd>BufferLineCyclePrev<cr>", { desc = "Prev buffer" })
|
||||||
|
Util.map("n", "]b", "<cmd>BufferLineCycleNext<cr>", { desc = "Next buffer" })
|
||||||
|
else
|
||||||
|
Util.map("n", "<S-h>", "<cmd>bprevious<cr>", { desc = "Prev buffer" })
|
||||||
|
Util.map("n", "<S-l>", "<cmd>bnext<cr>", { desc = "Next buffer" })
|
||||||
|
Util.map("n", "[b", "<cmd>bprevious<cr>", { desc = "Prev buffer" })
|
||||||
|
Util.map("n", "]b", "<cmd>bnext<cr>", { desc = "Next buffer" })
|
||||||
|
end
|
||||||
|
|
||||||
|
-- tabs
|
||||||
|
Util.map("n", "<leader><tab>l", "<cmd>tablast<cr>", { desc = "Last Tab" })
|
||||||
|
Util.map("n", "<leader><tab>f", "<cmd>tabfirst<cr>", { desc = "First Tab" })
|
||||||
|
Util.map("n", "<leader><tab><tab>", "<cmd>tabnew<cr>", { desc = "New Tab" })
|
||||||
|
Util.map("n", "<leader><tab>]", "<cmd>tabnext<cr>", { desc = "Next Tab" })
|
||||||
|
Util.map("n", "<leader><tab>d", "<cmd>tabclose<cr>", { desc = "Close Tab" })
|
||||||
|
Util.map(
|
||||||
|
"n",
|
||||||
|
"<leader><tab>[",
|
||||||
|
"<cmd>tabprevious<cr>",
|
||||||
|
{ desc = "Previous Tab" }
|
||||||
|
)
|
||||||
|
|
||||||
|
-- close
|
||||||
|
Util.map("n", "<leader>wq", "<C-w>q", { desc = "[W]indow [Q]uit" }) -- quit
|
||||||
|
|
||||||
|
------------------------------
|
||||||
|
-- Clipboard
|
||||||
|
------------------------------
|
||||||
|
|
||||||
|
Util.map("x", "<leader>p", [["_dP]])
|
||||||
|
|
||||||
|
Util.map({ "n", "v" }, "<leader>y", [["+y]])
|
||||||
|
Util.map("n", "<leader>Y", [["+Y]])
|
||||||
|
|
||||||
|
Util.map({ "n", "v" }, "<leader>d", [["_d]])
|
||||||
|
|
||||||
|
Util.map("i", "<C-c>", "<Esc>")
|
||||||
|
|
||||||
|
Util.map("n", "Q", "<nop>")
|
||||||
|
|
||||||
|
------------------------------
|
||||||
|
-- Utilities
|
||||||
|
------------------------------
|
||||||
|
|
||||||
|
Util.map("n", "<leader>u", vim.cmd.UndotreeToggle)
|
||||||
|
|
||||||
|
-- better indenting
|
||||||
|
Util.map("v", "<", "<gv")
|
||||||
|
Util.map("v", ">", ">gv")
|
||||||
|
|
||||||
|
-- file permission
|
||||||
|
Util.map("n", "<leader>x", "<cmd>!chmod +x %<CR>", { silent = true })
|
||||||
|
|
||||||
|
Util.map("n", "<leader>mr", "<cmd>CellularAutomaton make_it_rain<CR>")
|
||||||
|
|
||||||
|
------------------------------
|
||||||
|
-- Terminal
|
||||||
|
------------------------------
|
||||||
|
|
||||||
|
-- lazygit
|
||||||
|
Util.map("n", "<leader>gg", function()
|
||||||
|
Util.float_term(
|
||||||
|
{ "lazygit" },
|
||||||
|
{ cwd = Util.get_root(), esc_esc = false, ctrl_hjkl = false }
|
||||||
|
)
|
||||||
|
end, { desc = "Lazygit (root dir)" })
|
||||||
|
Util.map("n", "<leader>gG", function()
|
||||||
|
Util.float_term({ "lazygit" }, { esc_esc = false, ctrl_hjkl = false })
|
||||||
|
end, { desc = "Lazygit (cwd)" })
|
||||||
|
|
||||||
|
-- float term
|
||||||
|
local lazyterm = function()
|
||||||
|
Util.float_term(nil, { cwd = Util.get_root() })
|
||||||
|
end
|
||||||
|
Util.map("n", "<leader>ft", lazyterm, { desc = "Terminal (root dir)" })
|
||||||
|
Util.map("n", "<leader>fT", function()
|
||||||
|
Util.float_term()
|
||||||
|
end, { desc = "Terminal (cwd)" })
|
||||||
|
Util.map("n", "<c-`>", lazyterm, { desc = "Terminal (root dir)" })
|
||||||
|
Util.map("n", "<c-/>", lazyterm, { desc = "Terminal (root dir)" })
|
||||||
|
Util.map("n", "<c-_>", lazyterm, { desc = "which_key_ignore" })
|
||||||
|
|
||||||
|
Util.map("t", "<esc><esc>", "<c-\\><c-n>", { desc = "Enter Normal Mode" })
|
||||||
|
Util.map("t", "<C-h>", "<cmd>wincmd h<cr>", { desc = "Go to left window" })
|
||||||
|
Util.map("t", "<C-j>", "<cmd>wincmd j<cr>", { desc = "Go to lower window" })
|
||||||
|
Util.map("t", "<C-k>", "<cmd>wincmd k<cr>", { desc = "Go to upper window" })
|
||||||
|
Util.map("t", "<C-l>", "<cmd>wincmd l<cr>", { desc = "Go to right window" })
|
||||||
|
Util.map("t", "<C-/>", "<cmd>close<cr>", { desc = "Hide Terminal" })
|
||||||
|
Util.map("t", "<c-_>", "<cmd>close<cr>", { desc = "which_key_ignore" })
|
||||||
|
|
||||||
|
------------------------------
|
||||||
|
-- Others
|
||||||
|
------------------------------
|
||||||
|
|
||||||
|
-- lazy
|
||||||
|
Util.map("n", "<leader>l", "<cmd>Lazy<cr>", { desc = "Lazy" })
|
||||||
65
lua/rayandrew/set.lua
Normal file
65
lua/rayandrew/set.lua
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
vim.g.mapleader = " "
|
||||||
|
vim.g.maplocalleader = "\\"
|
||||||
|
|
||||||
|
local opt = vim.opt
|
||||||
|
|
||||||
|
opt.autowrite = true -- Enable auto write
|
||||||
|
opt.backup = false
|
||||||
|
opt.clipboard = "unnamedplus" -- Sync with system clipboard
|
||||||
|
opt.completeopt = "menu,menuone,noselect"
|
||||||
|
opt.conceallevel = 3 -- Hide * markup for bold and italic
|
||||||
|
opt.confirm = true -- Confirm to save changes before exiting modified buffer
|
||||||
|
opt.cursorline = true -- Enable highlighting of the current line
|
||||||
|
opt.expandtab = true -- Use spaces instead of tabs
|
||||||
|
opt.formatoptions = "jcroqlnt" -- tcqj
|
||||||
|
opt.grepformat = "%f:%l:%c:%m"
|
||||||
|
opt.grepprg = "rg --vimgrep"
|
||||||
|
opt.hlsearch = false
|
||||||
|
opt.ignorecase = true -- Ignore case
|
||||||
|
opt.incsearch = true
|
||||||
|
opt.inccommand = "nosplit" -- preview incremental substitute
|
||||||
|
opt.laststatus = 0
|
||||||
|
opt.list = true -- Show some invisible characters (tabs...
|
||||||
|
opt.mouse = "a" -- Enable mouse mode
|
||||||
|
opt.nu = true
|
||||||
|
opt.number = true -- Print line number
|
||||||
|
opt.pumblend = 10 -- Popup blend
|
||||||
|
opt.pumheight = 10 -- Maximum number of entries in a popup
|
||||||
|
opt.relativenumber = true -- Relative line numbers
|
||||||
|
opt.scrolloff = 4 -- Lines of context
|
||||||
|
opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize" }
|
||||||
|
opt.shiftround = true -- Round indent
|
||||||
|
opt.shiftwidth = 2 -- Size of an indent
|
||||||
|
opt.shortmess:append({ W = true, I = true, c = true })
|
||||||
|
opt.showmode = false -- Dont show mode since we have a statusline
|
||||||
|
opt.sidescrolloff = 8 -- Columns of context
|
||||||
|
opt.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time
|
||||||
|
opt.smartcase = true -- Don't ignore case with capitals
|
||||||
|
opt.smartindent = true -- Insert indents automatically
|
||||||
|
opt.softtabstop = 2
|
||||||
|
opt.spelllang = { "en" }
|
||||||
|
opt.splitbelow = true -- Put new windows below current
|
||||||
|
opt.splitright = true -- Put new windows right of current
|
||||||
|
opt.swapfile = false
|
||||||
|
opt.tabstop = 2 -- Number of spaces tabs count for
|
||||||
|
opt.termguicolors = true -- True color support
|
||||||
|
opt.timeoutlen = 300
|
||||||
|
opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
|
||||||
|
opt.undofile = true
|
||||||
|
opt.undolevels = 10000
|
||||||
|
opt.updatetime = 200 -- Save swap file and trigger CursorHold
|
||||||
|
opt.wildmode = "longest:full,full" -- Command-line completion mode
|
||||||
|
opt.winminwidth = 5 -- Minimum window width
|
||||||
|
opt.wrap = false -- Disable line wrap
|
||||||
|
|
||||||
|
if vim.fn.has("nvim-0.9.0") == 1 then
|
||||||
|
opt.splitkeep = "screen"
|
||||||
|
opt.shortmess:append({ C = true })
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Fix markdown indentation settings
|
||||||
|
vim.g.markdown_recommended_style = 0
|
||||||
|
|
||||||
|
opt.isfname:append("@-@")
|
||||||
|
|
||||||
|
opt.colorcolumn = "80"
|
||||||
80
lua/rayandrew/theme.lua
Normal file
80
lua/rayandrew/theme.lua
Normal file
|
|
@ -0,0 +1,80 @@
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
M.colorscheme = "rose-pine"
|
||||||
|
|
||||||
|
function M.setup()
|
||||||
|
-- taken from https://github.com/LazyVim/LazyVim/blob/566049aa4a26a86219dd1ad1624f9a1bf18831b6/lua/lazyvim/config/init.lua#L117C3-L129C5
|
||||||
|
require("lazy.core.util").try(function()
|
||||||
|
if type(M.colorscheme) == "function" then
|
||||||
|
M.colorscheme()
|
||||||
|
else
|
||||||
|
vim.cmd.colorscheme(M.colorscheme)
|
||||||
|
end
|
||||||
|
end, {
|
||||||
|
msg = "Could not load your colorscheme",
|
||||||
|
on_error = function(msg)
|
||||||
|
require("lazy.core.util").error(msg)
|
||||||
|
vim.cmd.colorscheme("habamax")
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
M.icons = {
|
||||||
|
dap = {
|
||||||
|
Stopped = { " ", "DiagnosticWarn", "DapStoppedLine" },
|
||||||
|
Breakpoint = " ",
|
||||||
|
BreakpointCondition = " ",
|
||||||
|
BreakpointRejected = { " ", "DiagnosticError" },
|
||||||
|
LogPoint = ".>",
|
||||||
|
},
|
||||||
|
diagnostics = {
|
||||||
|
Error = " ",
|
||||||
|
Warn = " ",
|
||||||
|
Hint = " ",
|
||||||
|
Info = " ",
|
||||||
|
},
|
||||||
|
git = {
|
||||||
|
added = " ",
|
||||||
|
modified = " ",
|
||||||
|
removed = " ",
|
||||||
|
},
|
||||||
|
kinds = {
|
||||||
|
Array = " ",
|
||||||
|
Boolean = " ",
|
||||||
|
Class = " ",
|
||||||
|
Color = " ",
|
||||||
|
Constant = " ",
|
||||||
|
Constructor = " ",
|
||||||
|
Copilot = " ",
|
||||||
|
Enum = " ",
|
||||||
|
EnumMember = " ",
|
||||||
|
Event = " ",
|
||||||
|
Field = " ",
|
||||||
|
File = " ",
|
||||||
|
Folder = " ",
|
||||||
|
Function = " ",
|
||||||
|
Interface = " ",
|
||||||
|
Key = " ",
|
||||||
|
Keyword = " ",
|
||||||
|
Method = " ",
|
||||||
|
Module = " ",
|
||||||
|
Namespace = " ",
|
||||||
|
Null = " ",
|
||||||
|
Number = " ",
|
||||||
|
Object = " ",
|
||||||
|
Operator = " ",
|
||||||
|
Package = " ",
|
||||||
|
Property = " ",
|
||||||
|
Reference = " ",
|
||||||
|
Snippet = " ",
|
||||||
|
String = " ",
|
||||||
|
Struct = " ",
|
||||||
|
Text = " ",
|
||||||
|
TypeParameter = " ",
|
||||||
|
Unit = " ",
|
||||||
|
Value = " ",
|
||||||
|
Variable = " ",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return M
|
||||||
173
lua/rayandrew/util.lua
Normal file
173
lua/rayandrew/util.lua
Normal file
|
|
@ -0,0 +1,173 @@
|
||||||
|
-- shamelessly copied from
|
||||||
|
-- https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/util/init.lua
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
---@param on_attach fun(client, buffer)
|
||||||
|
function M.on_attach(on_attach)
|
||||||
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
|
callback = function(args)
|
||||||
|
local buffer = args.buf
|
||||||
|
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||||
|
on_attach(client, buffer)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.fg(name)
|
||||||
|
---@type {foreground?:number}?
|
||||||
|
local hl = vim.api.nvim_get_hl and vim.api.nvim_get_hl(0, { name = name })
|
||||||
|
or vim.api.nvim_get_hl_by_name(name, true)
|
||||||
|
local fg = hl and hl.fg or hl.foreground
|
||||||
|
return fg and { fg = string.format("#%06x", fg) }
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.map(mode, lhs, rhs, opts)
|
||||||
|
local has_handler, handler = pcall(require, "lazy.core.handler")
|
||||||
|
if has_handler then
|
||||||
|
local keys = handler.handlers.keys
|
||||||
|
---@cast keys LazyKeysHandler
|
||||||
|
-- do not create the keymap if a lazy keys handler exists
|
||||||
|
if not keys.active[keys.parse({ lhs, mode = mode }).id] then
|
||||||
|
opts = opts or {}
|
||||||
|
opts.silent = opts.silent ~= false
|
||||||
|
vim.keymap.set(mode, lhs, rhs, opts)
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.keymap.set(mode, lhs, rhs, opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
M.root_patterns = { ".git", "lua" }
|
||||||
|
|
||||||
|
-- returns the root directory based on:
|
||||||
|
-- * lsp workspace folders
|
||||||
|
-- * lsp root_dir
|
||||||
|
-- * root pattern of filename of the current buffer
|
||||||
|
-- * root pattern of cwd
|
||||||
|
---@return string
|
||||||
|
function M.get_root()
|
||||||
|
---@type string?
|
||||||
|
local path = vim.api.nvim_buf_get_name(0)
|
||||||
|
path = path ~= "" and vim.loop.fs_realpath(path) or nil
|
||||||
|
---@type string[]
|
||||||
|
local roots = {}
|
||||||
|
if path then
|
||||||
|
for _, client in pairs(vim.lsp.get_active_clients({ bufnr = 0 })) do
|
||||||
|
local workspace = client.config.workspace_folders
|
||||||
|
local paths = workspace
|
||||||
|
and vim.tbl_map(function(ws)
|
||||||
|
return vim.uri_to_fname(ws.uri)
|
||||||
|
end, workspace)
|
||||||
|
or client.config.root_dir and { client.config.root_dir }
|
||||||
|
or {}
|
||||||
|
for _, p in ipairs(paths) do
|
||||||
|
local r = vim.loop.fs_realpath(p)
|
||||||
|
if path:find(r, 1, true) then
|
||||||
|
roots[#roots + 1] = r
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
table.sort(roots, function(a, b)
|
||||||
|
return #a > #b
|
||||||
|
end)
|
||||||
|
---@type string?
|
||||||
|
local root = roots[1]
|
||||||
|
if not root then
|
||||||
|
path = path and vim.fs.dirname(path) or vim.loop.cwd()
|
||||||
|
---@type string?
|
||||||
|
root = vim.fs.find(M.root_patterns, { path = path, upward = true })[1]
|
||||||
|
root = root and vim.fs.dirname(root) or vim.loop.cwd()
|
||||||
|
end
|
||||||
|
---@cast root string
|
||||||
|
return root
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.telescope(builtin, opts)
|
||||||
|
local params = { builtin = builtin, opts = opts }
|
||||||
|
return function()
|
||||||
|
builtin = params.builtin
|
||||||
|
opts = params.opts
|
||||||
|
opts = vim.tbl_deep_extend("force", { cwd = M.get_root() }, opts or {})
|
||||||
|
if builtin == "files" then
|
||||||
|
if vim.loop.fs_stat((opts.cwd or vim.loop.cwd()) .. "/.git") then
|
||||||
|
opts.show_untracked = true
|
||||||
|
builtin = "git_files"
|
||||||
|
else
|
||||||
|
builtin = "find_files"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if opts.cwd and opts.cwd ~= vim.loop.cwd() then
|
||||||
|
opts.attach_mappings = function(_, map)
|
||||||
|
map("i", "<a-c>", function()
|
||||||
|
local action_state = require("telescope.actions.state")
|
||||||
|
local line = action_state.get_current_line()
|
||||||
|
M.telescope(
|
||||||
|
params.builtin,
|
||||||
|
vim.tbl_deep_extend(
|
||||||
|
"force",
|
||||||
|
{},
|
||||||
|
params.opts or {},
|
||||||
|
{ cwd = false, default_text = line }
|
||||||
|
)
|
||||||
|
)()
|
||||||
|
end)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
require("telescope.builtin")[builtin](opts)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
---@type table<string, LazyFloat>
|
||||||
|
local terminals = {}
|
||||||
|
|
||||||
|
function M.float_term(cmd, opts)
|
||||||
|
opts = vim.tbl_deep_extend("force", {
|
||||||
|
ft = "lazyterm",
|
||||||
|
size = { width = 0.9, height = 0.9 },
|
||||||
|
}, opts or {}, { persistent = true })
|
||||||
|
---@cast opts LazyCmdOptions|{interactive?:boolean, esc_esc?:false}
|
||||||
|
|
||||||
|
local termkey = vim.inspect({
|
||||||
|
cmd = cmd or "shell",
|
||||||
|
cwd = opts.cwd,
|
||||||
|
env = opts.env,
|
||||||
|
count = vim.v.count1,
|
||||||
|
})
|
||||||
|
|
||||||
|
if terminals[termkey] and terminals[termkey]:buf_valid() then
|
||||||
|
terminals[termkey]:toggle()
|
||||||
|
else
|
||||||
|
terminals[termkey] = require("lazy.util").float_term(cmd, opts)
|
||||||
|
local buf = terminals[termkey].buf
|
||||||
|
vim.b[buf].lazyterm_cmd = cmd
|
||||||
|
if opts.esc_esc == false then
|
||||||
|
vim.keymap.set("t", "<esc>", "<esc>", { buffer = buf, nowait = true })
|
||||||
|
end
|
||||||
|
if opts.ctrl_hjkl == false then
|
||||||
|
vim.keymap.set("t", "<c-h>", "<c-h>", { buffer = buf, nowait = true })
|
||||||
|
vim.keymap.set("t", "<c-j>", "<c-j>", { buffer = buf, nowait = true })
|
||||||
|
vim.keymap.set("t", "<c-k>", "<c-k>", { buffer = buf, nowait = true })
|
||||||
|
vim.keymap.set("t", "<c-l>", "<c-l>", { buffer = buf, nowait = true })
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("BufEnter", {
|
||||||
|
buffer = buf,
|
||||||
|
callback = function()
|
||||||
|
vim.cmd.startinsert()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
return terminals[termkey]
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.has(plugin)
|
||||||
|
return require("lazy.core.config").spec.plugins[plugin] ~= nil
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
3
stylua.toml
Normal file
3
stylua.toml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
indent_type = "Spaces"
|
||||||
|
indent_width = 2
|
||||||
|
column_width = 80
|
||||||
Loading…
Reference in a new issue