add nvim config & wallpaper

This commit is contained in:
蓝莓小果冻 2024-08-09 12:44:27 +08:00
parent 5f6cff5bc4
commit b79b9df668
56 changed files with 3640 additions and 0 deletions

26
nvim/init.lua Normal file
View File

@ -0,0 +1,26 @@
-- ██
-- ░░
-- ███████ █████ ██████ ██ ██ ██ ██████████
-- ░░██░░░██ ██░░░██ ██░░░░██░██ ░██░██░░██░░██░░██
-- ░██ ░██░███████░██ ░██░░██ ░██ ░██ ░██ ░██ ░██
-- ░██ ░██░██░░░░ ░██ ░██ ░░████ ░██ ░██ ░██ ░██
-- ███ ░██░░██████░░██████ ░░██ ░██ ███ ░██ ░██
-- ░░░ ░░ ░░░░░░ ░░░░░░ ░░ ░░ ░░░ ░░ ░░
--
-- ▓▓▓▓▓▓▓▓▓▓
-- ░▓ author ▓ xero <x@xero.style>
-- ░▓ code ▓ https://code.x-e.ro/dotfiles
-- ░▓ mirror ▓ https://git.io/.files
-- ░▓▓▓▓▓▓▓▓▓▓
-- ░░░░░░░░░░
require("general")
require("ui")
require("commands")
require("plugins")
if vim.g.noplugins == nil then
require("plugins")
else
local colors = vim.fn.stdpath("data") .. "/lazy/miasma.nvim/colors/miasma.vim"
if vim.fn.filereadable(colors) then vim.cmd('source ' .. colors) end
end

89
nvim/lua/commands.lua Normal file
View File

@ -0,0 +1,89 @@
-- ██
-- ░░
-- ███████ █████ ██████ ██ ██ ██ ██████████
-- ░░██░░░██ ██░░░██ ██░░░░██░██ ░██░██░░██░░██░░██
-- ░██ ░██░███████░██ ░██░░██ ░██ ░██ ░██ ░██ ░██
-- ░██ ░██░██░░░░ ░██ ░██ ░░████ ░██ ░██ ░██ ░██
-- ███ ░██░░██████░░██████ ░░██ ░██ ███ ░██ ░██
-- ░░░ ░░ ░░░░░░ ░░░░░░ ░░ ░░ ░░░ ░░ ░░
--
-- ▓▓▓▓▓▓▓▓▓▓
-- ░▓ author ▓ xero <x@xero.style>
-- ░▓ code ▓ https://code.x-e.ro/dotfiles
-- ░▓ mirror ▓ https://git.io/.files
-- ░▓▓▓▓▓▓▓▓▓▓
-- ░░░░░░░░░░
--
local f = require("utils.functions")
local r = require("utils.remaps")
-- buffers
r.noremap("n", "<c-n>", ":bn<cr>", "next buffer")
r.noremap("n", "<c-p>", ":bp<cr>", "prev buffer")
r.noremap("n", "<c-x>", ":bd<cr>", "exit buffer")
-- tabs
r.noremap("n", "<leader><tab>l", "<cmd>tablast<cr>", "Last Tab")
r.noremap("n", "<leader><tab>f", "<cmd>tabfirst<cr>", "First Tab")
r.noremap("n", "<leader><tab><tab>", "<cmd>tabnew<cr>", "New Tab")
r.noremap("n", "<leader><tab>]", "<cmd>tabnext<cr>", "Next Tab")
r.noremap("n", "<leader><tab>d", "<cmd>tabclose<cr>", "Close Tab")
r.noremap("n", "<leader><tab>[", "<cmd>tabprevious<cr>", "Previous Tab")
-- json pretty print
r.noremap("n", "<leader>j", ":%!jq .<cr>", "jq format")
-- remove highlighting
r.noremap("n", "<esc><esc>", ":nohlsearch<cr>", "remove highlighting", { silent = true })
-- remove trailing white space
f.cmd("Nows", "%s/\\s\\+$//e", { desc = "remove trailing whitespace" })
-- remove blank lines
f.cmd("Nobl", "g/^\\s*$/d", { desc = "remove blank lines" })
-- spell check
f.cmd("Sp", "setlocal spell! spell?", { desc = "toggle spell check" })
r.noremap("n", "<leader>s", ":Sp<cr>", "toggle spell check")
-- ios keeb
r.noremap("n", "<a-left>", "0", "ios home key")
r.noremap("i", "<a-left>", "0", "ios home key")
-- pseudo tail functionality
f.cmd("Tail", 'set autoread | au CursorHold * checktime | call feedkeys("G")', { desc = "pseudo tail functionality" })
-- make current buffer executable
f.cmd("Chmodx", "!chmod a+x %", { desc = "make current buffer executable" })
r.noremap("n", "<leader>x", ":Chmodx<cr>", "chmod +x buffer")
-- fix syntax highlighting
f.cmd("FixSyntax", "syntax sync fromstart", { desc = "reload syntax highlighting" })
-- vertical term
f.cmd("T", ":vs | :set nu! | :term", { desc = "vertical terminal" })
-- the worst place in the universe
r.noremap("n", "Q", "<nop>", "")
-- move blocks
r.noremap("v", "J", ":m '>+1<CR>gv=gv", "move block up")
r.noremap("v", "K", ":m '<-2<CR>gv=gv", "move block down")
-- focus scrolling
r.noremap("n", "<C-d>", "<C-d>zz", "scroll down")
r.noremap("n", "<C-u>", "<C-u>zz", "scroll up")
-- focus highlight searches
r.noremap("n", "n", "nzzzv", "next match")
r.noremap("n", "N", "Nzzzv", "prev match")
-- remove trailing whitespaces and ^M chars
f.autocmd({ "BufWritePre" }, {
pattern = { "*" },
callback = function(_)
local save_cursor = vim.fn.getpos(".")
vim.cmd [[%s/\s\+$//e]]
vim.fn.setpos(".", save_cursor)
end,
})

83
nvim/lua/general.lua Normal file
View File

@ -0,0 +1,83 @@
-- ██
-- ░░
-- ███████ █████ ██████ ██ ██ ██ ██████████
-- ░░██░░░██ ██░░░██ ██░░░░██░██ ░██░██░░██░░██░░██
-- ░██ ░██░███████░██ ░██░░██ ░██ ░██ ░██ ░██ ░██
-- ░██ ░██░██░░░░ ░██ ░██ ░░████ ░██ ░██ ░██ ░██
-- ███ ░██░░██████░░██████ ░░██ ░██ ███ ░██ ░██
-- ░░░ ░░ ░░░░░░ ░░░░░░ ░░ ░░ ░░░ ░░ ░░
--
-- ▓▓▓▓▓▓▓▓▓▓
-- ░▓ author ▓ xero <x@xero.style>
-- ░▓ code ▓ https://code.x-e.ro/dotfiles
-- ░▓ mirror ▓ https://git.io/.files
-- ░▓▓▓▓▓▓▓▓▓▓
-- ░░░░░░░░░░
--
-- security
vim.opt.modelines = 0
-- set leader key to comma
vim.g.mapleader = ","
-- hide buffers, not close them
vim.opt.hidden = true
-- maintain undo history between sessions
vim.opt.swapfile = false
vim.opt.undofile = true
vim.opt.undodir = vim.fn.stdpath("data") .. "/undo"
-- scroll bounds
vim.o.scrolloff = 13
-- ipad scrolling
vim.opt.mouse = "a"
-- fuzzy find
vim.opt.path:append("**")
-- lazy file name tab completion
vim.opt.wildmode = "list:longest,list:full"
vim.opt.wildmenu = true
vim.opt.wildignorecase = true
-- ignore files vim doesnt use
vim.opt.wildignore:append(".git,.hg,.svn")
vim.opt.wildignore:append(".aux,*.out,*.toc")
vim.opt.wildignore:append(".o,*.obj,*.exe,*.dll,*.manifest,*.rbc,*.class")
vim.opt.wildignore:append(".ai,*.bmp,*.gif,*.ico,*.jpg,*.jpeg,*.png,*.psd,*.webp")
vim.opt.wildignore:append(".avi,*.divx,*.mp4,*.webm,*.mov,*.m2ts,*.mkv,*.vob,*.mpg,*.mpeg")
vim.opt.wildignore:append(".mp3,*.oga,*.ogg,*.wav,*.flac")
vim.opt.wildignore:append(".eot,*.otf,*.ttf,*.woff")
vim.opt.wildignore:append(".doc,*.pdf,*.cbr,*.cbz")
vim.opt.wildignore:append(".zip,*.tar.gz,*.tar.bz2,*.rar,*.tar.xz,*.kgb")
vim.opt.wildignore:append(".swp,.lock,.DS_Store,._*")
vim.opt.wildignore:append(".,..")
-- case insensitive search
vim.opt.ignorecase = true
vim.opt.smartcase = true
vim.opt.infercase = true
-- make backspace behave in a sane manner
vim.opt.backspace = "indent,eol,start"
-- searching
vim.opt.hlsearch = true
vim.opt.incsearch = true
vim.opt.inccommand = "split"
-- use indents of 2
vim.opt.shiftwidth = 2
-- tabs are tabs
vim.opt.expandtab = false
-- an indentation every 2 columns
vim.opt.tabstop = 2
-- let backspace delete indent
vim.opt.softtabstop = 2
-- enable auto indentation
vim.opt.autoindent = true

94
nvim/lua/plugins.lua Normal file
View File

@ -0,0 +1,94 @@
-- ██╗ █████╗ ███████╗██╗ ██╗ Z
-- ██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝ Z
-- ██║ ███████║ ███╔╝ ╚████╔╝ z
-- ██║ ██╔══██║ ███╔╝ ╚██╔╝ z
-- ███████╗██║ ██║███████╗ ██║
-- ╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝
local pluginspath = vim.fn.stdpath("data") .. "/lazy"
local lazypath = pluginspath .. "/lazy.nvim"
-- install lazy
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
-- use a protected call so we don't error out on first use
local status_ok, lazy = pcall(require, "lazy")
if not status_ok then
print("lazy just installed, please restart neovim")
return
end
-- install plugins
lazy.setup({
spec = {
require("plugins.miasma"),
require("plugins.osc52-yank"),
require("plugins.git"),
require("plugins.tmux"),
-- require("plugns.scrollbar"),
require("plugins.gitsigns"),
require("plugins.indent"),
require("plugins.luasnip"),
require("plugins.which-key"),
require("plugins.telescope"),
require("plugins.treesitter"),
require("plugins.guess-indent"),
require("plugins.mason"),
require("plugins.lsp"),
require("plugins.cmp"),
require("plugins.trouble"),
require("plugins.comments"),
require("plugins.colorizer"),
require("plugins.surround"),
require("plugins.tint"),
require("plugins.ansi"),
require("plugins.lualine"),
require("plugins.increname"),
require("plugins.fzf"),
require("plugins.devicons"),
require("plugins.matchparen"),
require("plugins.lush"),
require("plugins.alpha"),
require("plugins.dadbod"),
--require("plugins.copilot"),
--require("plugins.mason-dap"),
--{ "xero/sourcerer.vim" },
--{ 'mattn/vim-sl' }, -- train
},
dev = {
path = "~/.local/src",
},
lockfile = vim.fn.stdpath("config") .. "/lua/plugins/lazy-lock.json",
ui = {
size = { width = 0.8, height = 0.8 },
wrap = true,
border = "shadow",
icons = require("utils.icons").lazy,
},
performance = {
cache = {
enabled = true,
},
reset_packpath = true,
rtp = {
disabled_plugins = {
"gzip",
"matchparen",
"netrwPlugin",
"tarPlugin",
"tohtml",
"tutor",
"zipPlugin",
},
},
},
})

View File

@ -0,0 +1,63 @@
return {
'goolord/alpha-nvim',
event = 'VimEnter',
opts = function()
local dashboard = require('alpha.themes.dashboard')
require("alpha.term")
dashboard.section.terminal.command = vim.fn.stdpath("config") .. "/nvim-logo -t"
dashboard.section.terminal.width = 70
dashboard.section.terminal.height = 10
dashboard.section.terminal.opts.redraw = true
dashboard.section.terminal.opts.window_config.zindex = 1
-- offset placment for screenshots
-- dashboard.section.terminal.opts.window_config.col = math.floor((vim.o.columns - 70) / 2 + 20)
-- vim.cmd [[autocmd! User AlphaClosed]]
dashboard.section.buttons.val = {
dashboard.button('i', ' new file', ':ene <BAR> startinsert<CR>'),
dashboard.button('o', ' old files', ':Telescope oldfiles<CR>'),
dashboard.button('f', '󰥨 find file', ':Telescope file_browser<CR>'),
dashboard.button('g', '󰱼 find text', ':Telescope live_grep_args<CR>'),
dashboard.button('h', ' browse git', ':Flog<CR>'),
dashboard.button('l', '󰒲 lazy', ':Lazy<CR>'),
dashboard.button('m', '󱌣 mason', ':Mason<CR>'),
dashboard.button('p', '󰄉 profile', ':Lazy profile<CR>'),
dashboard.button('q', '󰭿 quit', ':qa<CR>'),
}
for _, button in ipairs(dashboard.section.buttons.val) do
button.opts.hl = 'Normal'
button.opts.hl_shortcut = 'Function'
end
dashboard.section.footer.opts.hl = "Special"
dashboard.opts.layout = {
dashboard.section.terminal,
{ type = "padding", val = 4 },
dashboard.section.buttons,
dashboard.section.footer,
}
return dashboard
end,
config = function(_, dashboard)
-- close lazy and re-open when the dashboard is ready
if vim.o.filetype == 'lazy' then
vim.cmd.close()
vim.api.nvim_create_autocmd('User', {
pattern = 'AlphaReady',
callback = function()
require('lazy').show()
end,
})
end
require('alpha').setup(dashboard.opts)
vim.api.nvim_create_autocmd('User', {
pattern = 'LazyVimStarted',
callback = function()
local stats = require('lazy').stats()
local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100)
dashboard.section.footer.val = '󱐋 ' .. stats.count .. ' plugins loaded in ' .. ms .. 'ms'
pcall(vim.cmd.AlphaRedraw)
end,
})
end,
}

View File

@ -0,0 +1,7 @@
return {
"powerman/vim-plugin-AnsiEsc",
lazy = true,
cmd = {
"AnsiEsc",
},
}

89
nvim/lua/plugins/cmp.lua Normal file
View File

@ -0,0 +1,89 @@
return {
"hrsh7th/nvim-cmp",
event = "InsertEnter",
dependencies = {
"hrsh7th/cmp-nvim-lsp-signature-help",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"saadparwaiz1/cmp_luasnip",
"hrsh7th/cmp-nvim-lua",
"windwp/nvim-autopairs",
"onsails/lspkind-nvim",
{ "roobert/tailwindcss-colorizer-cmp.nvim", config = true }
},
config = function()
local cmp = require("cmp")
local lsp_kind = require("lspkind")
local cmp_next = function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif require("luasnip").expand_or_jumpable() then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-expand-or-jump", true, true, true), "")
else
fallback()
end
end
local cmp_prev = function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif require("luasnip").jumpable(-1) then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-jump-prev", true, true, true), "")
else
fallback()
end
end
lsp_kind.init()
---@diagnostic disable-next-line
cmp.setup({
enabled = true,
preselect = cmp.PreselectMode.None,
window = {
completion = cmp.config.window.bordered({
winhighlight = "Normal:Normal,FloatBorder:LspBorderBG,CursorLine:PmenuSel,Search:None",
}),
documentation = cmp.config.window.bordered({
winhighlight = "Normal:Normal,FloatBorder:LspBorderBG,CursorLine:PmenuSel,Search:None",
}),
},
---@diagnostic disable-next-line
view = {
entries = "bordered",
},
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
mapping = {
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<S-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}),
["<tab>"] = cmp_next,
["<down>"] = cmp_next,
["<C-p>"] = cmp_prev,
["<up>"] = cmp_prev,
},
sources = {
{ name = "nvim_lsp_signature_help", group_index = 1 },
{ name = "luasnip", max_item_count = 5, group_index = 1 },
{ name = "nvim_lsp", max_item_count = 20, group_index = 1 },
{ name = "nvim_lua", group_index = 1 },
{ name = "vim-dadbod-completion", group_index = 1 },
{ name = "path", group_index = 2 },
{ name = "buffer", keyword_length = 2, max_item_count = 5, group_index = 2 },
},
})
local presentAutopairs, cmp_autopairs = pcall(require, "nvim-autopairs.completion.cmp")
if not presentAutopairs then
return
end
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } }))
end,
}

