initial commit for dev-env

This commit is contained in:
pika 2024-08-17 20:25:24 +02:00
parent 9171060e62
commit a97049a1d1
26 changed files with 153 additions and 478 deletions

View file

@ -42,7 +42,7 @@ map("n", "<leader>x", "<cmd>bd!<CR>")
map("n", "<leader>C", "<cmd>ColorizerToggle<CR>")
--─< Toggle NvimTree >─────────────────────────────────────────────────────────────────
map("n", "<leader>e", ":NvimTreeToggle<CR>", { noremap = true, silent = true, desc = "[e]xplorer" })
map("n", "<leader>e", ":Neotree toggle<CR>", { noremap = true, silent = true, desc = "[e]xplorer" })
-- ─< Disable arrow keys in normal mode >───────────────────────────────────────────────
map("n", "<left>", '<cmd>echo "Use h to move!!"<CR>')

View file

@ -1,22 +1,35 @@
-- Bootstrap lazy.nvim
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,
})
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({ { import = "pika.plugins" }, { import = "pika.plugins.lsp" } }, {
checker = {
enabled = true,
notify = true,
},
change_detection = {
notify = true,
},
-- Make sure to setup `mapleader` and `maplocalleader` before
-- loading lazy.nvim so that mappings are correct.
-- This is also a good place to setup other settings (vim.opt)
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
-- Setup lazy.nvim
require("lazy").setup({
spec = {
-- import your plugins
{ import = "pika.plugins" },
},
-- Configure any other settings here. See the documentation for more details.
-- colorscheme that will be used when installing plugins.
install = { colorscheme = { "eldritch" } },
-- automatically check for plugin updates
checker = { enabled = true },
})

View file

@ -1,36 +0,0 @@
return {
"goolord/alpha-nvim",
event = "VimEnter",
config = function()
local alpha = require("alpha")
local dashboard = require("alpha.themes.dashboard")
-- Set header
dashboard.section.header.val = {
" ",
" ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ ",
" ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ ",
" ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ ",
" ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ ",
" ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ ",
" ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ",
" ",
}
-- Set menu
dashboard.section.buttons.val = {
dashboard.button("e", " > New File", "<cmd>ene<CR>"),
dashboard.button("SPC ee", " > Toggle file explorer", "<cmd>NvimTreeToggle<CR>"),
dashboard.button("SPC ff", "󰱼 > Find File", "<cmd>Telescope find_files<CR>"),
dashboard.button("SPC fs", " > Find Word", "<cmd>Telescope live_grep<CR>"),
dashboard.button("SPC wr", "󰁯 > Restore Session For Current Directory", "<cmd>SessionRestore<CR>"),
dashboard.button("q", " > Quit NVIM", "<cmd>qa<CR>"),
}
-- Send config to alpha
alpha.setup(dashboard.opts)
-- Disable folding on alpha buffer
vim.cmd([[autocmd FileType alpha setlocal nofoldenable]])
end,
}

View file

@ -1,16 +0,0 @@
return {
"rmagatti/auto-session",
config = function()
local auto_session = require("auto-session")
auto_session.setup({
auto_restore_enabled = false,
auto_session_suppress_dirs = { "~/", "~/Dev/", "~/Downloads", "~/Documents", "~/Desktop/" },
})
local keymap = vim.keymap
keymap.set("n", "<leader>wr", "<cmd>SessionRestore<CR>", { desc = "Restore session for cwd" }) -- restore last workspace session for current directory
keymap.set("n", "<leader>ws", "<cmd>SessionSave<CR>", { desc = "Save session for auto session root dir" }) -- save workspace session for current working directory
end,
}

View file

@ -20,3 +20,4 @@ return {
vim.keymap.set("n", "<S-Tab>", "<cmd>BufferLineCyclePrev<CR>")
end,
}

View file

@ -1,41 +0,0 @@
-- using lazy.nvim
return {
"LintaoAmons/cd-project.nvim",
config = function()
require("cd-project").setup({
-- this json file is acting like a database to update and read the projects in real time.
-- So because it's just a json file, you can edit directly to add more paths you want manually
projects_config_filepath = vim.fs.normalize(vim.fn.stdpath("config") .. "/cd-project.nvim.json"),
-- this controls the behaviour of `CdProjectAdd` command about how to get the project directory
project_dir_pattern = { ".git", ".gitignore", "Cargo.toml", "package.json", "go.mod" },
choice_format = "both", -- optional, you can switch to "name" or "path"
projects_picker = "vim-ui", -- optional, you can switch to `telescope`
auto_register_project = false, -- optional, toggle on/off the auto add project behaviour
-- do whatever you like by hooks
hooks = {
{
callback = function(dir)
vim.notify("switched to dir: " .. dir)
end,
},
{
callback = function(_)
vim.cmd("Telescope find_files")
end,
},
{
callback = function(dir)
vim.notify("switched to dir: " .. dir)
end, -- required, action when trigger the hook
name = "cd hint", -- optional
order = 1, -- optional, the exection order if there're multiple hooks to be trigger at one point
pattern = "cd-project.nvim", -- optional, trigger hook if contains pattern
trigger_point = "DISABLE", -- optional, enum of trigger_points, default to `AFTER_CD`
match_rule = function(dir) -- optional, a function return bool. if have this fields, then pattern will be ignored
return true
end,
},
},
})
end,
}

View file

@ -4,9 +4,7 @@ return {
"sontungexpt/witch",
-- priority = 1000,
lazy = false,
config = function(_, opts)
require("witch").setup(opts)
end,
opts = {},
},
{ "savq/melange-nvim" },
@ -37,10 +35,11 @@ return {
})
end,
},
{
"LazyVim/LazyVim",
opts = {
colorscheme = "melange",
},
},
{
"eldritch-theme/eldritch.nvim",
lazy = false,
opts = {},
}
}