View File

@ -0,0 +1,13 @@
return {
"brenoprata10/nvim-highlight-colors",
event = "VeryLazy",
config = function()
local r = require("utils.remaps")
local c = require("nvim-highlight-colors")
c.setup({})
r.which_key("<leader>c", "colorizer")
r.noremap("n", "<leader>c", function()
c.toggle()
end, "toggle colorizer")
end,
}

View File

@ -0,0 +1,16 @@
return {
"terrortylor/nvim-comment",
event = "BufReadPost",
config = function()
require('nvim_comment').setup()
require("which-key").register({
g = {
name = "go",
c = {
name = "comment",
c = "line",
}
}
})
end,
}

View File

@ -0,0 +1,59 @@
return {
-- copilot
{
"zbirenbaum/copilot.lua",
verylazy = true,
cmd = "Copilot",
build = ":Copilot auth",
opts = {
suggestion = { enabled = false },
panel = { enabled = false },
filetypes = {
markdown = true,
help = true,
lua = true,
bash = true,
},
},
},
-- copilot cmp source
{
"nvim-cmp",
dependencies = {
{
"zbirenbaum/copilot-cmp",
verylazy = true,
dependencies = "copilot.lua",
opts = {},
config = function(_, opts)
local copilot_cmp = require("copilot_cmp")
copilot_cmp.setup(opts)
require("utils.functions").on_attach(function(client)
if client.name == "copilot" then
copilot_cmp._on_insert_enter({})
end
end)
end,
},
},
---@param opts cmp.ConfigSchema
opts = function(_, opts)
local cmp = require("cmp")
table.insert(opts, { sources = { name = "copilot", group_index = 2 } })
opts.sorting = {
priority_weight = 2,
comparators = {
require("copilot_cmp.comparators").prioritize,
cmp.config.compare.offset,
cmp.config.compare.exact,
cmp.config.compare.score,
cmp.config.compare.kind,
cmp.config.compare.sort_text,
cmp.config.compare.length,
cmp.config.compare.order,
},
}
end,
},
}

View File

@ -0,0 +1,40 @@
return {
"tpope/vim-dadbod",
dependencies = {
"kristijanhusak/vim-dadbod-ui",
"kristijanhusak/vim-dadbod-completion",
},
opts = {
db_competion = function()
---@diagnostic disable-next-line
require("cmp").setup.buffer { sources = { { name = "vim-dadbod-completion" } } }
end,
},
config = function(_, opts)
vim.g.db_ui_save_location = vim.fn.stdpath "config" .. require("plenary.path").path.sep .. "db_ui"
vim.api.nvim_create_autocmd("FileType", {
pattern = {
"sql",
},
command = [[setlocal omnifunc=vim_dadbod_completion#omni]],
})
vim.api.nvim_create_autocmd("FileType", {
pattern = {
"sql",
"mysql",
"plsql",
},
callback = function()
vim.schedule(opts.db_completion)
end,
})
end,
keys = {
{ "<leader>Dt", "<cmd>DBUIToggle<cr>", desc = "Toggle UI" },
{ "<leader>Df", "<cmd>DBUIFindBuffer<cr>", desc = "Find Buffer" },
{ "<leader>Dr", "<cmd>DBUIRenameBuffer<cr>", desc = "Rename Buffer" },
{ "<leader>Dq", "<cmd>DBUILastQueryInfo<cr>", desc = "Last Query Info" },
},
}

View File

@ -0,0 +1,803 @@
return {
"nvim-tree/nvim-web-devicons",
event = "VeryLazy",
config = function()
require("nvim-web-devicons").setup({
-- yes, this is all the icons w/ an extra space
override = {
["default_icon"] = {
icon = "󱔗 ",
},
[".babelrc"] = {
icon = "",
},
[".bash_profile"] = {
icon = "",
},
[".bashrc"] = {
icon = "",
},
[".ds_store"] = {
icon = "",
},
[".eslintrc"] = {
icon = "",
},
[".gitattributes"] = {
icon = "",
},
[".gitconfig"] = {
icon = "",
},
[".gitignore"] = {
icon = "",
},
[".gitlab-ci.yml"] = {
icon = "",
},
[".gitmodules"] = {
icon = "",
},
[".gvimrc"] = {
icon = "",
},
[".npmignore"] = {
icon = "",
},
[".npmrc"] = {
icon = "",
},
[".settings.json"] = {
icon = "",
},
[".vimrc"] = {
icon = "",
},
[".zprofile"] = {
icon = "",
},
[".zshenv"] = {
icon = "",
},
[".zshrc"] = {
icon = "",
},
["brewfile"] = {
icon = "",
},
["cmakelists.txt"] = {
icon = "",
},
["commit_editmsg"] = {
icon = "",
},
["containerfile"] = {
icon = "󰡨 ",
},
["copying"] = {
icon = "",
},
["copying.lesser"] = {
icon = "",
},
["docker-compose.yml"] = {
icon = "󰡨 ",
},
["docker-compose.yaml"] = {
icon = "󰡨 ",
},
[".dockerignore"] = {
icon = "󰡨 ",
},
["gemfile$"] = {
icon = "",
},
["vagrantfile$"] = {
icon = "",
},
["_gvimrc"] = {
icon = "",
},
["_vimrc"] = {
icon = "",
},
["package.json"] = {
icon = "",
},
["package-lock.json"] = {
icon = "",
},
["node_modules"] = {
icon = "",
},
["favicon.ico"] = {
icon = "",
},
["mix.lock"] = {
icon = "",
},
[".env"] = {
icon = "",
},
["gruntfile"] = {
icon = "",
},
["gulpfile"] = {
icon = "",
},
["rakefile"] = {
icon = "",
},
["procfile"] = {
icon = "",
},
["dockerfile"] = {
icon = "󰡨 ",
},
["build"] = {
icon = "",
},
["workspace"] = {
icon = "",
},
["unlicense"] = {
icon = "",
},
["ai"] = {
icon = "",
},
["awk"] = {
icon = "",
},
["bash"] = {
icon = "",
},
["bat"] = {
icon = "",
},
["bazel"] = {
icon = "",
},
["bzl"] = {
icon = "",
},
["bmp"] = {
icon = "",
},
["c"] = {
icon = "",
},
["c++"] = {
icon = "",
},
["cbl"] = {
icon = "",
},
["cc"] = {
icon = "",
},
["cfg"] = {
icon = "",
},
["cjs"] = {
icon = "",
},
["clj"] = {
icon = "",
},
["cljc"] = {
icon = "",
},
["cljs"] = {
icon = "",
},
["cljd"] = {
icon = "",
},
["cmake"] = {
icon = "",
},
["cob"] = {
icon = "",
},
["cobol"] = {
icon = "",
},
["coffee"] = {
icon = "",
},
["conf"] = {
icon = "",
},
["config.ru"] = {
icon = "",
},
["cp"] = {
icon = "",
},
["cpp"] = {
icon = "",
},
["cpy"] = {
icon = "",
},
["cr"] = {
icon = "",
},
["cs"] = {
icon = "󰌛 ",
},
["csh"] = {
icon = "",
},
["cson"] = {
icon = "",
},
["css"] = {
icon = "",
},
["csv"] = {
icon = "󰈙 ",
},
["cxx"] = {
icon = "",
},
["d"] = {
icon = "",
},
["dart"] = {
icon = "",
},
["db"] = {
icon = "",
},
["desktop"] = {
icon = "",
},
["diff"] = {
icon = "",
},
["doc"] = {
icon = "󰈬 ",
},
["docx"] = {
icon = "󰈬 ",
},
["drl"] = {
icon = "",
},
["dropbox"] = {
icon = "",
},
["dump"] = {
icon = "",
},
["edn"] = {
icon = "",
},
["eex"] = {
icon = "",
},
["ejs"] = {
icon = "",
},
["elm"] = {
icon = "",
},
["epp"] = {
icon = "",
},
["erb"] = {
icon = "",
},
["erl"] = {
icon = "",
},
["ex"] = {
icon = "",
},
["exs"] = {
icon = "",
},
["f#"] = {
icon = "",
},
["f90"] = {
icon = "󱈚 ",
},
["fnl"] = {
icon = "🌜 ",
},
["fish"] = {
icon = "",
},
["fs"] = {
icon = "",
},
["fsi"] = {
icon = "",
},
["fsscript"] = {
icon = "",
},
["fsx"] = {
icon = "",
},
["gd"] = {
icon = "",
},
["gemspec"] = {
icon = "",
},
["gif"] = {
icon = "",
},
["git"] = {
icon = "",
},
["glb"] = {
icon = "",
},
["go"] = {
icon = "",
},
["godot"] = {
icon = "",
},
["graphql"] = {
icon = "",
},
["gql"] = {
icon = "",
},
["h"] = {
icon = "",
},
["haml"] = {
icon = "",
},
["hbs"] = {
icon = "",
},
["heex"] = {
icon = "",
},
["hh"] = {
icon = "",
},
["hpp"] = {
icon = "",
},
["hrl"] = {
icon = "",
},
["hs"] = {
icon = "",
},
["htm"] = {
icon = "",
},
["html"] = {
icon = "",
},
["hxx"] = {
icon = "",
},
["ico"] = {
icon = "",
},
["import"] = {
icon = "",
},
["ini"] = {
icon = "",
},
["java"] = {
icon = "",
},
["jl"] = {
icon = "",
},
["jpeg"] = {
icon = "",
},
["jpg"] = {
icon = "",
},
["js"] = {
icon = "",
},
["test.js"] = {
icon = "",
},
["spec.js"] = {
icon = "",
},
["json"] = {
icon = "",
},
["json5"] = {
icon = "",
},
["jsx"] = {
icon = "",
},
["test.jsx"] = {
icon = "",
},
["spec.jsx"] = {
icon = "",
},
["ksh"] = {
icon = "",
},
["kt"] = {
icon = "",
},
["kts"] = {
icon = "",
},
["leex"] = {
icon = "",
},
["less"] = {
icon = "",
},
["lhs"] = {
icon = "",
},
["license"] = {
icon = "",
},
["lua"] = {
icon = "",
},
["luau"] = {
icon = "",
},
["gnumakefile"] = {
icon = "",
},
["makefile"] = {
icon = "",
},
["mk"] = {
icon = "",
},
["markdown"] = {
icon = "",
},
["material"] = {
icon = "󰔉 ",
},
["md"] = {
icon = "",
},
["mdx"] = {
icon = "",
},
["mint"] = {
icon = "󰌪 ",
},
["mjs"] = {
icon = "",
},
["ml"] = {
icon = "λ ",
},
["mli"] = {
icon = "λ ",
},
["mo"] = {
icon = "",
},
["mustache"] = {
icon = "",
},
["nim"] = {
icon = "",
},
["nix"] = {
icon = "",
},
["opus"] = {
icon = "󰈣 ",
},
["org"] = {
icon = "",
},
["otf"] = {
icon = "",
},
["pck"] = {
icon = "",
},
["pdf"] = {
icon = "",
},
["php"] = {
icon = "",
},
["pl"] = {
icon = "",
},
["pm"] = {
icon = "",
},
["png"] = {
icon = "",
},
["pp"] = {
icon = "",
},
["ppt"] = {
icon = "󰈧 ",
},
["pro"] = {
icon = "",
},
["ps1"] = {
icon = "󰨊 ",
},
["psd1"] = {
icon = "󰨊 ",
},
["psm1"] = {
icon = "󰨊 ",
},
["psb"] = {
icon = "",
},
["psd"] = {
icon = "",
},
["py"] = {
icon = "",
},
["pyc"] = {
icon = "",
},
["pyd"] = {
icon = "",
},
["pyo"] = {
icon = "",
},
["query"] = {
icon = "",
},
["r"] = {
icon = "󰟔 ",
},
["rake"] = {
icon = "",
},
["rb"] = {
icon = "",
},
["README"] = {
icon = "󰑇 ",
},
["README.md"] = {
icon = "󰑇 ",
},
["res"] = {
icon = "",
},
["resi"] = {
icon = "",
},
["rlib"] = {
icon = "",
},
["rmd"] = {
icon = "",
},
["robots.txt"] = {
icon = "󱚤 ",
},
["rproj"] = {
icon = "󰗆 ",
},
["rs"] = {
icon = "",
},
["rss"] = {
icon = "",
},
["sass"] = {
icon = "",
},
["sbt"] = {
icon = "",
},
["scala"] = {
icon = "",
},
["scm"] = {
icon = "󰘧 ",
},
["scss"] = {
icon = "",
},
["sh"] = {
icon = "",
},
["sig"] = {
icon = "λ ",
},
["slim"] = {
icon = "",
},
["sln"] = {
icon = "",
},
["sml"] = {
icon = "λ ",
},
["sql"] = {
icon = "",
},
["sqlite"] = {
icon = "",
},
["sqlite3"] = {
icon = "",
},
["styl"] = {
icon = "",
},
["sublime"] = {
icon = "",
},
["suo"] = {
icon = "",
},
["sv"] = {
icon = "󰍛 ",
},
["svelte"] = {
icon = "",
},
["svh"] = {
icon = "󰍛 ",
},
["svg"] = {
icon = "󰜡 ",
},
["swift"] = {
icon = "",
},
["t"] = {
icon = "",
},
["tbc"] = {
icon = "󰛓 ",
},
["tcl"] = {
icon = "󰛓 ",
},
["terminal"] = {
icon = "",
},
["tex"] = {
icon = "󰙩 ",
},
["tf"] = {
icon = "",
},
["tfvars"] = {
icon = "",
},
["toml"] = {
icon = "",
},
["tres"] = {
icon = "",
},
["ts"] = {
icon = "",
},
["test.ts"] = {
icon = "",
},
["spec.ts"] = {
icon = "",
},
["tscn"] = {
icon = "󰎁 ",
},
["tsx"] = {
icon = "",
},
["test.tsx"] = {
icon = "",
},
["spec.tsx"] = {
icon = "",
},
["twig"] = {
icon = "",
},
["txt"] = {
icon = "󰈙 ",
},
["v"] = {
icon = "󰍛 ",
},
["vala"] = {
icon = "",
},
["vh"] = {
icon = "󰍛 ",
},
["vhd"] = {
icon = "󰍛 ",
},
["vhdl"] = {
icon = "󰍛 ",
},
["vim"] = {
icon = "",
},
["vue"] = {
icon = "",
},
["webmanifest"] = {
icon = "",
},
["webp"] = {
icon = "",
},
["webpack"] = {
icon = "󰜫 ",
},
["xcplayground"] = {
icon = "",
},
["xls"] = {
icon = "󰈛 ",
},
["xlsx"] = {
icon = "󰈛 ",
},
["xml"] = {
icon = "󰗀 ",
},
["xul"] = {
icon = "",
},
["yaml"] = {
icon = "",
},
["yml"] = {
icon = "",
},
["zig"] = {
icon = "",
},
["zsh"] = {
icon = "",
},
["sol"] = {
icon = "󰞻 ",
},
["prisma"] = {
icon = "󰔶 ",
},
["lock"] = {
icon = "",
},
["log"] = {
icon = "󰌱 ",
},
["wasm"] = {
icon = "",
},
["liquid"] = {
icon = "",
},
},
})
end,
}

32
nvim/lua/plugins/fzf.lua Normal file
View File

@ -0,0 +1,32 @@
return {
'ibhagwan/fzf-lua',
event = "VeryLazy",
dependencies = { 'nvim-tree/nvim-web-devicons' },
keys = {
{ "<leader>/c", function() require("fzf-lua").commands() end, desc = "Search commands" },
{ "<leader>/C", function() require("fzf-lua").command_history() end, desc = "Search command history" },
{ "<leader>/f", function() require("fzf-lua").files() end, desc = "Find files" },
{ "<leader>/o", function() require("fzf-lua").oldfiles() end, desc = "Find files" },
{ "<leader>/h", function() require("fzf-lua").highlights() end, desc = "Search highlights" },
{ "<leader>/M", function() require("fzf-lua").marks() end, desc = "Search marks" },
{ "<leader>/k", function() require("fzf-lua").keymaps() end, desc = "Search keymaps" },
{ "<leader>/t", function() require("fzf-lua").treesitter() end, desc = "Search treesitter" },
{ "<leader>/gf", function() require("fzf-lua").git_files() end, desc = "Find git files" },
{ "<leader>/gb", function() require("fzf-lua").git_branches() end, desc = "Search git branches" },
{ "<leader>/gc", function() require("fzf-lua").git_commits() end, desc = "Search git commits" },
{ "<leader>/gC", function() require("fzf-lua").git_bcommits() end, desc = "Search git buffer commits" },
{ "<leader>bc", function() require("fzf-lua").git_bcommits() end, desc = "Search git buffer commits" },
{ "<leader>//", function() require("fzf-lua").resume() end, desc = "Resume FZF" },
},
config = function()
local fzf = require('fzf-lua')
fzf.setup({
keymap = {
fzf = {
['CTRL-Q'] = 'select-all+accept',
},
},
})
fzf.register_ui_select()
end,
}

36
nvim/lua/plugins/git.lua Normal file
View File

@ -0,0 +1,36 @@
return {
"rbong/vim-flog",
event = "VeryLazy",
dependencies = {
"tpope/vim-fugitive",
},
cmd = {
"Flog",
"G",
"GBrowse",
"GDelete",
"GMove",
"GRemove",
"GRename",
"GUnlink",
"Gcd",
"Gclog",
"Gdiffsplit",
"Gdrop",
"Gedit",
"Ggrep",
"Ghdiffsplit",
"Git",
"Glcd",
"Glgrep",
"Gllog",
"Gpedit",
"Gread",
"Gsplit",
"Gtabedit",
"Gvdiffsplit",
"Gvsplit",
"Gwq",
"Gwrite",
},
}

View File

@ -0,0 +1,29 @@
return {
"lewis6991/gitsigns.nvim",
config = function()
local gitsigns = require("gitsigns")
gitsigns.setup({
signs = {
add = { text = '' },
change = { text = '' },
delete = { text = '' },
topdelete = { text = '' },
changedelete = { text = '' },
untracked = { text = '' },
},
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
numhl = false, -- Toggle with `:Gitsigns toggle_nunhl`
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
sign_priority = 9,
watch_gitdir = {
interval = 1000,
},
attach_to_untracked = false,
})
-- if pcall(require, "scrollbar") then
-- require("scrollbar.handlers.gitsigns").setup()
-- end
end,
event = { "BufReadPre", "BufNewFile" },
}

View File

@ -0,0 +1,7 @@
return {
"nmac427/guess-indent.nvim",
event = "VeryLazy",
config = function()
require("guess-indent").setup({})
end,
}

View File

@ -0,0 +1,10 @@
return {
"smjonas/inc-rename.nvim",
lazy = true,
cmd = {
"IncRename",
},
config = function()
require("inc_rename").setup()
end,
}

View File

@ -0,0 +1,20 @@
return {
"lukas-reineke/indent-blankline.nvim",
main = "ibl",
event = "VeryLazy",
config = function()
require("ibl").setup({
scope = {
show_start = false,
},
indent = {
char = "",
tab_char = "",
smart_indent_cap = true,
},
whitespace = {
remove_blankline_trail = true,
},
})
end,
}

View File

@ -0,0 +1,56 @@
{
"LuaSnip": { "branch": "master", "commit": "b84eeb3641b08324287587b426ec974b888390d9" },
"alpha-nvim": { "branch": "main", "commit": "41283fb402713fc8b327e60907f74e46166f4cfd" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
"cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "031e6ba70b0ad5eee49fd2120ff7a2e325b17fa7" },
"cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" },
"fzf-lua": { "branch": "main", "commit": "e9413dc2b6e8ab7f62385c972df1dceba483492d" },
"gitsigns.nvim": { "branch": "main", "commit": "e6e3c3a1394d9e0a1c75d8620f8631e4a6ecde0e" },
"guess-indent.nvim": { "branch": "main", "commit": "6cd61f7a600bb756e558627cd2e740302c58e32d" },
"inc-rename.nvim": { "branch": "main", "commit": "8ba77017ca468f3029bf88ef409c2d20476ea66b" },
"indent-blankline.nvim": { "branch": "master", "commit": "3fe94b8034dd5241cb882bb73847303b58857ecf" },
"lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" },
"lsp_lines.nvim": { "branch": "main", "commit": "7d9e2748b61bff6ebba6e30adbc7173ccf21c055" },
"lspkind-nvim": { "branch": "master", "commit": "cff4ae321a91ee3473a92ea1a8c637e3a9510aec" },
"lualine.nvim": { "branch": "master", "commit": "544dd1583f9bb27b393f598475c89809c4d5e86b" },
"lush.nvim": { "branch": "main", "commit": "6a254139d077ad53be7e4f3602c8da0c84447fd9" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "62360f061d45177dda8afc1b0fd1327328540301" },
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
"matchparen.nvim": { "branch": "main", "commit": "190861577d83167021dcb3339dd3aa594279f2f3" },
"miasma.nvim": { "branch": "main", "commit": "c672feec07d4e77ac485ee58e3432a96ebe51953" },
"neodev.nvim": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" },
"nvim-autopairs": { "branch": "master", "commit": "e38c5d837e755ce186ae51d2c48e1b387c4425c6" },
"nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" },
"nvim-comment": { "branch": "main", "commit": "e9ac16ab056695cad6461173693069ec070d2b23" },
"nvim-highlight-colors": { "branch": "main", "commit": "a411550ef85cae467b889ba7d1a96bd78332d90e" },
"nvim-lspconfig": { "branch": "master", "commit": "652386deae739e38fa1bcf2f06e3e7de9b3436ba" },
"nvim-osc52": { "branch": "main", "commit": "04cfaba1865ae5c53b6f887c3ca7304973824fb2" },
"nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" },
"nvim-treesitter": { "branch": "master", "commit": "88aad97312787c11154afbe16068fc2b1e18b249" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "33a17515b79ddb10d750320fa994098bdc3e93ef" },
"nvim-treesitter-textsubjects": { "branch": "master", "commit": "a8d2844bba925d9450ef7ab215f3b054028288ca" },
"nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" },
"plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" },
"schemastore.nvim": { "branch": "main", "commit": "218a9887085b81b3eb0ee8f1e2d20c4a7fd7b1c9" },
"shipwright.nvim": { "branch": "master", "commit": "e596ab48328c31873f4f4d2e070243bf9de16ff3" },
"tailwindcss-colorizer-cmp.nvim": { "branch": "main", "commit": "3d3cd95e4a4135c250faf83dd5ed61b8e5502b86" },
"telescope-file-browser.nvim": { "branch": "master", "commit": "a46780830b576049c675680650f773bedfa8677a" },
"telescope-live-grep-args.nvim": { "branch": "master", "commit": "649b662a8f476fd2c0289570764459e95ebaa3f3" },
"telescope-undo.nvim": { "branch": "main", "commit": "51be9ae7c42fc27c0b05505e3a0162e0f05fbb6a" },
"telescope.nvim": { "branch": "master", "commit": "3b1600d0fd5172ad9fae00987362ca0ef3d8895d" },
"tint.nvim": { "branch": "master", "commit": "02bd0527a315a80e4e25bb2dd7b6994fb0daae01" },
"tmux.nvim": { "branch": "main", "commit": "65ee9d6e6308afcd7d602e1320f727c5be63a947" },
"trouble.nvim": { "branch": "custom-indent", "commit": "15530355f2fd9e02a5dfba727e394f2438758ac8" },
"vim-dadbod": { "branch": "master", "commit": "7888cb7164d69783d3dce4e0283decd26b82538b" },
"vim-dadbod-completion": { "branch": "master", "commit": "c3ab458fb7c94c2fc4baae4e2cd5601eec9d27bc" },
"vim-dadbod-ui": { "branch": "master", "commit": "0f51d8de368c8c6220973e8acd156d17da746f4c" },
"vim-flog": { "branch": "master", "commit": "dd7a1cf09d034ffa063bedfef4f13891eff06f3a" },
"vim-fugitive": { "branch": "master", "commit": "0444df68cd1cdabc7453d6bd84099458327e5513" },
"vim-oscyank": { "branch": "main", "commit": "c37c9d98e8a0aed749624fa14a7ece7913cf34de" },
"vim-plugin-AnsiEsc": { "branch": "master", "commit": "690f820d20b6e3a79ba20499874eb7333aa4ca5c" },
"which-key.nvim": { "branch": "main", "commit": "6c1584eb76b55629702716995cca4ae2798a9cca" }
}