View file

@ -0,0 +1,78 @@
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,
},
{
"folke/persistence.nvim",
event = "BufReadPre",
opts = {},
-- stylua: ignore
keys = {
{ "<leader>qs", function() require("persistence").load() end, desc = "Restore Session" },
{ "<leader>ql", function() require("persistence").load({ last = true }) end, desc = "Restore Last Session" },
{ "<leader>qd", function() require("persistence").stop() end, desc = "Don't Save Current Session" },
},
}
}

View file

@ -1,4 +0,0 @@
return {
"stevearc/dressing.nvim",
event = "VeryLazy",
}

View file

@ -1,41 +0,0 @@
return {
"stevearc/conform.nvim",
event = { "BufReadPre", "BufNewFile" },
config = function()
local conform = require("conform")
conform.setup({
formatters_by_ft = {
javascript = { "prettier" },
typescript = { "prettier" },
javascriptreact = { "prettier" },
typescriptreact = { "prettier" },
svelte = { "prettier" },
css = { "prettier" },
-- html = { 'prettier' },
fish = { "fish_indent" },
php = { "pretty-php" },
json = { "yq" },
yaml = { "yq" },
markdown = { "prettier" },
graphql = { "prettier" },
liquid = { "prettier" },
sh = { "shfmt" },
lua = { "stylua" },
},
format_on_save = {
lsp_fallback = false,
async = false,
timeout_ms = 1000,
},
})
vim.keymap.set({ "n", "v" }, "<leader>mp", function()
conform.format({
lsp_fallback = true,
async = false,
timeout_ms = 1000,
})
end, { desc = "Format file or range (in visual mode)" })
end,
}

View file