View File

@ -0,0 +1,39 @@
local ext_fmt = function(cmd)
return function()
local view = vim.fn.winsaveview()
vim.cmd [[:silent w!]]
vim.cmd((":silent !%s %%"):format(cmd))
vim.cmd [[:silent syntax sync fromstart]]
vim.fn.winrestview(view)
vim.cmd [[:silent redraw!]]
vim.cmd [[:silent e]]
end
end
local int_fmt = function() vim.lsp.buf.formatting {} end
local cmds = {
c = ext_fmt "clang-format --style=file -i",
cmake = ext_fmt "cmake-format -i",
cpp = ext_fmt "clang-format --style=file -i",
css = ext_fmt "prettier -w",
go = int_fmt,
html = ext_fmt "prettierd -w",
java = ext_fmt "astyle -A2 -s2 -c -J -n -q -z2 -xC80",
javascript = ext_fmt "prettier -w",
json = ext_fmt "prettierd -w",
lua = ext_fmt "stylua",
nix = ext_fmt "nixpkgs-fmt",
php = ext_fmt "php-cs-fixer fix --rules=@PSR12",
python = ext_fmt "black",
rust = int_fmt,
sh = ext_fmt "shfmt -w -i 0 -sr -kp",
typescript = ext_fmt "prettier -w",
yaml = ext_fmt "prettier -w",
}
local X = {}
X.run = function()
cmds[vim.o.filetype]()
end
return X

View File

@ -0,0 +1,126 @@
return {
"neovim/nvim-lspconfig",
dependencies = {
"folke/neodev.nvim",
"b0o/schemastore.nvim",
"williamboman/mason-lspconfig.nvim",
"https://git.sr.ht/~whynothugo/lsp_lines.nvim",
},
event = { "BufReadPre", "BufNewFile" },
config = function()
require("neodev").setup({})
require("lsp_lines").setup()
local lspconfig = require("lspconfig")
local remaps = require("plugins.lsp.remaps")
local icons = require("utils.icons")
local presentCmpNvimLsp, cmp_lsp = pcall(require, "cmp_nvim_lsp")
local presentLspSignature, lsp_signature = pcall(require, "lsp_signature")
vim.lsp.set_log_level("error") -- 'trace', 'debug', 'info', 'warn', 'error'
local function on_attach(client, bufnr)
remaps.set_default_on_buffer(client, bufnr)
if presentLspSignature then
lsp_signature.on_attach({ floating_window = false, timer_interval = 500 })
end
end
local signs = {
{ name = "DiagnosticSignError", text = icons.diagnostics.error },
{ name = "DiagnosticSignWarn", text = icons.diagnostics.warning },
{ name = "DiagnosticSignHint", text = icons.diagnostics.hint },
{ name = "DiagnosticSignInfo", text = icons.diagnostics.information },
}
for _, sign in ipairs(signs) do
vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" })
end
local config = {
virtual_text = false, -- appears after the line
virtual_lines = false, -- appears under the line
signs = {
active = signs,
},
flags = {
debounce_text_changes = 200,
},
update_in_insert = true,
underline = true,
severity_sort = true,
float = {
focus = false,
focusable = false,
style = "minimal",
border = "shadow",
source = "always",
header = "",
prefix = "",
},
}
lspconfig.util.default_config = vim.tbl_deep_extend('force', lspconfig.util.default_config, config)
vim.diagnostic.config(config)
local border = {
border = "shadow",
}
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.hover, border)
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, border)
local capabilities
if presentCmpNvimLsp then
capabilities = cmp_lsp.default_capabilities(vim.lsp.protocol.make_client_capabilities())
else
capabilities = vim.lsp.protocol.make_client_capabilities()
end
local servers = {
bashls = require("plugins.lsp.servers.bashls")(on_attach),
cssls = require("plugins.lsp.servers.cssls")(on_attach),
dockerls = {},
html = {},
jsonls = {},
lua_ls = require("plugins.lsp.servers.luals")(on_attach),
intelephense = require("plugins.lsp.servers.phpls")(on_attach),
pylsp = {},
rust_analyzer = {},
tailwindcss = require("plugins.lsp.servers.tailwindcss")(on_attach),
terraformls = {},
tflint = {},
tsserver = require("plugins.lsp.servers.tsserver")(on_attach),
yamlls = {},
}
local default_lsp_config = {
on_attach = on_attach,
capabilities = capabilities,
flags = {
debounce_text_changes = 200,
allow_incremental_sync = true,
},
}
local server_names = {}
for server_name, _ in pairs(servers) do
table.insert(server_names, server_name)
end
local present_mason, mason = pcall(require, "mason-lspconfig")
if present_mason then
mason.setup({ ensure_installed = server_names })
end
for server_name, server_config in pairs(servers) do
local merged_config = vim.tbl_deep_extend("force", default_lsp_config, server_config)
lspconfig[server_name].setup(merged_config)
if server_name == "rust_analyzer" then
local present_rust_tools, rust_tools = pcall(require, "rust-tools")
if present_rust_tools then
rust_tools.setup({ server = merged_config })
end
end
end
end
}

View File

@ -0,0 +1,129 @@
local r = require("utils.remaps")
local vim = vim
local X = {}
local function LspToggle()
if vim.diagnostic.is_disabled(0) == true then
vim.diagnostic.enable()
vim.diagnostic.config({ virtual_text = true })
vim.cmd [[LspStart]]
else
vim.diagnostic.disable()
vim.cmd [[LspStop]]
end
end
local function generate_buf_keymapper(bufnr)
return function(type, input, output, description, extraOptions)
local options = { buffer = bufnr }
if extraOptions ~= nil then
options = vim.tbl_deep_extend("force", options, extraOptions)
end
r.noremap(type, input, output, description, options)
end
end
function X.set_default_on_buffer(client, bufnr)
local buf_set_keymap = generate_buf_keymapper(bufnr)
local function buf_set_option(...)
vim.api.nvim_buf_set_option(bufnr, ...)
end
local cap = client.server_capabilities
buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
if cap.definitionProvider then
buf_set_keymap("n", "gD", vim.lsp.buf.definition, "show definition")
end
if cap.declarationProvider then
buf_set_keymap("n", "gd", "<cmd>lua vim.lsp.buf.declaration()<CR>", "show declaration")
end
if cap.implementationProvider then
buf_set_keymap("n", "gi", vim.lsp.buf.implementation, "go to implementation")
buf_set_keymap("n", "gI", function()
require("fzf-lua").lsp_implementations()
end, "search implementations")
end
if cap.referencesProvider then
buf_set_keymap("n", "gr", function()
require("fzf-lua").lsp_references()
end, "show references")
end
if cap.hoverProvider then
buf_set_keymap("n", "K", vim.lsp.buf.hover, "hover docs")
end
if cap.codeActionProvider then
buf_set_keymap({ "n", "v" }, "<leader>ra", function()
local line_count = vim.api.nvim_buf_line_count(bufnr)
local range = {
start = { line = 1, character = 1 },
["end"] = { line = line_count, character = 1 },
}
vim.lsp.buf.code_action({ range = range.range })
end, "code actions")
end
buf_set_keymap("n", "<leader>rf", function()
if cap.documentFormattingProvider then
vim.lsp.buf.format({
async = true,
bufnr = bufnr,
})
else
require("plugins.lsp.format").run()
end
end, "format")
if cap.renameProvider then
buf_set_keymap("n", "<leader>rr", ":IncRename ", "rename")
end
if cap.documentSymbolProvider then
buf_set_keymap("n", "<leader>lo", function()
require("fzf-lua").lsp_document_symbols()
end, "document symbols")
end
local ft = vim.bo[bufnr].filetype
if ft == "sh" or ft == "lua" then
buf_set_keymap("n", "<leader>ld", function()
local row, _ = unpack(vim.api.nvim_win_get_cursor(0))
local msgs = vim.diagnostic.get(bufnr)
local last, result = unpack({ "error", "" })
if ft == "lua" then
result = "---@diagnostic disable-next-line"
else
for _, d in pairs(msgs) do
if d.lnum == (row - 1) and d.code ~= last then
result = (result ~= "") and result .. "," .. d.code or "#shellcheck disable=" .. d.code
last = d.code
end
end
end
if result ~= "" then
vim.api.nvim_buf_set_lines(0, row - 1, row - 1, false, { result })
end
end, "shellscheck ignore")
end
buf_set_keymap("n", "<leader>li", ":LspInfo<CR>", "lsp info")
buf_set_keymap("n", "<leader>ls", vim.lsp.buf.signature_help, "show signature")
buf_set_keymap("n", "<leader>lE", vim.diagnostic.open_float, "show line diagnostics")
buf_set_keymap("n", "<leader>lt", function() LspToggle() end, "toggle lsp")
buf_set_keymap("n", "<leader>ll", function()
if vim.diagnostic.is_disabled(0) == true then
vim.diagnostic.enable()
vim.cmd [[LspStart]]
end
require("lsp_lines").toggle()
end, "toggle lsp lines")
end
return X

View File

@ -0,0 +1,20 @@
local util = require 'lspconfig.util'
return function(on_attach)
return {
on_attach = function(client, bufnr)
on_attach(client, bufnr)
end,
cmd = { 'bash-language-server', 'start' },
cmd_env = {
GLOB_PATTERN = "*@(.sh|.inc|.bash|.command|.zsh)",
},
settings = {
bashIde = {
globPattern = vim.env.GLOB_PATTERN or '*@(.sh|.inc|.bash|.command|.zsh)',
},
},
filetypes = { "sh", "zsh" },
root_dir = util.find_git_ancestor,
single_file_support = true,
}
end

View File

@ -0,0 +1,32 @@
local util = require 'lspconfig.util'
return function(on_attach)
return {
on_attach = function(client, bufnr)
on_attach(client, bufnr)
end,
settings = {
css = {
validate = true,
lint = {
unknownAtRules = "ignore"
}
},
scss = {
validate = true,
lint = {
unknownAtRules = "ignore"
}
},
less = {
validate = true,
lint = {
unknownAtRules = "ignore"
}
},
},
cmd = { "vscode-css-language-server", "--stdio" },
filetypes = { "css", "scss" },
root_dir = util.find_git_ancestor,
single_file_support = true,
}
end

View File

@ -0,0 +1,54 @@
return function(on_attach)
return {
on_attach = function(client, bufnr)
on_attach(client, bufnr)
client.server_capabilities.document_formatting = true
vim.api.nvim_create_autocmd('BufWritePre', {
buffer = bufnr,
command = 'EslintFixAll',
})
end,
cmd = { "vscode-eslint-language-server", "--stdio" },
filetypes = {
"javascript",
"javascriptreact",
"javascript.jsx",
"typescript", "typescriptreact",
"typescript.tsx",
"vue",
"svelte",
"astro",
"js",
},
codeAction = {
disableRuleComment = {
enable = true,
location = "separateLine"
},
showDocumentation = {
enable = true
}
},
codeActionOnSave = {
enable = false,
mode = "all"
},
experimental = {
useFlatConfig = false
},
format = true,
nodePath = "",
onIgnoredFiles = "off",
packageManager = "npm",
problems = {
shortenToSingleLine = false
},
quiet = false,
run = "onType",
useESLintClass = false,
validate = "on",
workingDirectory = {
mode = "location"
}
}
end

View File

@ -0,0 +1,18 @@
return function(capabilities)
capabilities.textDocument.completion.completionItem.snippetSupport = true
return {
settings = {
json = {
schemas = require("schemastore").json.schemas({
select = {
"package.json",
".eslintrc",
"GitHub Action",
"prettierrc.json",
},
}),
},
},
}
end

View File

@ -0,0 +1,32 @@
return function(on_attach)
return {
on_attach = function(client, bufnr)
on_attach(client, bufnr)
client.server_capabilities.document_formatting = false
client.server_capabilities.document_range_formatting = false
end,
settings = {
Lua = {
hint = {
enable = true
},
runtime = {
version = "LuaJIT",
},
diagnostics = {
globals = { "vim" },
},
workspace = {
-- make the server aware of Neovim runtime files
library = {
[vim.fn.expand('$VIMRUNTIME/lua')] = true,
[vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true
},
checkThirdParty = false
},
-- do not send telemetry data containing a randomized but unique identifier
telemetry = { enable = false },
},
},
}
end

View File

@ -0,0 +1,15 @@
local util = require 'lspconfig.util'
return function(on_attach)
return {
on_attach = function(client, bufnr)
on_attach(client, bufnr)
end,
cmd = { 'nginx-language-server' },
cmd_env = {
GLOB_PATTERN = "*@(nginx.conf)",
},
filetypes = { "nginx" },
root_dir = util.find_git_ancestor,
single_file_support = true,
}
end

View File

@ -0,0 +1,13 @@
local util = require 'lspconfig.util'
return function(on_attach)
return {
on_attach = function(client, bufnr)
on_attach(client, bufnr)
end,
cmd = { "intelephense", "--stdio" },
filetypes = { "php" },
root_dir = util.root_pattern("composer.json", ".git"),
-- root_dir = util.find_git_ancestor,
single_file_support = true,
}
end

View File

@ -0,0 +1,19 @@
local util = require 'lspconfig.util'
return function(on_attach)
return {
on_attach = function(client, bufnr)
on_attach(client, bufnr)
end,
settings = {
stylelintplus = {
autoFixOnSave = true,
autoFixOnFormat = true,
validateOnSave = false,
validateOnType = true,
}
},
filetypes = { "css", "less", "scss", "sugarss", "vue", "wxss" },
root_dir = util.find_git_ancestor,
single_file_support = true,
}
end

View File

@ -0,0 +1,82 @@
local util = require 'lspconfig.util'
return function(on_attach)
return {
on_attach = function(client, bufnr)
on_attach(client, bufnr)
end,
cmd = { "tailwindcss-language-server", "--stdio" },
filetypes = {
"astro",
"astro-markdown",
"blade",
"clojure",
"django-html",
"htmldjango",
"edge",
"gohtml",
"haml",
"handlebars",
"hbs",
"html",
"html-eex",
"heex",
"jade",
"leaf",
"liquid",
"markdown",
"mdx",
"mustache",
"njk",
"nunjucks",
"razor",
"slim",
"twig",
"css",
"less",
"postcss",
"sass",
"scss",
"stylus",
"sugarss",
"reason",
"rescript",
"vue",
"svelte"
},
init_options = {
userLanguages = {
eelixir = "html-eex",
eruby = "erb"
}
},
root_dir = util.root_pattern(
'tailwind.config.js',
'tailwind.config.cjs',
'tailwind.config.mjs',
'tailwind.config.ts',
'postcss.config.js',
'postcss.config.cjs',
'postcss.config.mjs',
'postcss.config.ts',
'package.json',
'node_modules',
'.git'
),
single_file_support = true,
settings = {
tailwindCSS = {
classAttributes = { "class", "className", "class:list", "classList", "ngClass" },
lint = {
cssConflict = "warning",
invalidApply = "error",
invalidConfigPath = "error",
invalidScreen = "error",
invalidTailwindDirective = "error",
invalidVariant = "error",
recommendedVariantOrder = "warning"
},
validate = true
}
}
}
end

View File

@ -0,0 +1,24 @@
local util = require 'lspconfig.util'
return function(on_attach)
return {
on_attach = function(client, bufnr)
on_attach(client, bufnr)
client.server_capabilities.document_formatting = true
end,
cmd = { "typescript-language-server", "--stdio" },
filetypes = {
"javascript",
"javascriptreact",
"javascript.jsx",
"typescript",
"typescriptreact",
"typescript.tsx",
},
init_options = {
hostInfo = "neovim",
},
-- root_dir = util.root_pattern("package.json", "package-lock.json", "tsconfig.json", "jsconfig.json", ".git"),
root_dir = util.find_node_modules_ancestor,
single_file_support = true,
}
end

View File

@ -0,0 +1,3 @@
return function(capabilities)
capabilities.textDocument.completion.completionItem.snippetSupport = true
end

View File

@ -0,0 +1,298 @@
return {
"nvim-lualine/lualine.nvim",
event = "VeryLazy",
dependencies = { 'nvim-tree/nvim-web-devicons' },
init = function()
-- disable until lualine loads
vim.opt.laststatus = 0
end,
opts = function()
-- miasma colors
local colors = {
bg = "#222222",
black = "#1c1c1c",
grey = "#666666",
red = "#685742",
green = "#5f875f",
yellow = "#B36D43",
blue = "#78824B",
magenta = "#bb7744",
cyan = "#C9A554",
white = "#D7C483",
}
local conditions = {
buffer_not_empty = function()
return vim.fn.empty(vim.fn.expand("%:t")) ~= 1
end,
hide_in_width_first = function()
return vim.fn.winwidth(0) > 80
end,
hide_in_width = function()
return vim.fn.winwidth(0) > 70
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,
}
-- 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.yellow,
Rv = colors.yellow,
cv = colors.yellow,
ce = colors.yellow,
r = colors.cyan,
rm = colors.cyan,
["r?"] = colors.cyan,
["!"] = colors.red,
t = colors.red,
}
-- config
local config = {
options = {
-- remove default sections and component separators
component_separators = "",
section_separators = "",
theme = {
-- setting defaults to statusline
normal = { c = { fg = colors.fg, bg = colors.bg } },
inactive = { c = { fg = colors.fg, bg = colors.bg } },
},
},
sections = {
-- clear defaults
lualine_a = {},
lualine_b = {},
lualine_y = {},
lualine_z = {},
-- clear for later use
lualine_c = {},
lualine_x = {},
},
inactive_sections = {
-- clear defaults
lualine_a = {},
lualine_b = {},
lualine_y = {},
lualine_z = {},
-- clear for later use
lualine_c = {},
lualine_x = {},
},
}
-- insert active component in lualine_c at left section
local function active_left(component)
table.insert(config.sections.lualine_c, component)
end
-- insert inactive component in lualine_c at left section
local function inactive_left(component)
table.insert(config.inactive_sections.lualine_c, component)
end
-- insert active component in lualine_x at right section
local function active_right(component)
table.insert(config.sections.lualine_x, component)
end
-- insert inactive component in lualine_x at right section
local function inactive_right(component)
table.insert(config.inactive_sections.lualine_x, component)
end
-- dump object contents
local function dump(o)
if type(o) == 'table' then
local s = ''
for k, v in pairs(o) do
if type(k) ~= 'number' then k = '"' .. k .. '"' end
s = s .. dump(v) .. ','
end
return s
else
return tostring(o)
end
end
-- active left section
active_left({
function()
local icon
local ok, devicons = pcall(require, 'nvim-web-devicons')
if ok then
icon = devicons.get_icon(vim.fn.expand('%:t'))
if icon == nil then
icon = devicons.get_icon_by_filetype(vim.bo.filetype)
end
else
if vim.fn.exists('*WebDevIconsGetFileTypeSymbol') > 0 then
icon = vim.fn.WebDevIconsGetFileTypeSymbol()
end
end
if icon == nil then
icon = ''
end
return icon:gsub("%s+", "")
end,
color = function()
return { bg = mode_color[vim.fn.mode()], fg = colors.white }
end,
padding = { left = 1, right = 1 },
separator = { right = "▓▒░" },
})
active_left({
"filename",
cond = conditions.buffer_not_empty,
color = function()
return { bg = mode_color[vim.fn.mode()], fg = colors.white }
end,
padding = { left = 1, right = 1 },
separator = { right = "▓▒░" },
symbols = {
modified = "󰶻 ",
readonly = "",
unnamed = "",
newfile = "",
},
})
active_left({
"branch",
icon = "",
color = { bg = colors.blue, fg = colors.black },
padding = { left = 0, right = 1 },
separator = { right = "▓▒░", left = "░▒▓" },
})
-- inactive left section
inactive_left({
function()
return ''
end,
cond = conditions.buffer_not_empty,
color = { bg = colors.black, fg = colors.grey },
padding = { left = 1, right = 1 },
})
inactive_left({
"filename",
cond = conditions.buffer_not_empty,
color = { bg = colors.black, fg = colors.grey },
padding = { left = 1, right = 1 },
separator = { right = "▓▒░" },
symbols = {
modified = "",
readonly = "",
unnamed = "",
newfile = "",
},
})
-- active right section
active_right({
function()
local clients = vim.lsp.get_active_clients()
local clients_list = {}
for _, client in pairs(clients) do
if (not clients_list[client.name]) then
table.insert(clients_list, client.name)
end
end
local lsp_lbl = dump(clients_list):gsub("(.*),", "%1")
return lsp_lbl:gsub(",", ", ")
end,
icon = "",
color = { bg = colors.green, fg = colors.black },
padding = { left = 1, right = 1 },
cond = conditions.hide_in_width_first,
separator = { right = "▓▒░", left = "░▒▓" },
})
active_right({
"diagnostics",
sources = { "nvim_diagnostic" },
symbols = { error = "", warn = "", info = "" },
colored = false,
color = { bg = colors.magenta, fg = colors.black },
padding = { left = 1, right = 1 },
separator = { right = "▓▒░", left = "░▒▓" },
})
active_right({
"searchcount",
color = { bg = colors.cyan, fg = colors.black },
padding = { left = 1, right = 1 },
separator = { right = "▓▒░", left = "░▒▓" },
})
active_right({
"location",
color = { bg = colors.red, fg = colors.white },
padding = { left = 1, right = 0 },
separator = { left = "░▒▓" },
})
active_right({
function()
local cur = vim.fn.line(".")
local total = vim.fn.line("$")
return string.format("%2d%%%%", math.floor(cur / total * 100))
end,
color = { bg = colors.red, fg = colors.white },
padding = { left = 1, right = 1 },
cond = conditions.hide_in_width,
separator = { right = "▓▒░" },
})
active_right({
"o:encoding",
fmt = string.upper,
cond = conditions.hide_in_width,
padding = { left = 1, right = 1 },
color = { bg = colors.blue, fg = colors.black },
})
active_right({
"fileformat",
fmt = string.lower,
icons_enabled = false,
cond = conditions.hide_in_width,
color = { bg = colors.blue, fg = colors.black },
separator = { right = "▓▒░" },
padding = { left = 0, right = 1 },
})
-- inactive right section
inactive_right({
"location",
color = { bg = colors.black, fg = colors.grey },
padding = { left = 1, right = 0 },
separator = { left = "░▒▓" },
})
inactive_right({
"progress",
color = { bg = colors.black, fg = colors.grey },
cond = conditions.hide_in_width,
padding = { left = 1, right = 1 },
separator = { right = "▓▒░" },
})
inactive_right({
"fileformat",
fmt = string.lower,
icons_enabled = false,
cond = conditions.hide_in_width,
color = { bg = colors.black, fg = colors.grey },
separator = { right = "▓▒░" },
padding = { left = 0, right = 1 },
})
--
return config
end,
}