@ -1,47 +0,0 @@
return {
"lewis6991/gitsigns.nvim",
event = { "BufReadPre", "BufNewFile" },
opts = {
on_attach = function(bufnr)
local gs = package.loaded.gitsigns
local function map(mode, l, r, desc)
vim.keymap.set(mode, l, r, { buffer = bufnr, desc = desc })
end
-- Navigation
map("n", "]h", gs.next_hunk, "Next Hunk")
map("n", "[h", gs.prev_hunk, "Prev Hunk")
-- Actions
map("n", "<leader>hs", gs.stage_hunk, "Stage hunk")
map("n", "<leader>hr", gs.reset_hunk, "Reset hunk")
map("v", "<leader>hs", function()
gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
end, "Stage hunk")
map("v", "<leader>hr", function()
gs.reset_hunk({ vim.fn.line("."), vim.fn.line("v") })
end, "Reset hunk")
map("n", "<leader>hS", gs.stage_buffer, "Stage buffer")
map("n", "<leader>hR", gs.reset_buffer, "Reset buffer")
map("n", "<leader>hu", gs.undo_stage_hunk, "Undo stage hunk")
map("n", "<leader>hp", gs.preview_hunk, "Preview hunk")
map("n", "<leader>hb", function()
gs.blame_line({ full = true })
end, "Blame line")
map("n", "<leader>hB", gs.toggle_current_line_blame, "Toggle line blame")
map("n", "<leader>hd", gs.diffthis, "Diff this")
map("n", "<leader>hD", function()
gs.diffthis("~")
end, "Diff this ~")
-- Text object
map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>", "Gitsigns select hunk")
end,
},
}

View file

@ -1,19 +0,0 @@
return {
"kdheepak/lazygit.nvim",
cmd = {
"LazyGit",
"LazyGitConfig",
"LazyGitCurrentFile",
"LazyGitFilter",
"LazyGitFilterCurrentFile",
},
-- optional for floating window border decoration
dependencies = {
"nvim-lua/plenary.nvim",
},
-- setting the keybinding for LazyGit with 'keys' is recommended in
-- order to load the plugin when the command is run for the first time
keys = {
{ "<leader>lg", "<cmd>LazyGit<cr>", desc = "Open lazy git" },
},
}

View file

@ -1,35 +0,0 @@
return {
"mfussenegger/nvim-lint",
event = { "BufReadPre", "BufNewFile" },
config = function()
local lint = require("lint")
lint.linters_by_ft = {
javascript = { "eslint_d" },
typescript = { "eslint_d" },
javascriptreact = { "eslint_d" },
typescriptreact = { "eslint_d" },
git = { "gitlint" },
json = { "jsonlint" },
markdown = { "vale" },
fish = { "fish" },
php = { "php" },
yaml = { "yamllint" },
css = { "stylelint" },
sh = { "shellcheck" },
}
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
group = lint_augroup,
callback = function()
lint.try_lint()
end,
})
vim.keymap.set("n", "<leader>l", function()
lint.try_lint()
end, { desc = "Trigger linting for current file" })
end,
}

View file