View File

@ -0,0 +1,36 @@
return {
"L3MON4D3/LuaSnip",
dependencies = { "rafamadriz/friendly-snippets" },
event = "InsertEnter",
postinstall = "make install_jsregexp",
config = function()
local luasnip = require("luasnip")
luasnip.config.setup({
history = true,
updateevents = "TextChanged,TextChangedI",
enable_autosnippets = true,
})
-- add vscode exported completions
require("luasnip.loaders.from_vscode").lazy_load()
local r = require("utils.remaps")
r.map({ "i", "s" }, "<c-n>", function()
if luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
end
end, "Expand current snippet or jump to next", { silent = true })
r.map({ "i", "s" }, "<c-p>", function()
if luasnip.jumpable(-1) then
luasnip.jump(-1)
end
end, "Go to previous snippet", { silent = true })
r.map("i", "<c-l>", function()
if luasnip.choice_active() then
luasnip.change_choice(1)
end
end, "Show list of options")
end,
}

11
nvim/lua/plugins/lush.lua Normal file
View File

@ -0,0 +1,11 @@
return {
"rktjmp/lush.nvim",
lazy = true,
dependencies = {
"rktjmp/shipwright.nvim",
},
cmd = {
"Lushify",
"Shipwright",
},
}

View File

@ -0,0 +1,22 @@
return {
"jay-babu/mason-nvim-dap.nvim",
dependencies = { "williamboman/mason.nvim" },
cmd = "Mason",
config = function()
local mason_dap = require("mason-nvim-dap")
mason_dap.setup({
ensure_installed = {
"bash",
"cppdbg",
"js",
"node2",
"php",
"python",
},
auto_update = false,
run_on_start = false,
automatic_setup = true,
})
mason_dap.setup_handlers {}
end,
}

View File

@ -0,0 +1,42 @@
return {
"williamboman/mason.nvim",
build = ":MasonInstallAll",
config = function()
local f = require("utils.functions")
require("mason").setup({
ui = {
border = "shadow",
icons = require("utils.icons").mason,
zindex = 99,
},
})
f.cmd("MasonInstallAll", function()
vim.cmd('MasonUpdate')
local ensure_installed = {
"bash-language-server",
"black",
"clang-format",
"css-lsp",
"dockerfile-language-server",
"eslint-lsp",
"html-lsp",
"json-lsp",
"lua-language-server",
"php-cs-fixer",
"prettierd",
"python-lsp-server",
"rust-analyzer",
"shellcheck",
"shellharden",
"shfmt",
"stylua",
"tailwindcss-language-server",
"terraform-ls",
"tflint",
"typescript-language-server",
"yaml-language-server",
}
vim.cmd('MasonInstall ' .. table.concat(ensure_installed, ' '))
end, { desc = "install all lsp tools" })
end,
}

View File

@ -0,0 +1,11 @@
return {
"monkoose/matchparen.nvim",
event = "VeryLazy",
config = function()
require("matchparen").setup({
on_startup = true,
hl_group = "MatchParen",
debounce_time = 100,
})
end,
}

View File

@ -0,0 +1,10 @@
return {
"xero/miasma.nvim",
-- dev = true,
-- branch = "dev",
lazy = false,
priority = 1000,
config = function()
vim.cmd("colorscheme miasma")
end,
}

View File

@ -0,0 +1,19 @@
return {
"ojroques/vim-oscyank",
event = "VeryLazy",
dependencies = {
"ojroques/nvim-osc52",
},
config = function()
vim.api.nvim_set_option("clipboard", "unnamedplus")
vim.api.nvim_create_autocmd("TextYankPost", {
group = vim.api.nvim_create_augroup("highlight_yank", { clear = true }),
callback = function()
vim.highlight.on_yank({ higroup = "IncSearch", timeout = 500 })
if vim.v.event.operator == "y" and vim.v.event.regname == "" then
vim.cmd [[OSCYankRegister]]
end
end,
})
end,
}

View File

@ -0,0 +1,25 @@
return {
"petertriho/nvim-scrollbar",
event = "VeryLazy",
config = function()
local scrollbar = require("scrollbar")
scrollbar.setup({
show_in_active_only = true,
handle = {
blend = 0,
text = " ",
color = "#1c1c1c",
color_nr = 234,
},
marks = {
Search = { color = "#C9A554" },
Error = { color = "#685742" },
Warn = { color = "#B36D43" },
Info = { color = "#5f875f" },
Hint = { color = "#5f875f" },
Misc = { color = "#bb7744" },
Cursor = { color = "#222222" , text = " " },
}
})
end,
}

View File

@ -0,0 +1,23 @@
return {
"kylechui/nvim-surround",
version = "*",
event = "VeryLazy",
config = function()
---@diagnostic disable-next-line
require("nvim-surround").setup({
keymaps = {
insert = "<c-g>s",
insert_line = "<c-g>S",
normal = "s",
normal_cur = "ss",
normal_line = "S",
normal_cur_line = "SS",
visual = "S",
visual_line = "gS",
delete = "ds",
change = "cs",
change_line = "cS",
},
})
end
}

View File

@ -0,0 +1,94 @@
return {
"nvim-telescope/telescope.nvim",
event = "VeryLazy",
dependencies = {
"nvim-lua/plenary.nvim",
"debugloop/telescope-undo.nvim",
"nvim-telescope/telescope-file-browser.nvim",
"nvim-telescope/telescope-live-grep-args.nvim",
},
config = function()
local telescope = require("telescope")
local tele_actions = require("telescope.actions")
local lga_actions = require("telescope-live-grep-args.actions")
local lga_shortcuts = require("telescope-live-grep-args.shortcuts")
local undo_actions = require("telescope-undo.actions")
local r = require("utils.remaps")
local i = require("utils.icons")
telescope.setup({
defaults = {
layout_config = {
anchor = "center",
height = 0.8,
width = 0.9,
preview_width = 0.6,
prompt_position = "bottom",
},
borderchars = i.telescope,
mappings = {
i = {
["<esc>"] = tele_actions.close,
},
},
},
extensions = {
undo = {
use_delta = true,
side_by_side = true,
entry_format = "󰣜 #$ID, $STAT, $TIME",
layout_strategy = "flex",
mappings = {
i = {
["<cr>"] = undo_actions.yank_additions,
["<EFBFBD>"] = undo_actions.yank_deletions, -- term mapped to shift+enter
["<c-\\>"] = undo_actions.restore,
},
},
},
live_grep_args = {
auto_quoting = true,
mappings = {
i = {
["<c-\\>"] = lga_actions.quote_prompt({ postfix = " --hidden " }),
},
},
},
file_browser = {
depth = 1,
auto_depth = false,
hidden = { file_browser = true, folder_browser = true },
hide_parent_dir = false,
collapse_dirs = false,
prompt_path = false,
quiet = false,
dir_icon = "󰉓 ",
dir_icon_hl = "Default",
display_stat = { date = true, size = true, mode = true },
git_status = true,
},
},
})
r.noremap("n", "<leader>u", ":Telescope undo<cr>", "undo tree")
r.noremap("n", "\\", function()
telescope.extensions.live_grep_args.live_grep_args({
prompt_title = 'grep',
additional_args = '-i',
})
end, "live grep")
r.noremap("n", "<leader>o", ":Telescope oldfiles<cr>", "old files")
r.noremap("n", "<leader>gc", function()
lga_shortcuts.grep_word_under_cursor({ postfix = " --hidden " })
end, "grep under cursor")
r.noremap("n", "<leader>f", function()
telescope.extensions.file_browser.file_browser()
end, "browse files")
r.noremap("n", "<leader>.", function()
telescope.extensions.file_browser.file_browser({
path = vim.fn.stdpath("config")
})
end, "nvim dotfiles")
telescope.load_extension("undo")
telescope.load_extension("file_browser")
telescope.load_extension("live_grep_args")
end,
}

33
nvim/lua/plugins/tint.lua Normal file
View File

@ -0,0 +1,33 @@
return {
"levouh/tint.nvim",
event = "VeryLazy",
config = function()
local tint = require("tint")
local transforms = require("tint.transforms")
tint.setup({
transforms = {
transforms.tint_with_threshold(-10, "#1a1a1a", 7),
transforms.saturate(0.65),
},
tint_background_colors = true,
highlight_ignore_patterns = {
"SignColumn",
"LineNr",
"CursorLine",
"WinSeparator",
"VertSplit",
"StatusLineNC",
},
})
vim.api.nvim_create_autocmd("FocusGained", {
callback = function()
tint.untint(vim.api.nvim_get_current_win())
end,
})
vim.api.nvim_create_autocmd("FocusLost", {
callback = function()
tint.tint(vim.api.nvim_get_current_win())
end,
})
end,
}

53
nvim/lua/plugins/tmux.lua Normal file
View File

@ -0,0 +1,53 @@
return {
"aserowy/tmux.nvim",
event = "VeryLazy",
config = function()
local tmux = require("tmux")
local r = require("utils.remaps")
tmux.setup({
copy_sync = {
enable = false,
},
navigation = {
cycle_navigation = false,
enable_default_keybindings = false,
persist_zoom = true,
},
resize = {
enable_default_keybindings = false,
},
})
local zoom = function()
if vim.fn.winnr("$") > 1 then
if vim.g.zoomed ~= nil then
vim.cmd(vim.g.zoom_winrestcmd)
vim.g.zoomed = 0
else
vim.g.zoom_winrestcmd = vim.fn.winrestcmd()
vim.cmd("resize")
vim.cmd("vertical resize")
vim.g.zoomed = 1
end
else
vim.cmd("!tmux resize-pane -Z")
end
end
r.noremap("n", "<c-h>", tmux.move_left, "tmux focus left")
r.noremap("n", "<c-j>", tmux.move_bottom, "tmux focus bottom")
r.noremap("n", "<c-k>", tmux.move_top, "tmux focus top")
r.noremap("n", "<c-l>", tmux.move_right, "tmux focus right")
r.noremap("n", "<c-left>", tmux.resize_left, "tmux resize left")
r.noremap("n", "<c-down>", tmux.resize_bottom, "tmux resize bottom")
r.noremap("n", "<c-up>", tmux.resize_top, "tmux resize top")
r.noremap("n", "<c-right>", tmux.resize_right, "tmux resize right")
r.noremap("t", "<c-h>", tmux.move_left, "tmux focus left")
r.noremap("t", "<c-j>", tmux.move_bottom, "tmux focus bottom")
r.noremap("t", "<c-k>", tmux.move_top, "tmux focus top")
r.noremap("t", "<c-l>", tmux.move_right, "tmux focus right")
r.noremap("t", "<c-left>", tmux.resize_left, "tmux resize left")
r.noremap("t", "<c-down>", tmux.resize_bottom, "tmux resize bottom")
r.noremap("t", "<c-up>", tmux.resize_top, "tmux resize top")
r.noremap("t", "<c-right>", tmux.resize_right, "tmux resize right")
r.noremap("n", "<leader>z", zoom, "tmux zoom")
end,
}

View File

@ -0,0 +1,168 @@
return {
"nvim-treesitter/nvim-treesitter",
dependencies = {
"RRethy/nvim-treesitter-textsubjects",
"nvim-treesitter/nvim-treesitter-textobjects",
},
event = { "BufReadPost", "BufNewFile" },
config = function()
local treesitter = require("nvim-treesitter.configs")
---@diagnostic disable-next-line
treesitter.setup({
ensure_installed = {
"bash",
"css",
"dockerfile",
"go",
"graphql",
"hcl",
"html",
"javascript",
"json",
"lua",
"markdown",
"markdown_inline",
"php",
"python",
"regex",
"regex",
"ruby",
"rust",
"scss",
"sql",
"terraform",
"tsx",
"typescript",
"vim",
"yaml",
},
highlight = {
enable = true,
},
match = {
enable = true,
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = "zi",
node_incremental = "zi",
scope_incremental = "zo",
node_decremental = "zd",
},
},
indent = {
enable = true,
},
-- textobjects = {
-- select = {
-- enable = true,
-- lookahead = true,
-- keymaps = {
-- ["af"] = "@function.outer",
-- ["if"] = "@function.inner",
-- ["ac"] = "@class.outer",
-- ["ic"] = "@class.inner",
--
-- -- xml attribute
-- ["ax"] = "@attribute.outer",
-- ["ix"] = "@attribute.inner",
--
-- -- json
-- ["ak"] = "@key.outer",
-- ["ik"] = "@key.inner",
-- ["av"] = "@value.outer",
-- ["iv"] = "@value.inner",
-- },
-- },
swap = {
enable = true,
swap_next = {
["<leader>rp"] = "@parameter.inner",
},
swap_previous = {
["<leader>rP"] = "@parameter.inner",
},
},
-- move = {
-- enable = true,
-- set_jumps = true, -- whether to set jumps in the jumplist
-- goto_next_start = {
-- ["]m"] = "@function.outer",
-- ["]]"] = "@class.outer",
-- },
-- goto_next_end = {
-- ["]M"] = "@function.outer",
-- ["]["] = "@class.outer",
-- },
-- goto_previous_start = {
-- ["[m"] = "@function.outer",
-- ["[["] = "@class.outer",
-- },
-- goto_previous_end = {
-- ["[M"] = "@function.outer",
-- ["[]"] = "@class.outer",
-- },
-- },
-- },
textsubjects = {
enable = true,
keymaps = {
["."] = "textsubjects-smart",
[";"] = "textsubjects-container-outer",
["i;"] = "textsubjects-container-inner",
},
},
})
local r = require("utils.remaps")
r.noremap("n", "<leader>dp", function()
vim.treesitter.inspect_tree({ command = "botright 60vnew" })
end, "treesitter playground")
r.noremap("n", "<C-e>", function()
local result = vim.treesitter.get_captures_at_cursor(0)
print(vim.inspect(result))
end, "show treesitter capture group")
r.map_virtual("zi", "init selection")
r.map_virtual("zi", "expand node")
r.map_virtual("zo", "expand scope")
r.map_virtual("zd", "decrement scope")
-- r.map_virtual("af", "Function outer motion")
-- r.map_virtual("if", "Function inner motion")
-- r.map_virtual("ac", "Class outer motion")
-- r.map_virtual("ic", "Class inner motion")
--
-- r.map_virtual("ax", "Attribute (html, xml) outer motion")
-- r.map_virtual("ix", "Attribute (html, xml) inner motion")
--
-- r.map_virtual("ak", "Json key outer motion")
-- r.map_virtual("ik", "Json key inner motion")
--
-- r.map_virtual("av", "Json value outer motion")
-- r.map_virtual("iv", "Json value inner motion")
--
-- r.which_key("fp", "parameters")
--
r.map_virtual("<leader>rp", "swap parameter to next")
r.map_virtual("<leader>rP", "swap parameter to previous")
--
-- r.map_virtual("]m", "Go to next function (start)")
-- r.map_virtual("]M", "Go to next function (end)")
--
-- r.map_virtual("]]", "Go to next class (start)")
-- r.map_virtual("][", "Go to next class (end)")
--
-- r.map_virtual("[m", "Go to previous function (start)")
-- r.map_virtual("[M", "Go to previous function (end)")
--
-- r.map_virtual("[[", "Go to previous class (start)")
-- r.map_virtual("[]", "Go to previous class (end)")
end,
build = function()
vim.cmd [[TSUpdate]]
end,
}

View File

@ -0,0 +1,35 @@
return {
-- "folke/trouble.nvim",
"xero/trouble.nvim", -- till my pr is merged
branch = "custom-indent",
event = "VeryLazy",
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
require("trouble").setup({
auto_fold = false,
fold_open = "",
fold_closed = "",
height = 6,
indent_str = "",
include_declaration = {
"lsp_references",
"lsp_implementations",
"lsp_definitions"
},
mode = "workspace_diagnostics",
multiline = true,
padding = false,
position = "bottom",
severity = nil, -- nil (ALL) or vim.diagnostic.severity.ERROR | WARN | INFO | HINT
signs = require("utils.icons").diagnostics,
use_diagnostic_signs = true,
})
local r = require("utils.remaps")
r.noremap("n", "<leader>lr", ":TroubleToggle lsp_references<cr>", "lsp references ")
r.noremap("n", "<leader>le", ":TroubleToggle document_diagnostics<cr>", "diagnostics")
r.noremap("n", "<leader>t", function()
require("lsp_lines").toggle()
vim.cmd [[TroubleToggle workspace_diagnostics]]
end, "toggle trouble  ")
end,
}

View File

@ -0,0 +1,56 @@
return {
"folke/which-key.nvim",
keys = { "<leader>" },
config = function()
local which_key = require("which-key")
which_key.setup({
plugins = {
spelling = {
enabled = true,
suggestions = 20,
},
},
window = {
border = "shadow",
position = "bottom",
margin = { 0, 1, 1, 5 },
padding = { 1, 2, 1, 2 },
},
triggers_nowait = {
"`",
"'",
"g`",
"g'",
'"',
"<c-r>",
"z=",
},
})
local opts = {
prefix = "<leader>",
}
local groups = {
b = { name = "buffer" },
s = { name = "search" },
-- g = { name = "git" },
r = { name = "refactor" },
l = { name = "lsp" },
d = { name = "debug" },
m = { name = "macro/markdown" },
n = { name = "notifications" },
["<tab>"] = { name = "tabs" },
[";"] = { name = "test" },
["'"] = { name = "marks" },
["/"] = { name = "search" },
["/g"] = { name = "git" },
["/gd"] = { name = "diff" },
["["] = { name = "previous" },
["]"] = { name = "next" },
}
which_key.register(groups, opts)
end,
}

124
nvim/lua/ui.lua Normal file
View File