@ -1,71 +0,0 @@
-- return {
-- "nvim-lualine/lualine.nvim",
-- dependencies = { "nvim-tree/nvim-web-devicons" },
-- config = function()
-- local lualine = require("lualine")
-- local lazy_status = require("lazy.status") -- to configure lazy pending updates count
--
-- local colors = {
-- blue = "#57a5e5",
-- green = "#70c2be",
-- violet = "#aaaaff",
-- yellow = "#dbb651",
-- red = "#e75a7c",
-- fg = "#f1e9dc",
-- bg = "#31332e",
-- inactive_bg = "#3a3d37",
-- }
--
-- local my_lualine_theme = {
-- normal = {
-- a = { bg = colors.blue, fg = colors.bg, gui = "bold" },
-- b = { bg = colors.bg, fg = colors.fg },
-- c = { bg = colors.bg, fg = colors.fg },
-- },
-- insert = {
-- a = { bg = colors.green, fg = colors.bg, gui = "bold" },
-- b = { bg = colors.bg, fg = colors.fg },
-- c = { bg = colors.bg, fg = colors.fg },
-- },
-- visual = {
-- a = { bg = colors.violet, fg = colors.bg, gui = "bold" },
-- b = { bg = colors.bg, fg = colors.fg },
-- c = { bg = colors.bg, fg = colors.fg },
-- },
-- command = {
-- a = { bg = colors.yellow, fg = colors.bg, gui = "bold" },
-- b = { bg = colors.bg, fg = colors.fg },
-- c = { bg = colors.bg, fg = colors.fg },
-- },
-- replace = {
-- a = { bg = colors.red, fg = colors.bg, gui = "bold" },
-- b = { bg = colors.bg, fg = colors.fg },
-- c = { bg = colors.bg, fg = colors.fg },
-- },
-- inactive = {
-- a = { bg = colors.inactive_bg, fg = colors.semilightgray, gui = "bold" },
-- b = { bg = colors.inactive_bg, fg = colors.semilightgray },
-- c = { bg = colors.inactive_bg, fg = colors.semilightgray },
-- },
-- }
--
-- -- configure lualine with modified theme
-- lualine.setup({
-- options = {
-- theme = my_lualine_theme,
-- },
-- sections = {
-- lualine_x = {
-- {
-- lazy_status.updates,
-- cond = lazy_status.has_updates,
-- color = { fg = "#ff9e64" },
-- },
-- { "encoding" },
-- { "fileformat" },
-- { "filetype" },
-- },
-- },
-- })
-- end,
-- }

View file

@ -1,10 +0,0 @@
return {
"MeanderingProgrammer/markdown.nvim",
name = "render-markdown", -- Only needed if you have another plugin named markdown.nvim
dependencies = { "nvim-treesitter/nvim-treesitter", "echasnovski/mini.nvim" }, -- if you use the mini.nvim suite
-- dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.icons' }, -- if you use standalone mini plugins
-- dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, -- if you prefer nvim-web-devicons
config = function()
require("render-markdown").setup({})
end,
}

View file

@ -0,0 +1,22 @@
return {
{
"nvim-neo-tree/neo-tree.nvim",
opts = {
window = {
mappings = {
["l"] = "open",
["o"] = "open",
["h"] = "close_node",
["C-v"] = "open_split",
},
},
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
-- "MunifTanjim/nui.nvim",
"3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information
}
}
}
}

View file

@ -1,65 +0,0 @@
return {
'nvim-tree/nvim-tree.lua',
dependencies = 'nvim-tree/nvim-web-devicons',
config = function()
local nvimtree = require 'nvim-tree'
-- recommended settings from nvim-tree documentation
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
nvimtree.setup {
view = {
width = 24,
relativenumber = true,
},
-- change folder arrow icons
renderer = {
indent_markers = {
enable = true,
-- icons = {
-- corner = '󱞩', -- Light Arc Up and Right
-- edge = '', -- Box Drawings Heavy Vertical
-- item = '', -- Box Drawings Heavy Vertical and Right
-- none = ' ', -- default: (empty space)
-- },
},
icons = {
glyphs = {
folder = {
arrow_closed = '', -- arrow when folder is closed
arrow_open = '', -- arrow when folder is open
},
default = '',
symlink = '',
git = {
unstaged = '',
staged = '',
unmerged = '',
renamed = '󰘦',
untracked = '󰓒',
deleted = '',
-- ignored = '󱥸',
},
},
},
},
-- -- disable window_picker for
-- -- explorer to work well with
-- -- window splits
-- actions = {
-- open_file = {
-- window_picker = {
-- enable = false,
-- },
-- },
-- },
filters = {
custom = { '.DS_Store' },
},
git = {
ignore = false,
},
}
end,
}

View file

@ -4,25 +4,12 @@ return {
dependencies = {
"nvim-lua/plenary.nvim",
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
"nvim-tree/nvim-web-devicons",
"folke/todo-comments.nvim",
"echasnovski/mini.icons",
},
config = function()
local telescope = require("telescope")
local actions = require("telescope.actions")
local transform_mod = require("telescope.actions.mt").transform_mod
local trouble = require("trouble")
local trouble_telescope = require("trouble.providers.telescope")
-- or create your custom action
local custom_actions = transform_mod({
open_trouble_qflist = function(prompt_bufnr)
trouble.toggle("quickfix")
end,
})
local trouble_telescope = require("trouble.sources.telescope")
-- local transform_mod = require("telescope.actions.mt").transform_mod
telescope.setup({
defaults = {
@ -31,8 +18,6 @@ return {
i = {
["<C-k>"] = actions.move_selection_previous, -- move to prev result
["<C-j>"] = actions.move_selection_next, -- move to next result
["<C-q>"] = actions.send_selected_to_qflist + custom_actions.open_trouble_qflist,
["<C-t>"] = trouble_telescope.open, -- Updated line
},
},
},
@ -46,7 +31,6 @@ return {
-- Telescope mappings
map("n", "<leader>sf", "<cmd>Telescope find_files<CR>", { noremap = true, silent = true, desc = "Find Files" })
map("n", "<leader>sw", "<cmd>Telescope live_grep<CR>", { noremap = true, silent = true, desc = "Search Word" })
map("n", "<leader>sn", "<cmd>Telescope neovim<CR>", { noremap = true, silent = true, desc = "Neovim Files" })
map("n", "<leader><leader>", "<cmd>Telescope buffers<CR>", { noremap = true, silent = true, desc = "Buffers" })
local builtin = require("telescope.builtin")
@ -58,11 +42,11 @@ return {
map("n", "<leader>sk", builtin.keymaps, { desc = "[S]earch [K]eymaps" })
map("n", "<leader>sg", builtin.live_grep, { desc = "[S]earch by [G]rep" })
map("n", "<leader>sd", builtin.diagnostics, { desc = "[S]earch [D]iagnostics" })
map("n", "<leader>sr", builtin.resume, { desc = "[S]earch [R]esume" })
-- map("n", "<leader>sr", builtin.resume, { desc = "[S]earch [R]esume" })
map("n", "<leader>s.", builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
map("n", "<leader><leader>", builtin.buffers, { desc = "[ ] Find existing buffers" })
map("n", "<leader>T", "<CMD>:Telescope colorscheme<CR>")
map("n", "<leader>T", "<cmd>Telescope colorscheme<CR>")
map("n", "<leader>q", vim.cmd.q)
-- Additional custom mappings
map("n", "<leader>/", function()

View file

@ -1,21 +0,0 @@
return {
"folke/todo-comments.nvim",
event = { "BufReadPre", "BufNewFile" },
dependencies = { "nvim-lua/plenary.nvim" },
config = function()
local todo_comments = require("todo-comments")
-- set keymaps
local keymap = vim.keymap -- for conciseness
keymap.set("n", "]t", function()
todo_comments.jump_next()
end, { desc = "Next todo comment" })
keymap.set("n", "[t", function()
todo_comments.jump_prev()
end, { desc = "Previous todo comment" })
todo_comments.setup()
end,
}

View file

@ -62,3 +62,4 @@ return {
})
end,
}

View file

@ -1,12 +0,0 @@
return {
"folke/trouble.nvim",
dependencies = { "nvim-tree/nvim-web-devicons", "folke/todo-comments.nvim" },
keys = {
{ "<leader>xx", "<cmd>TroubleToggle<CR>", desc = "Open/close trouble list" },
{ "<leader>xw", "<cmd>TroubleToggle workspace_diagnostics<CR>", desc = "Open trouble workspace diagnostics" },
{ "<leader>xd", "<cmd>TroubleToggle document_diagnostics<CR>", desc = "Open trouble document diagnostics" },
{ "<leader>xq", "<cmd>TroubleToggle quickfix<CR>", desc = "Open trouble quickfix list" },
{ "<leader>xl", "<cmd>TroubleToggle loclist<CR>", desc = "Open trouble location list" },
{ "<leader>xt", "<cmd>TodoTrouble<CR>", desc = "Open todos in trouble" },
},
}