@ -0,0 +1,124 @@
-- ██
-- ░░
-- ██ ██ ██ ██████████ ██████ █████
-- ░██ ░██░██░░██░░██░░██░░██░░█ ██░░░██
-- ░░██ ░██ ░██ ░██ ░██ ░██ ░██ ░ ░██ ░░
-- ░░████ ░██ ░██ ░██ ░██ ░██ ░██ ██
-- ░░██ ░██ ███ ░██ ░██░███ ░░█████
-- ░░ ░░ ░░░ ░░ ░░ ░░░ ░░░░░
--
-- ▓▓▓▓▓▓▓▓▓▓
-- ░▓ author ▓ xero <x@xero.style>
-- ░▓ code ▓ https://code.x-e.ro/dotfiles
-- ░▓ mirror ▓ https://git.io/.files
-- ░▓▓▓▓▓▓▓▓▓▓
-- ░░░░░░░░░░
--
-- show matching brackets/parenthesis
vim.opt.showmatch = true
-- disable startup message
vim.opt.shortmess:append("sI")
-- cmd display (set to zero to autohide)
vim.opt.cmdheight = 1
-- gutter sizing
vim.opt.signcolumn = "auto:2"
-- syntax highlighting
vim.opt.termguicolors = true
vim.opt.synmaxcol = 512
-- show line numbers
vim.opt.number = true
-- default no line wrapping
vim.opt.wrap = false
-- set indents when wrapped
vim.opt.breakindent = true
-- highlight cursor
vim.opt.cursorline = true
-- set cursorcolumn = true
-- show invisibles
vim.opt.listchars = { tab = " ", trail = "·", extends = "»", precedes = "«", nbsp = "" }
vim.opt.list = true
-- split style
vim.opt.fillchars = { vert = "" }
vim.opt.splitbelow = true
vim.opt.splitright = true
-- custom tabline
local noname = "[unnamed]"
local function extract_filename(win)
local b = vim.api.nvim_win_get_buf(win)
local fullname = vim.api.nvim_buf_get_name(b)
local mod = vim.api.nvim_buf_get_option(b, 'modified') and "" or ""
if fullname ~= "" then
local shortname = vim.fn.fnamemodify(fullname, ":~:.:gs%(.?[^/])[^/]*/%\1/%")
if #shortname > 30 then shortname = vim.fn.fnamemodify(fullname, ":t") end
return mod..shortname
end
end
local function get_best_window_filename(tabpage, window)
local filename = extract_filename(window)
if filename == nil then
local wins = vim.api.nvim_tabpage_list_wins(tabpage)
if #wins > 1 then
for _, win in ipairs(wins) do
filename = extract_filename(win)
break
end
end
end
if filename == nil then
return noname
end
return filename
end
local function is_float_win(win)
local config = vim.api.nvim_win_get_config(win)
return config.zindex and config.zindex > 0
end
local function getname(tabpage)
-- vim.F.npcall(vim.api.nvim_tabpage_get_var, tabpage, "tab_title")
local title = vim.t[tabpage].tab_title
if title ~= nil then
return title
end
local window = vim.api.nvim_tabpage_get_win(tabpage)
-- don't replace the last filename-buffer w/ floating windows
if is_float_win(window) then
return vim.t[tabpage].last_buffer_filename
end
local filename = get_best_window_filename(tabpage, window)
vim.t[tabpage].last_buffer_filename = filename
return filename
end
function Tabline()
local tl = {}
local current = vim.api.nvim_get_current_tabpage()
for i, tabpage in ipairs(vim.api.nvim_list_tabpages()) do
local hi = tabpage == current and "%#TabLineSel#" or "%#TabLine#"
local hiSep = tabpage == current and "%#TabLineSelSep#" or "%#TabLineSep#"
table.insert(tl, "%" .. i .. "T") -- mouse click target region
table.insert(tl, hi .. " " .. getname(tabpage) .. " ")
table.insert(tl, hiSep .. "▓▒░ " .. hi)
end
table.insert(tl, "%T") -- end mouse click region(s).
table.insert(tl, "%#TabLineFill#")
return table.concat(tl, '')
end
vim.opt.tabline = [[%!v:lua.Tabline()]]

View File

@ -0,0 +1,73 @@
local functions = require("utils.functions")
local X = {}
local duplicates_n = {}
local duplicates_v = {}
local duplicates_i = {}
local duplicates_s = {}
local duplicates_x = {}
local function check_and_set_duplicates(input, description, check, table)
if check then
local found = table[input]
if found ~= nil then
if found ~= description then
print(input .. " already mapped (" .. found .. " so we cannot re-map (" .. description .. ")")
end
end
table[input] = description
end
end
X.check_duplicates = function(type, input, description)
local check_n = false
local check_v = false
local check_i = false
local check_s = false
local check_x = false
if functions.is_table(type) then
if type["n"] then
check_n = true
end
if type["v"] then
check_v = true
end
if type["i"] then
check_i = true
end
if type["s"] then
check_s = true
end
if type["x"] then
check_x = true
end
else
if type == "n" then
check_n = true
end
if type == "v" then
check_v = true
end
if type == "i" then
check_i = true
end
if type == "s" then
check_s = true
end
if type == "x" then
check_x = true
end
end
check_and_set_duplicates(input, description, check_n, duplicates_n)
check_and_set_duplicates(input, description, check_v, duplicates_v)
check_and_set_duplicates(input, description, check_i, duplicates_i)
check_and_set_duplicates(input, description, check_s, duplicates_s)
check_and_set_duplicates(input, description, check_x, duplicates_x)
end
return X

View File

@ -0,0 +1,126 @@
local vim = vim
local X = {}
---@param on_attach fun(client, buffer)
function X.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 X.starts_with(str, start)
return str:sub(1, #start) == start
end
function X.is_table(to_check)
return type(to_check) == "table"
end
function X.has_key(t, key)
for t_key, _ in pairs(t) do
if t_key == key then
return true
end
end
return false
end
function X.has_value(t, val)
for _, value in ipairs(t) do
if value == val then
return true
end
end
return false
end
function X.tprint(table)
print(vim.inspect(table))
end
function X.tprint_keys(table)
for k in pairs(table) do
print(k)
end
end
X.reload = function()
local presentReload, reload = pcall(require, "plenary.reload")
if presentReload then
local counter = 0
for moduleName in pairs(package.loaded) do
if X.starts_with(moduleName, "lt.") then
reload.reload_module(moduleName)
counter = counter + 1
end
end
-- clear nvim-mapper keys
vim.g.mapper_records = nil
vim.notify("Reloaded " .. counter .. " modules!")
end
end
function X.is_macunix()
return vim.fn.has("macunix")
end
function X.link_highlight(from, to, override)
local hl_exists, _ = pcall(vim.api.nvim_get_hl_by_name, from, false)
if override or not hl_exists then
-- vim.cmd(("highlight link %s %s"):format(from, to))
vim.api.nvim_set_hl(0, from, { link = to })
end
end
X.highlight = function(group, opts)
vim.api.nvim_set_hl(0, group, opts)
end
X.highlight_bg = function(group, col)
vim.api.nvim_set_hl(0, group, { bg = col })
end
-- Define fg color
-- @param group Group
-- @param color Color
X.highlight_fg = function(group, col)
vim.api.nvim_set_hl(0, group, { fg = col })
end
-- Define bg and fg color
-- @param group Group
-- @param fgcol Fg Color
-- @param bgcol Bg Color
X.highlight_fg_bg = function(group, fgcol, bgcol)
vim.api.nvim_set_hl(0, group, { bg = bgcol, fg = fgcol })
end
X.from_highlight = function(hl)
local result = {}
local list = vim.api.nvim_get_hl_by_name(hl, true)
for k, v in pairs(list) do
local name = k == "background" and "bg" or "fg"
result[name] = string.format("#%06x", v)
end
return result
end
X.get_color_from_terminal = function(num, default)
local key = "terminal_color_" .. num
return vim.g[key] and vim.g[key] or default
end
X.cmd = function(name, command, desc)
vim.api.nvim_create_user_command(name, command, desc)
end
X.autocmd = function(evt, opts)
vim.api.nvim_create_autocmd(evt, opts)
end
return X

69
nvim/lua/utils/icons.lua Normal file
View File

@ -0,0 +1,69 @@
return {
diagnostics = {
error = "",
hint = "",
information = "",
other = "",
warning = "",
},
git = {
Added = "",
Modified = "",
Removed = "",
},
dap = {
breakpoint = "",
breakpoint_condition = "",
log_point = "",
stopped = "",
breakpoint_rejected = "",
pause = "",
play = "",
step_into = "",
step_over = "",
step_out = "",
step_back = "",
run_last = "",
terminate = "",
},
lazy = {
cmd = "",
config = "",
event = "",
ft = "",
init = "",
import = "",
keys = "",
lazy = "󰒲 ",
loaded = "󱄲",
not_loaded = "󱄯",
plugin = "",
runtime = "",
source = "",
start = "",
task = "",
list = {
"󱄰",
"",
"",
"",
},
},
mason = {
package_installed = "󱄲",
package_pending = "󱄰",
package_uninstalled = "󱄯",
},
borders = {
dashed = { "", "", "", "", "", "", "", "", },
double = { "", "", "", "", "", "", "", "", },
single = { "", "", "", "", "", "", "", "", },
blocks = { "", "", "", "", "", "", "", "", },
blocky = { "", "", "", "", "", "", "", "", },
},
telescope = {
prompt = { "", "", "", "", "", "", "", "", },
results = { "", " ", "", "", "", "", "", "", },
preview = { "", "", "", "", "", "", "", "", },
},
}

60
nvim/lua/utils/remaps.lua Normal file
View File

@ -0,0 +1,60 @@
local keymap = vim.keymap
local check_duplicates = require("utils.duplicates").check_duplicates
local X = {}
local which_key_lazy_registers = nil
local function lazy_register_which_key(input, description)
if which_key_lazy_registers == nil then
which_key_lazy_registers = {}
end
which_key_lazy_registers[input] = description
end
local function try_add_to_which_key_by_input(input, description)
local present_which_key, which_key = pcall(require, "which-key")
local has_leader = string.find(input, "<leader>")
if has_leader then
if present_which_key then
if which_key_lazy_registers ~= nil then
which_key.register(which_key_lazy_registers)
which_key_lazy_registers = nil
end
which_key.register({
[input] = description,
})
else
lazy_register_which_key(input, description)
end
end
end
function X.map(type, input, output, description, additional_options)
local options = { remap = true, desc = description }
if additional_options then
options = vim.tbl_deep_extend("force", options, additional_options)
end
keymap.set(type, input, output, options)
check_duplicates(type, input, description)
end
function X.noremap(type, input, output, description, additional_options)
local options = { remap = false }
if additional_options then
options = vim.tbl_deep_extend("force", options, additional_options)
end
X.map(type, input, output, description, options)
end
function X.map_virtual(input, description)
check_duplicates(type, input, description)
try_add_to_which_key_by_input(input, description)
end
function X.which_key(input, description)
try_add_to_which_key_by_input(input, description)
end
return X

74
nvim/nvim-logo Executable file
View File

@ -0,0 +1,74 @@
#!/bin/sh
# neovim logo by @sunjon https://github.com/nvimdev/dashboard-nvim/wiki/Ascii-Header-Text
# color variations and script by @xero https://git.io/.files
case "$1" in
-b) cat << x0

███████████ █████ ██
███████████ █████ 
████████████████ ███████████ ███ ███████
████████████████ ████████████ █████ ██████████████
██████████████ █████████████ █████ █████ ████ █████
██████████████████████████████████ █████ █████ ████ █████
██████ ███ █████████████████ ████ █████ █████ ████ ██████
x0
;;
-o) cat << x0
 
███████████ █████ ██
███████████ █████ 
████████████████ ███████████ ███ ███████
████████████████ ████████████ █████ ██████████████
█████████████████████████████ █████ █████ ████ █████
██████████████████████████████████ █████ █████ ████ █████
██████ ███ █████████████████ ████ █████ █████ ████ ██████
██████ ██ ███████████████ ██ █████████████████
 ██████ ██ ███████████████ ██ █████████████████ 
x0
;;
-t) cat << x0
  
███████████ █████ ██ 
███████████ █████  
████████████████ ███████████ ███ ███████ 
████████████████ ████████████ █████ ██████████████ 
█████████████████████████████ █████ █████ ████ █████ 
██████████████████████████████████ █████ █████ ████ █████ 
██████ ███ █████████████████ ████ █████ █████ ████ ██████
██████ ██ ███████████████ ██ █████████████████
 
x0
;;
-l) cat << x0
  
 ███████████ █████ ██ 
 ███████████ █████  
 ████████████████ ███ ████████ ███ ███████ 
 ████████████████ ████ ████████ █████ ██████████████ 
 ██████████████████████ ███████ █████ █████ ████ █████ 
 ████████████████████████████ ██████ █████ █████ ████ █████ 
██████ ███ █████████████████ ████ █████ █████ ████ ██████
██████ ██ ███████████████ ██ █████████████████
 

x0
;;
*) cat << x0
nvim-logo: display cool text mode art banners in your shell/editor
usage: ./nvim-logo [-t|-l|-b|-h]
flags:
-t display in miasma true colors
-o display in origional true colors
-l display in limited 246 colors
-b display in black and white (text only)
-h display this message
requirements:
this design uses non-standard characters from NerdFonts (v3)
please view in a patched font https://www.nerdfonts.com/
credits:
neovim logo by @sunjon https://github.com/nvimdev/dashboard-nvim/wiki/Ascii-Header-Text
color variations and script by @xero https://git.io/.files
x0
;;
esac
exit 0

Binary file not shown.

After

Width:  |  Height:  |  Size: 511 KiB