diff --git a/.stylua.toml b/.stylua.toml new file mode 100644 index 0000000..047d961 --- /dev/null +++ b/.stylua.toml @@ -0,0 +1,7 @@ +call_parentheses = "Always" +collapse_simple_statement = "Never" +column_width = 120 +indent_type = "Spaces" +indent_width = 4 +line_endings = "Unix" +quote_style = "AutoPreferSingle" diff --git a/README.md b/README.md new file mode 100644 index 0000000..9ee5f55 --- /dev/null +++ b/README.md @@ -0,0 +1,157 @@ +
+ +

nvim

+ + +License + + +People + + +Stars + + +Forks + + +Watches + + +Last Updated + +

Your Personalized Development Environment โค๏ธ๐Ÿ‘จโ€๐Ÿ’ป

+ +
+ nvim Demo +
+
nvim screenshot
+
+ +
+ +Handcrafted Neovim setup for the ultimate CLI dev experience. + +## โœจ Features + +- **Fully configured LSP**: Out of the box LSP and completions, including Copilot (optional) +- **Awesome keybindings**: Intuitive and well documented keybindings with which-key +- **Blazingly fast**: Starts up in less than 30ms thanks to extensive lazy loading +- **Batteries included**: Has all the necessary plugins included out of the box +- **Git in there**: Powerful git integrations thanks to lazygit, fugitive, gitsigns and more +- **Pretty colors**: Comes with treesitter and dracula preconfigured with full transparency support +- **Goto for notes**: Comes with powerful note-taking capabilities, thanks to [tdo](https://github.com/2kabhishek/tdo) +- **Tmux integration**: Works with your tmux configurations out of the box +- **Dev tools**: Comes with debugging, testing, database and REPL support, pick and choose +- **Auto install**: All necessary LSPs, Null LS sources, Treesitter Parsers etc. are auto installed +- **User module**: Configure nvim according to your needs by using the `user` module! +- and some more + +Most importantly: + +**Built for extending**: nvim has a easy to understand config structure that promotes personalization, so go ahead, bring your keybindings, functions and plugins over, and truly make **nvim: Your Personalized Development Environment!** + +## โšก Setup + +### โš™๏ธ Requirements + +Before you begin, ensure you have met the following requirements: + +- You have installed the latest version of `neovim` +- Python provider is necessary for some operations: `pip install neovim` +- Some command line tools: fd, ripgrep + +- To use nvim for notes, take a look at [tdo.nvim](https://github.com/2kabhishek/tdo.nvim) + +### ๐Ÿ’ป Installation + +To install `nvim` clone the repo and setup the symlink + +```bash +git clone https://github.com/S4NKALP/nvim +``` + +On Linux and Mac + +```bash +ln -sfnv $PWD/nvim $HOME/.config/nvim +``` + +On Windows Powershell + +```powershell +New-Item -ItemType SymbolicLink -Path "$env:LOCALAPPDATA\nvim" -Target "$PWD\nvim" -Force +``` + +## ๐Ÿš€ Usage + +Edit files in [lua/core](./lua/core/) for tweaking [options](./lua/core/options.lua), and to add/remove [functions](./lua/core/functions.lua) and [autocmds](./lua/core/autocmd.lua) + +### ๐Ÿ“ฆ Plugins + +To add new plugins add it to the [plugins list](./lua/plugins/list.lua) + +For plugin configs you can place them in these folders based on the functionality: + +- [lang](./lua/plugins/lang/): Plugins related to language features, completions, lsp, debugging etc. +- [tools](./lua/plugins/tools/): General purpose tool plugins that aid in the editing experience. +- [ui](./lua/plugins/ui/): Cosmetic plugins that make neovim pretty. + +### โŒจ๏ธ Keybindings + +Find the [keybinding manual here](./docs/keybindings.md). + +If you want to change functionality of a core keybinding, edit [core/keys](./lua/core/keys.lua) + +To add new keybindings edit the [which-key config](./lua/plugins/tools/which-key.lua) + +### ๐ŸŽจ User Configs + +`nvim` supports a user module where you can store your custom configs, these will always override the default configs, whenever there is a clash. + +To use custom configs create the file `lua/user/init.lua`, you can structure your configs as you like there. + +> `lua/user/init.lua` must be present to load custom configs, `require` any custom modules in this file. + +`user` module is not part of the repo, you can set up `user` module as a separate git repository while continuously receiving `nvim2k` updates. + +#### ๐Ÿค– Auto Install + +By default nvim will auto install a set of LSP servers and null-ls sources using mason, if you want to disable it make sure to add the following to your user module. + +```lua +-- lua/user/init.lua +local user = { + auto_install = true, +} + +return user +``` + +To setup and access other user options you can use the `get_user_config(key, default)` method in `lib.util` + +Example: `local auto_install = require('lib.util').get_user_value('auto_install', true)` + +## ๐Ÿง‘โ€๐Ÿ’ป Behind The Code + +### ๐ŸŒˆ Inspiration + +I have been using vim/neovim for years now, I wanted to share my config for everyone to use + +### ๐Ÿ’ก Challenges/Learnings + +- Finding out the right plugins and configs! +- Setting up the initial config structure with lazy loading was tough. + +### ๐Ÿงฐ Tools Used + +- [dots](https://github.com/S4NKALP/hyprland) โ€” Desktop Environment +- [nvim](https://github.com/S4NKALP/nvim) โ€” Personalized Editor + +
+ +
+ +โญ hit the star button if you found this useful โญ
+ +
diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..1adfab1 --- /dev/null +++ b/init.lua @@ -0,0 +1,7 @@ +require('core.options') +require('core.functions') +require('core.keys') +require('core.autocmd') +require('plugins.lazy') +-- Add user configs to this module +pcall(require, 'user') diff --git a/lua/core/autocmd.lua b/lua/core/autocmd.lua new file mode 100644 index 0000000..75d9995 --- /dev/null +++ b/lua/core/autocmd.lua @@ -0,0 +1,107 @@ +local function augroup(name) + return vim.api.nvim_create_augroup('nvim' .. name, { clear = true }) +end + +-- Strip trailing spaces before write +vim.api.nvim_create_autocmd({ 'BufWritePre' }, { + group = augroup('strip_space'), + pattern = { '*' }, + callback = function() + vim.cmd([[ %s/\s\+$//e ]]) + end, +}) + +-- Check if we need to reload the file when it changed +vim.api.nvim_create_autocmd({ 'FocusGained', 'TermClose', 'TermLeave' }, { + group = augroup('checktime'), + command = 'checktime', +}) + +-- Highlight on yank +vim.api.nvim_create_autocmd('TextYankPost', { + group = augroup('highlight_yank'), + callback = function() + vim.highlight.on_yank() + end, +}) + +-- resize splits if window got resized +vim.api.nvim_create_autocmd({ 'VimResized' }, { + group = augroup('resize_splits'), + callback = function() + vim.cmd('tabdo wincmd =') + end, +}) + +-- go to last loc when opening a buffer +vim.api.nvim_create_autocmd('BufReadPost', { + group = augroup('last_loc'), + callback = function() + local mark = vim.api.nvim_buf_get_mark(0, '"') + local lcount = vim.api.nvim_buf_line_count(0) + if mark[1] > 0 and mark[1] <= lcount then + pcall(vim.api.nvim_win_set_cursor, 0, mark) + end + end, +}) + +-- close some filetypes with +vim.api.nvim_create_autocmd('FileType', { + group = augroup('close_with_q'), + pattern = { + 'DressingSelect', + 'Jaq', + 'PlenaryTestPopup', + 'fugitive', + 'help', + 'lir', + 'lspinfo', + 'man', + 'notify', + 'qf', + 'spectre_panel', + 'startuptime', + 'tsplayground', + }, + callback = function(event) + vim.bo[event.buf].buflisted = false + vim.keymap.set('n', 'q', 'close', { buffer = event.buf, silent = true }) + end, +}) + +-- wrap and check for spell in text filetypes +vim.api.nvim_create_autocmd('FileType', { + group = augroup('wrap_spell'), + pattern = { 'gitcommit', 'markdown' }, + callback = function() + vim.opt_local.wrap = true + vim.opt_local.spell = true + end, +}) + +-- Auto create dir when saving a file, in case some intermediate directory does not exist +vim.api.nvim_create_autocmd({ 'BufWritePre' }, { + group = augroup('auto_create_dir'), + callback = function(event) + local file = vim.loop.fs_realpath(event.match) or event.match + vim.fn.mkdir(vim.fn.fnamemodify(file, ':p:h'), 'p') + end, +}) + +-- Set arb filetype +vim.api.nvim_create_autocmd({ 'BufEnter' }, { + group = augroup('set_file_type'), + pattern = { '*.arb' }, + command = require('lib.util').get_file_type_cmd('arb'), +}) + +-- Disable format options +vim.api.nvim_create_autocmd('FileType', { + group = augroup('disable_formatoptions'), + pattern = '*', + callback = function() + vim.opt_local.formatoptions:remove({ 'c', 'r', 'o' }) + end, +}) + + diff --git a/lua/core/functions.lua b/lua/core/functions.lua new file mode 100644 index 0000000..6e2da4f --- /dev/null +++ b/lua/core/functions.lua @@ -0,0 +1,41 @@ +-- Reload neovim config +vim.api.nvim_create_user_command('ReloadConfig', function() + for name, _ in pairs(package.loaded) do + if name:match('^plugins') then + package.loaded[name] = nil + end + end + + dofile(vim.env.MYVIMRC) + vim.notify('Nvim configuration reloaded!', vim.log.levels.INFO) +end, {}) + +-- Copy relative path +vim.api.nvim_create_user_command('CopyRelativePath', function() + local path = vim.fn.expand('%') + vim.fn.setreg('+', path) + vim.notify('Copied "' .. path .. '" to the clipboard!') +end, {}) + +-- Copy absolute path +vim.api.nvim_create_user_command('CopyAbsolutePath', function() + local path = vim.fn.expand('%:p') + vim.fn.setreg('+', path) + vim.notify('Copied "' .. path .. '" to the clipboard!') +end, {}) + +vim.api.nvim_create_user_command('CopyFileName', function() + local path = vim.fn.expand('%:t') + vim.fn.setreg('+', path) + vim.notify('Copied "' .. path .. '" to the clipboard!') +end, {}) + +-- Switch to git root or file parent dir +vim.api.nvim_create_user_command('RootDir', function() + local root = require('lib.util').get_root_dir() + + if root == '' then + return + end + vim.cmd('lcd ' .. root) +end, {}) diff --git a/lua/core/keys.lua b/lua/core/keys.lua new file mode 100644 index 0000000..6e538f1 --- /dev/null +++ b/lua/core/keys.lua @@ -0,0 +1,211 @@ +local function map(mode, lhs, rhs, opts) + opts = opts or {} + opts.silent = opts.silent ~= false + vim.keymap.set(mode, lhs, rhs, opts) +end +local opts = { noremap = true, silent = true } +local icons = require('lib.icons') + +-- Space as leader +map('n', '', '', opts) +vim.g.mapleader = ' ' +vim.g.maplocalleader = ' ' + +-- Modes +-- normal_mode = "n", insert_mode = "i", visual_mode = "v", +-- visual_block_mode = "x", term_mode = "t", command_mode = "c", + +-- Save File +map({ + "i", + "v", + "n", + "s" +}, "", "w", { + desc = "Save file" +}) + +-- ctrl a to selected all text in file +map({ + "n", + "i", + "v" +}, "", "ggVG") + +-- Copy whole file +map("n", "", "%y+", { + desc = "Copy whole file" +}) + + +-- Paste +map("n", "]p", "op", { + desc = "Paste below" +}) +map("n", "[P", "Op", { + desc = "Paste above" +}) +map("i", "", '"+pa', { + desc = "Paste from clipboard" +}) +map({ + "n", + "x" +}, "", '"+y', { + desc = "Copy to clipboard" +}) + +-- Better escape using jk in insert and terminal mode +map("i", "jk", "") +map("i", "kj", "") +map("i", "jj", "") + +-- Terminal Mappings +map("t", "jk", "") +map("t", "kj", "") +map("t", "", "") + + +-- Visual overwrite paste +map({ 'v', 'x' }, 'p', '"_dP', opts) + +-- Do not copy on x +map({ 'v', 'x' }, 'x', '"_x', opts) + +-- Increment/decrement +map({ 'n', 'v', 'x' }, '-', '', opts) +map({ 'n', 'v', 'x' }, '=', '', opts) + +-- Move to line beginning and end +map({ 'n', 'v', 'x' }, 'gl', '$', { desc = 'End of line' }) +map({ 'n', 'v', 'x' }, 'gh', '^', { desc = 'Beginning of line' }) + +-- Center Cursors +map('n', 'J', 'mzJ`z', opts) +map('n', '', 'zz', opts) +map('n', '', 'zz', opts) +map('n', 'n', 'nzzzv', opts) +map('n', 'N', 'Nzzzv', opts) + +-- Better up/down +vim.keymap.set({ "n", "x" }, "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) +vim.keymap.set({ "n", "x" }, "", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) +vim.keymap.set({ "n", "x" }, "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) +vim.keymap.set({ "n", "x" }, "", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) + +-- Move text up and down +vim.keymap.set("n", "", "m .+1==", { desc = "Move Down" }) +vim.keymap.set("n", "", "m .-2==", { desc = "Move Up" }) +vim.keymap.set("i", "", "m .+1==gi", { desc = "Move Down" }) +vim.keymap.set("i", "", "m .-2==gi", { desc = "Move Up" }) +vim.keymap.set("v", "", ":m '>+1gv=gv", { desc = "Move Down" }) +vim.keymap.set("v", "", ":m '<-4gv=gv", { desc = "Move Up" }) + +-- Clear search, diff update and redraw +map({ 'i', 'n' }, '', 'noh', { desc = 'Escape and clear hlsearch' }) + +-- Consistent n/N search navigation +map('n', 'n', "'Nn'[v:searchforward]", { expr = true, desc = 'Next search result' }) +map('x', 'n', "'Nn'[v:searchforward]", { expr = true, desc = 'Next search result' }) +map('o', 'n', "'Nn'[v:searchforward]", { expr = true, desc = 'Next search result' }) +map('n', 'N', "'nN'[v:searchforward]", { expr = true, desc = 'Prev search result' }) +map('x', 'N', "'nN'[v:searchforward]", { expr = true, desc = 'Prev search result' }) +map('o', 'N', "'nN'[v:searchforward]", { expr = true, desc = 'Prev search result' }) + +-- Better indenting +map('v', '<', '', '>gv') + +-- Add undo breakpoints +map('i', ',', ',u') +map('i', '.', '.u') +map('i', ';', ';u') + + +-- Search +map({ + "n", + "x" +}, "gw", "*N", { + desc = "Search word under cursor" +}) + + +-- Insert empty line in insert mode +map("i", "", "o", { + desc = "Insert empty line below" +}) +map("i", "", "O", { + desc = "Insert empty line above" +}) + +-- Insert empty line without entering insert mode +map('n', '[o', ':call append(line("."), repeat([""], v:count1))', { + desc = "Insert empty line below" +}) +map('n', ']o', ':call append(line(".")-1, repeat([""], v:count1))', { + desc = "Insert empty line above" +}) + +-- go to beginning and end in insert mode +map("i", "", "^i", { + desc = "Go to beginning of line" +}) +map("i", "", "", { + desc = "Go to end of line" +}) + +-- navigate within insert mode +map("i", "", "", { + desc = "Move Left" +}) +map("i", "", "", { + desc = "Move Right" +}) +map("i", "", "", { + desc = "Move Down" +}) +map("i", "", "", { + desc = "Move Up" +}) + + +-- Move to window using the hjkl keys +vim.keymap.set("n", "", "h", { desc = "Go to Left Window", remap = true }) +vim.keymap.set("n", "", "j", { desc = "Go to Lower Window", remap = true }) +vim.keymap.set("n", "", "k", { desc = "Go to Upper Window", remap = true }) +vim.keymap.set("n", "", "l", { desc = "Go to Right Window", remap = true }) + + +-- Move with shift-arrows +map("n", "", "", { + desc = "Move window to the left" +}) +map("n", "", "", { + desc = "Move window down" +}) +map("n", "", "", { + desc = "Move window up" +}) +map("n", "", "", { + desc = "Move window to the right" +}) + +-- Resize window using arrow keys +vim.keymap.set("n", "", "resize +2", { desc = "Increase Window Height" }) +vim.keymap.set("n", "", "resize -2", { desc = "Decrease Window Height" }) +vim.keymap.set("n", "", "vertical resize -2", { desc = "Decrease Window Width" }) +vim.keymap.set("n", "", "vertical resize +2", { desc = "Increase Window Width" }) + + +-- Codeium +map('i', '', function () return vim.fn['codeium#Accept']() end, { expr = true, silent = true }) +map('i', '', function() return vim.fn['codeium#CycleCompletions'](1) end, { expr = true, silent = true }) +map('i', '', function() return vim.fn['codeium#CycleCompletions'](-1) end, { expr = true, silent = true }) +map('i', '', function() return vim.fn['codeium#Clear']() end, { expr = true, silent = true }) + + +map('n', 'mu', function() + require("notify").dismiss({ silent = true, pending = true }) + end, { desc = 'Dismiss All Notifications' }) + diff --git a/lua/core/options.lua b/lua/core/options.lua new file mode 100644 index 0000000..650d869 --- /dev/null +++ b/lua/core/options.lua @@ -0,0 +1,89 @@ +local options = { + ai = true, + autoindent = true, + autowrite = true, + backspace = 'indent,eol,start', + backup = false, -- creates a backup file + breakindent = true, + clipboard = 'unnamedplus', -- allows neovim to access the system clipboard + cmdheight = 1, -- more space in the neovim command line for displaying messages + completeopt = 'menu,menuone,noselect', -- mostly just for cmp + conceallevel = 0, -- so that `` is visible in markdown files + confirm = true, -- Confirm to save changes before exiting modified buffer + cursorline = true, -- highlight the current line + expandtab = true, -- convert tabs to spaces + fileencoding = 'utf-8', -- the encoding written to a file + formatoptions = 'jlnqt', -- set formatoptions, check help fo-table + grepformat = '%f:%l:%c:%m', + grepprg = 'rg --vimgrep', + hlsearch = true, -- highlight all matches on previous search pattern + ignorecase = true, -- ignore case in search patterns + inccommand = 'split', -- preview incremental substitute + laststatus = 3, + list = true, + listchars = { trail = '๏‘„', tab = '๏”๏„…', nbsp = '_', extends = '>', precedes = '<' }, -- highlight + mouse = 'a', -- allow the mouse to be used in neovim + number = true, -- set numbered lines + numberwidth = 4, -- set number column width to 2 {default 4} + pumblend = 10, -- Popup blen + pumheight = 10, -- pop up menu height + relativenumber = true, -- set relative numbered lines + scrolloff = 10, -- is one of my fav + sessionoptions = 'blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal', + shiftround = true, -- Round indent + shiftwidth = 4, -- the number of spaces inserted for each indentation + showcmd = false, + showmode = false, -- we don't need to see things like -- INSERT -- anymore + showtabline = 0, -- always show tabs + si = true, + sidescrolloff = 8, + signcolumn = 'yes', -- always show the sign column, otherwise it would shift the text each time + smartcase = true, -- smart case + smartindent = true, -- make indenting smarter again + smarttab = true, + splitbelow = true, -- force all horizontal splits to go below current window + splitright = true, -- force all vertical splits to go to the right of current window + swapfile = false, -- creates a swapfile + tabstop = 4, -- insert 2 spaces for a tab + termguicolors = true, -- set term gui colors (most terminals support this) + timeoutlen = 300, -- time to wait for a mapped sequence to complete (in milliseconds) + undofile = true, -- enable persistent undo + undolevels = 10000, + updatetime = 50, -- faster completion (4000ms default) + wildmenu = true, -- wildmenu + wildmode = 'longest:full,full', -- Command-line completion mode + winminwidth = 5, -- Minimum window width + wrap = false, -- display lines as one long line + writebackup = false, -- do not edit backups +} + +for k, v in pairs(options) do + vim.opt[k] = v +end + +-- netrw file explorer settings +vim.g.netrw_winsize = 20 +vim.g.netrw_banner = 0 +vim.g.netrw_liststyle = 1 + +-- Fix markdown indentation settings +vim.g.markdown_recommended_style = 0 + +vim.opt.path:append({ '**' }) +vim.opt.shortmess:append({ W = true, I = true, c = true }) + +-- hides `~` at the end of the buffer +vim.cmd([[set fillchars+=eob:\ ]]) + +vim.cmd([[ + setlocal spell spelllang=en "Set spellcheck language to en + setlocal spell! "Disable spell checks by default + filetype plugin indent on + if has('win32') + let g:python3_host_prog = $HOME . '/scoop/apps/python/current/python.exe' + endif + let &t_Cs = "\e[4:3m" "Undercurl + let &t_Ce = "\e[4:0m" + set whichwrap+=<,>,[,],h,l + set iskeyword+=- + ]]) diff --git a/lua/lib/icons.lua b/lua/lib/icons.lua new file mode 100644 index 0000000..00bcf56 --- /dev/null +++ b/lua/lib/icons.lua @@ -0,0 +1,164 @@ +return { + diagnostics = { + Error = '๏— ', + Hint = '๓ฐ   ', + Information = '๏š ', + Question = '๏™ ', + Warning = '๏ฑ ', + }, + documents = { + File = '๏…œ ', + FileEmpty = '๏€– ', + Files = '๏ƒ… ', + Folder = '๎—ฟ ', + FolderEmpty = '๏„” ', + OpenFolder = '๏ผ ', + OpenFolderEmpty = '๏„• ', + SymLink = '๏’ ', + SymlinkFolder = '๏’‚ ', + Import = '๎‰ฝ ', + }, + git = { + Add = '๏‘ ', + AddAlt = '๏‘— ', + Branch = '๏˜ ', + Diff = '๏‘€ ', + DiffAlt = '๏“’ ', + Ignore = 'โ—Œ ', + Mod = '๏‘„ ', + Octoface = '๏„“ ', + Remove = '๏’‹ ', + RemoveAlt = '๏‘˜ ', + Rename = '๏“ฐ ', + Repo = '๏ ', + Tag = '๏€ซ ', + Untrack = '๏“ƒ ', + }, + kind = { + Class = '๎ญฆ ', + Color = '๎ˆซ ', + Constant = '๎ญ ', + Constructor = '๓ฐˆ ', + Enum = '๏… ', + EnumMember = '๎ช• ', + Event = '๏ƒง ', + Field = '๏Ž ', + File = '๏…œ ', + Folder = '๎—ฟ ', + Function = '๓ฐŠ• ', + Interface = '๏ƒจ ', + Keyword = '๏‚„ ', + Method = '๏„ก ', + Module = '๏‘', + Operator = '๏‡ฌ ', + Property = '๏‚ญ ', + Reference = '๏’ ', + Snippet = '๏ƒ„ ', + Struct = '๏†ณ ', + Text = '๎˜’ ', + TypeParameter = '๏‡‹ ', + Unit = '๎ˆŸ ', + Value = '๏“ท ', + Variable = '๏’‡ ', + }, + type = { + Array = '๎ชŠ ', + Boolean = 'โป ', + Number = '๏Š’ ', + Object = '๏‰ˆ ', + String = '๏€ต ', + }, + ui = { + Arrow = '๏ฒ ', + ArrowClosed = '๏ธ ', + ArrowLeft = '๏‚จ ', + ArrowOpen = '๏” ', + ArrowRight = '๏‚ฉ ', + Bluetooth = '๏Š“ ', + Bookmark = '๏€ฎ ', + Bug = '๏†ˆ ', + Calendar = '๏ณ ', + Camera = '๏€ฐ ', + Check = '๏…Š ', + ChevronRight = '๏”', + Circle = '๏„‘ ', + CircleSmall = 'โ— ', + CircleSmallEmpty = 'โ—‹ ', + Clipboard = '๏ƒช ', + Close = '๏€ ', + Code = '๏„ก ', + Collection = '๏ƒŠ ', + Color = '๎ˆซ ', + Command = '๏ ', + Comment = '๏‰บ ', + Copilot = '๏’ธ ', + CopilotError = '๏’บ ', + Corner = 'โ”” ', + Dashboard = '๏‘ฃ ', + Database = '๏‡€ ', + Download = '๏‰ ', + Edge = 'โ”‚ ', + Electric = '๎ช† ', + Eye = '๏‘ ', + Fire = '๏’ ', + Firefox = '๏‰ฉ ', + Flag = '๏€ค ', + Game = '๏„› ', + Gear = '๏ฃ ', + GitHub = '๏ˆ ', + Heart = '๏“ก ', + History = '๏‡š ', + Home = '๏‘ญ ', + Incoming = '๏ฃถ ', + Jump = '๏“ฒ ', + Keyboard = '๏„œ ', + Ligthbulb = '๓ฐŒต ', + List = '๏€ข', + Lock = '๏€ฃ ', + Minus = 'โ€’ ', + Music = '๓ฐš ', + Neovim = '๏ฏ ', + NewFile = '๏…› ', + None = ' ', + Note = '๏‰‰ ', + Outgoing = '๏ฃบ ', + Package = '๏†ฒ ', + Paint = '๏‡ผ ', + Pause = '๏Œ ', + Pencil = '๏€ ', + Person = '๏€‡ ', + Pin = '๏ต ', + Play = '๏‹ ', + Plug = '๏‡ฆ ', + Plus = '๎ฉ  ', + Power = '๏€‘ ', + PowerlineArrowLeft = '๎‚ฒ', + PowerlineArrowRight = '๎‚ฐ', + PowerlineLeftRound = '๎‚ถ', + PowerlineRightRound = '๎‚ด', + Project = '๏ป ', + Question = '๏„จ ', + Reload = '๏€ก ', + Rocket = '๏„ต ', + Save = '๓ฐ†“ ', + Search = '๏ข ', + Separator = 'โ–Š ', + SeparatorLight = 'โ–', + SeparatorDashed = 'โ”†', + SignIn = '๏ช ', + SignOut = '๏ฆ ', + Sleep = '๓ฐ’ฒ ', + Star = '๏€… ', + Table = '๏ƒŽ ', + Telescope = '๏‘ซ ', + Terminal = '๏’‰ ', + Test = '๏ƒƒ ', + Time = '๏› ', + Topline = 'โ€พ', + Trash = '๏‡ธ ', + User = '๏“ฟ ', + Vim = '๎˜ซ ', + Wifi = '๏‡ซ ', + Windows = '๏…บ ', + }, +} diff --git a/lua/lib/util.lua b/lua/lib/util.lua new file mode 100644 index 0000000..b2f3de1 --- /dev/null +++ b/lua/lib/util.lua @@ -0,0 +1,66 @@ +local util = {} + +util.get_user_config = function(key, default) + local status_ok, user = pcall(require, 'user') + if not status_ok then + return default + end + + local user_config = user[key] + if user_config == nil then + return default + end + return user_config +end + +util.get_root_dir = function() + local bufname = vim.fn.expand('%:p') + if vim.fn.filereadable(bufname) == 0 then + return + end + + local parent = vim.fn.fnamemodify(bufname, ':h') + local git_root = vim.fn.systemlist('git -C ' .. parent .. ' rev-parse --show-toplevel') + if #git_root > 0 and git_root[1] ~= '' then + return git_root[1] + else + return parent + end +end + +util.get_file_type_cmd = function(extension) + local root = util.get_root_dir() + + if extension == 'arb' and root then + local gemfile_exists = vim.fn.filereadable(root .. '/Gemfile') == 1 + local pubspec_exists = vim.fn.filereadable(root .. '/pubspec.yaml') == 1 + if gemfile_exists then + return 'setfiletype ruby' + end + if pubspec_exists then + return 'setfiletype json' + end + end + return '' +end + +util.is_present = function(bin) + return vim.fn.executable(bin) == 1 +end + +util.telescope_select = function(options, options_desc, select_prompt) + require('telescope.pickers') + .new({}, { + prompt_title = select_prompt, + results_title = options_desc, + finder = require('telescope.finders').new_table({ + results = options, + entry_maker = require('telescope.make_entry').gen_from_file(), + }), + sorter = require('telescope.sorters').get_fzy_sorter(), + previewer = require('telescope.previewers').vim_buffer_cat.new({}), + }) + :find() +end + +return util diff --git a/lua/plugins/lang/ai.lua b/lua/plugins/lang/ai.lua new file mode 100644 index 0000000..45f69d4 --- /dev/null +++ b/lua/plugins/lang/ai.lua @@ -0,0 +1,35 @@ +local ai = require('mini.ai') + +ai.setup({ + custom_textobjects = { + o = ai.gen_spec.treesitter({ + a = { '@block.outer', '@conditional.outer', '@loop.outer' }, + i = { '@block.inner', '@conditional.inner', '@loop.inner' }, + }, {}), + f = ai.gen_spec.treesitter({ a = '@function.outer', i = '@function.inner' }, {}), + c = ai.gen_spec.treesitter({ a = '@class.outer', i = '@class.inner' }, {}), + t = { '<([%p%w]-)%f[^<%w][^<>]->.-', '^<.->().*()$' }, + }, + + mappings = { + -- Main textobject prefixes + around = 'a', + inside = 'i', + + -- Next/last variants + around_next = 'an', + inside_next = 'in', + around_last = 'al', + inside_last = 'il', + + -- Move cursor to corresponding edge of `a` textobject + goto_left = 'g[', + goto_right = 'g]', + }, + + -- How to search for object + -- 'cover', 'cover_or_next', 'cover_or_prev','cover_or_nearest', 'next', 'previous', 'nearest'. + search_method = 'cover_or_next', + n_lines = 500, + silent = false, +}) diff --git a/lua/plugins/lang/autopairs.lua b/lua/plugins/lang/autopairs.lua new file mode 100644 index 0000000..ae6231f --- /dev/null +++ b/lua/plugins/lang/autopairs.lua @@ -0,0 +1,26 @@ +local npairs = require('nvim-autopairs') + +npairs.setup({ + check_ts = true, + ts_config = { + lua = { 'string', 'source' }, + javascript = { 'string', 'template_string' }, + java = false, + }, + disable_filetype = { 'TelescopePrompt', 'spectre_panel' }, + fast_wrap = { + map = '', + chars = { '{', '[', '(', '"', "'" }, + pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], '%s+', ''), + offset = 0, + end_key = '$', + keys = 'qwertyuiopzxcvbnmasdfghjkl', + check_comma = true, + highlight = 'PmenuSel', + highlight_grey = 'LineNr', + }, +}) + +local cmp_autopairs = require('nvim-autopairs.completion.cmp') +local cmp = require('cmp') +cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } })) diff --git a/lua/plugins/lang/cmp.lua b/lua/plugins/lang/cmp.lua new file mode 100644 index 0000000..4ff4069 --- /dev/null +++ b/lua/plugins/lang/cmp.lua @@ -0,0 +1,246 @@ +local cmp = require('cmp') +local luasnip = require('luasnip') + +require('luasnip/loaders/from_vscode').lazy_load() + +local icons = require('lib.icons') +local kind_icons = icons.kind + +local max_count = 15 + local rounded_border = true + + local function border(hl_name) + if rounded_border then + return { + { "โ•ญ", hl_name }, + { "โ”€", hl_name }, + { "โ•ฎ", hl_name }, + { "โ”‚", hl_name }, + { "โ•ฏ", hl_name }, + { "โ”€", hl_name }, + { "โ•ฐ", hl_name }, + { "โ”‚", hl_name }, + } + else + return { + { "โ”Œ", hl_name }, + { "โ”€", hl_name }, + { "โ”", hl_name }, + { "โ”‚", hl_name }, + { "โ”˜", hl_name }, + { "โ”€", hl_name }, + { "โ””", hl_name }, + { "โ”‚", hl_name }, + } + end + end + + -- ๏— ๏šจ ๏ญ„ ๏ฏŸ ๏‘ ๏™ฑ some other good icons + local kind_icons = { + Text = "๎˜’", + Method = "๏„ก '", + Function = "๓ฐŠ•", + Constructor = "๓ฐˆ", + Field = "๏Ž", + Variable = "๏’‡", + Class = "๎ญฆ", + Interface = "๏ƒจ", + Module = "๏’‡", + Property = "๏‚ญ", + Unit = "๎ˆŸ", + Value = "๏“ท ", + Enum = "๏… ", + Keyword = "๏‚„", + Snippet = "๏ƒ„", + Color = "๎ˆซ", + File = "๏…œ ", + Reference = "๏’", + Folder = "๎—ฟ", + EnumMember = "๎ช•", + Constant = "๎ญ", + Struct = "๏†ณ", + Event = "๏ƒง", + Operator = "๏‡ฌ", + TypeParameter = "๏‡‹", + } + +cmp.setup({ + completion = { + completeopt = 'menu,menuone,preview,noselect', + }, + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + + mapping = { + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping(cmp.mapping.scroll_docs(-1), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.scroll_docs(1), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.config.disable, + [''] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + [''] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expandable() then + luasnip.expand() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + }, + formatting = { + fields = { 'kind', 'abbr', 'menu' }, + expandable_indicator = true, + format = function(entry, vim_item) + -- Kind icons + vim_item.kind = kind_icons[vim_item.kind] + vim_item.menu = ({ + codeium = '[Codeium]', + nvim_lsp = '[LSP]', + luasnip = '[Snippet]', + buffer = '[Buffer]', + path = '[Path]', + })[entry.source.name] + return vim_item + end, + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'path' }, + { name = 'nvim_lua' }, + { name = 'luasnip', keyword_length = 2 }, + { name = 'buffer', keyword_length = 3 }, + { name = 'codeium'}, + { name = 'lazydev', group_index = 0 }, + }, + confirm_opts = { + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }, + window = { + documentation = { + border = 'rounded', + winhighlight = 'NormalFloat:Pmenu,NormalFloat:Pmenu,CursorLine:PmenuSel,Search:None', + max_height = 15, + scrollbar = false, + }, + completion = { + border = 'rounded', + winhighlight = 'NormalFloat:Pmenu,NormalFloat:Pmenu,CursorLine:PmenuSel,Search:None', + scrollbar = false, + }, + }, + experimental = { + ghost_text = true + } +}) + + -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline({'/','?'}, { + formatting = { + fields = { "kind", "abbr" }, + format = function(entry, vim_item) + -- Kind icons + vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) + vim_item.menu = ({ + buffer = "(buffer)" + })[entry.source.name] + return vim_item + end, + }, + mapping = cmp.mapping.preset.cmdline(), + sources = { + { + name = 'buffer', + option = { max_item_count = max_count } + } + } + }) + + -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline(':', { + formatting = { + fields = { "kind", "abbr", "menu" }, + format = function(entry, vim_item) + -- Kind icons + vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) + vim_item.menu = ({ + buffer = "(buffer)", + path = "(path)", + })[entry.source.name] + return vim_item + end, + }, + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { + name = 'path', + option = { max_item_count = 10 } + } + }, + { + { + name = 'cmdline', + option = { max_item_count = 10 } + } + }) + }) + + cmp.setup.filetype("lua", { + sources = cmp.config.sources({ + { name = 'luasnip' }, -- For luasnip users. + { name = 'nvim_lsp' }, + { + name = "nvim_lua", + option = { max_item_count = max_count } + }, + { + name = 'buffer', + option = { keyword_length = 1 } + }, + { name = "path" }, + { name = "orgmode" }, + }), + }) + + cmp.setup.filetype("norg", { + sources = cmp.config.sources({ + { name = 'luasnip' }, -- For luasnip users. + { + name = 'neorg', + option = { max_item_count = max_count } + }, + { name = 'buffer', }, + { name = "path" }, + }) + }) + +require("luasnip.loaders.from_vscode").lazy_load() +local snippet_path = vim.fn.stdpath("config") .. "/snippets" +require("luasnip.loaders.from_snipmate").load({ path = { snippet_path } }) + + diff --git a/lua/plugins/lang/codeium.lua b/lua/plugins/lang/codeium.lua new file mode 100644 index 0000000..bae659d --- /dev/null +++ b/lua/plugins/lang/codeium.lua @@ -0,0 +1,4 @@ +require('codeium').setup({ + +}) + diff --git a/lua/plugins/lang/comment.lua b/lua/plugins/lang/comment.lua new file mode 100644 index 0000000..3079776 --- /dev/null +++ b/lua/plugins/lang/comment.lua @@ -0,0 +1,26 @@ +local comment = require('mini.comment') + +require('ts_context_commentstring').setup({ + enable_autocmd = false, + -- languages = { typescript = '// %s' }, +}) + +comment.setup({ + options = { + custom_commentstring = function() + return require('ts_context_commentstring.internal').calculate_commentstring() or vim.bo.commentstring + end, + ignore_blank_line = true, + start_of_line = false, + pad_comment_parts = true, + }, + + mappings = { + -- Toggle comment (like `gcip` - comment inner paragraph) for both + comment = 'gc', + comment_line = 'gcc', + comment_visual = 'gc', + -- Define 'comment' textobject (like `dgc` - delete whole comment block) + textobject = 'gc', + }, +}) diff --git a/lua/plugins/lang/dap.lua b/lua/plugins/lang/dap.lua new file mode 100644 index 0000000..c427723 --- /dev/null +++ b/lua/plugins/lang/dap.lua @@ -0,0 +1,152 @@ +local dap = require('dap') +local dapui = require('dapui') +local icons = require('lib.icons') + +dapui.setup({ + icons = { expanded = icons.ui.ArrowClosed, collapsed = icons.ui.ArrowOpen }, + mappings = { + expand = { '', '<2-LeftMouse>' }, + open = 'o', + remove = 'd', + edit = 'e', + repl = 'r', + toggle = 't', + }, + expand_lines = vim.fn.has('nvim-0.7'), + layouts = { + { + elements = { + { id = 'scopes', size = 0.25 }, + 'breakpoints', + 'stacks', + 'watches', + }, + size = 40, + position = 'right', + }, + { + elements = { + 'repl', + 'console', + }, + size = 0.25, + position = 'bottom', + }, + }, + floating = { + max_height = nil, + max_width = nil, + border = 'rounded', + mappings = { + close = { 'q', '' }, + }, + }, + windows = { indent = 1 }, + render = { + max_type_length = nil, + }, +}) + +vim.fn.sign_define('DapBreakpoint', { text = icons.ui.Bug, texthl = 'DiagnosticSignError', linehl = '', numhl = '' }) + +dap.listeners.after.event_initialized['dapui_config'] = function() + dapui.open() +end +dap.listeners.before.event_terminated['dapui_config'] = function() + dapui.close() +end +dap.listeners.before.event_exited['dapui_config'] = function() + dapui.close() +end + +dap.adapters.python = { + type = 'executable', + command = '/usr/bin/python', + args = { '-m', 'debugpy.adapter' }, +} + +dap.configurations.python = { + { + type = 'python', + request = 'launch', + name = 'Launch file', + + program = '${file}', + pythonPath = function() + local cwd = vim.fn.getcwd() + if vim.fn.executable(cwd .. '/venv/bin/python') == 1 then + return cwd .. '/venv/bin/python' + elseif vim.fn.executable(cwd .. '/.venv/bin/python') == 1 then + return cwd .. '/.venv/bin/python' + else + return '/usr/bin/python' + end + end, + }, +} + +dap.adapters.ruby = { + type = 'executable', + command = 'bundle', + args = { 'exec', 'readapt', 'stdio' }, +} + +dap.configurations.ruby = { + { + type = 'ruby', + request = 'launch', + name = 'Rails', + program = 'bundle', + programArgs = { 'exec', 'rails', 's' }, + useBundler = true, + }, +} + +dap.configurations.java = { + { + name = "Debug Launch (2GB)"; + type = 'java'; + request = 'launch'; + vmArgs = "" .. + "-Xmx2g " + }, + { + name = "Debug Attach (8000)"; + type = 'java'; + request = 'attach'; + hostName = "127.0.0.1"; + port = 8000; + }, + { + name = "Debug Attach (5005)"; + type = 'java'; + request = 'attach'; + hostName = "127.0.0.1"; + port = 5005; + }, + { + name = "My Custom Java Run Configuration", + type = "java", + request = "launch", + -- You need to extend the classPath to list your dependencies. + -- `nvim-jdtls` would automatically add the `classPaths` property if it is missing + -- classPaths = {}, + + -- If using multi-module projects, remove otherwise. + -- projectName = "yourProjectName", + + -- javaExec = "java", + mainClass = "replace.with.your.fully.qualified.MainClass", + + -- If using the JDK9+ module system, this needs to be extended + -- `nvim-jdtls` would automatically populate this property + -- modulePaths = {}, + vmArgs = "" .. + "-Xmx2g " + }, + } + + +vim.api.nvim_create_user_command('DapUIToggle', function() + require('dapui').toggle() +end, {}) diff --git a/lua/plugins/lang/lsp-lines.lua b/lua/plugins/lang/lsp-lines.lua new file mode 100644 index 0000000..4e24179 --- /dev/null +++ b/lua/plugins/lang/lsp-lines.lua @@ -0,0 +1,4 @@ +local lsp_lines = require('lsp_lines') + +lsp_lines.setup() +vim.diagnostic.config({ virtual_text = false }) diff --git a/lua/plugins/lang/lspconfig.lua b/lua/plugins/lang/lspconfig.lua new file mode 100644 index 0000000..fbb9dd2 --- /dev/null +++ b/lua/plugins/lang/lspconfig.lua @@ -0,0 +1,49 @@ +local lspconfig = require('lspconfig') +local cmp_lsp = require('cmp_nvim_lsp') +local icons = require('lib.icons').diagnostics + +local auto_install = require('lib.util').get_user_config('auto_install', true) +local installed_servers = {} +if auto_install then + installed_servers = require('plugins.list').lsp_servers +end + +local lsp_capabilities = cmp_lsp.default_capabilities() +local default_setup = function(server) + lspconfig[server].setup({ + capabilities = lsp_capabilities, + }) +end + +local signs = { Error = icons.Error, Warn = icons.Warning, Hint = icons.Hint, Info = icons.Information } +for type, icon in pairs(signs) do + local hl = 'DiagnosticSign' .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' }) +end + +require('mason-lspconfig').setup({ + ensure_installed = installed_servers, + handlers = { + default_setup, + lua_ls = function() + lspconfig.lua_ls.setup({ + capabilities = lsp_capabilities, + settings = { + Lua = { + runtime = { version = 'LuaJIT' }, + diagnostics = { globals = { 'vim' } }, + workspace = { library = { vim.env.VIMRUNTIME } }, + format = { + enable = true, + defaultConfig = { + align_continuous_assign_statement = false, + align_continuous_rect_table_field = false, + align_array_table = false, + }, + }, + }, + }, + }) + end, + }, +}) diff --git a/lua/plugins/lang/lspsaga.lua b/lua/plugins/lang/lspsaga.lua new file mode 100644 index 0000000..892e3b5 --- /dev/null +++ b/lua/plugins/lang/lspsaga.lua @@ -0,0 +1,21 @@ +local lspsaga = require('lspsaga') + +local icons = require('lib.icons') + +lspsaga.setup({ + ui = { + theme = 'round', + border = 'rounded', + devicon = true, + title = true, + winblend = 1, + expand = icons.ui.ArrowOpen, + collapse = icons.ui.ArrowClosed, + preview = icons.ui.List, + code_action = icons.diagnostics.Hint, + diagnostic = icons.ui.Bug, + incoming = icons.ui.Incoming, + outgoing = icons.ui.Outgoing, + hover = icons.ui.Comment, + }, +}) diff --git a/lua/plugins/lang/mason.lua b/lua/plugins/lang/mason.lua new file mode 100644 index 0000000..aa10be6 --- /dev/null +++ b/lua/plugins/lang/mason.lua @@ -0,0 +1,35 @@ +local mason = require('mason') + +local icons = require('lib.icons') +mason.setup({ + -- - "prepend": Use mason binary, "append": Use system binary + PATH = 'append', + + log_level = vim.log.levels.INFO, + max_concurrent_installers = 8, + + ui = { + check_outdated_packages_on_open = true, + border = 'rounded', + width = 0.8, + height = 0.8, + + icons = { + package_installed = icons.ui.Gear, + package_pending = icons.ui.Download, + package_uninstalled = icons.ui.Plus, + }, + + keymaps = { + toggle_package_expand = '', + install_package = 'i', + update_package = 'u', + check_package_version = 'c', + update_all_packages = 'U', + check_outdated_packages = 'C', + uninstall_package = 'x', + cancel_installation = '', + apply_language_filter = '', + }, + }, +}) diff --git a/lua/plugins/lang/neotest.lua b/lua/plugins/lang/neotest.lua new file mode 100644 index 0000000..e5fc2c6 --- /dev/null +++ b/lua/plugins/lang/neotest.lua @@ -0,0 +1,20 @@ +local neotest = require('neotest') + +neotest.setup({ + adapters = { + require('neotest-rspec')({ + rspec_cmd = function() + return vim.tbl_flatten({ + 'bundle', + 'exec', + 'rspec', + }) + end, + }), + require('neotest-jest')({ + jestCommand = 'npx jest --', + jestConfigFile = 'jest.config.js', + }), + require('neotest-python'), + }, +}) diff --git a/lua/plugins/lang/null-ls.lua b/lua/plugins/lang/null-ls.lua new file mode 100644 index 0000000..c095176 --- /dev/null +++ b/lua/plugins/lang/null-ls.lua @@ -0,0 +1,51 @@ +local null_ls = require('null-ls') + +local action = null_ls.builtins.code_actions +local comp = null_ls.builtins.completion +local diag = null_ls.builtins.diagnostics +local format = null_ls.builtins.formatting +local hover = null_ls.builtins.hover + +-- Buily in sources: https://github.com/nvimtools/none-ls.nvim/blob/main/doc/BUILTINS.md +null_ls.setup({ + debug = false, + border = 'rounded', + log_level = 'info', + diagnostics_format = '#{c} #{m} (#{s})', + sources = { + action.proselint, -- markdown actions + action.refactoring, + action.ts_node_action, -- treesitter node actions + comp.spell, -- spell completion + comp.tags, -- tags completion + diag.actionlint, -- github action lint + diag.credo, -- elixir diagnostics + diag.golangci_lint, + diag.hadolint, -- docker lint + diag.proselint, -- markdown lint + diag.reek, -- ruby code smell + diag.rubocop, -- ruby diagnostics + diag.todo_comments, + diag.trail_space, -- trailing space check + diag.vint, -- vim lint + diag.write_good, -- english writing style + format.mix, -- elixir formatter + format.prettier, -- js, md, css, etc formatter + format.rubocop, -- ruby formatter + format.shfmt, -- shell formatter + format.stylua, -- lua formatter + hover.dictionary, -- show word dictionary on hover + hover.printenv, -- show env on hover + }, +}) + +local auto_install = require('lib.util').get_user_config('auto_install', true) +local installed_sources = {} +if auto_install then + installed_sources = require('plugins.list').null_ls_sources +end + +require('mason-null-ls').setup({ + ensure_installed = installed_sources, + automatic_installation = auto_install, +}) diff --git a/lua/plugins/lang/refactoring.lua b/lua/plugins/lang/refactoring.lua new file mode 100644 index 0000000..26b4a20 --- /dev/null +++ b/lua/plugins/lang/refactoring.lua @@ -0,0 +1,25 @@ +local refactoring = require('refactoring') + +refactoring.setup({ + prompt_func_return_type = { + go = false, + java = false, + cpp = false, + c = false, + h = false, + hpp = false, + cxx = false, + }, + prompt_func_param_type = { + go = false, + java = false, + + cpp = false, + c = false, + h = false, + hpp = false, + cxx = false, + }, + printf_statements = {}, + print_var_statements = {}, +}) diff --git a/lua/plugins/lang/ror.lua b/lua/plugins/lang/ror.lua new file mode 100644 index 0000000..8c988d4 --- /dev/null +++ b/lua/plugins/lang/ror.lua @@ -0,0 +1,20 @@ +local ror = require('ror') +local icons = require('lib.icons') + +ror.setup({ + test = { + message = { + file = 'Running test file...', + line = 'Running single test...', + }, + coverage = { + up = 'DiffAdd', + down = 'DiffDelete', + }, + notification = { + timeout = false, + }, + pass_icon = icons.ui.Check, + fail_icon = icons.ui.Close, + }, +}) diff --git a/lua/plugins/lang/sniprun.lua b/lua/plugins/lang/sniprun.lua new file mode 100644 index 0000000..8dec6f1 --- /dev/null +++ b/lua/plugins/lang/sniprun.lua @@ -0,0 +1,14 @@ +local sniprun = require('sniprun') + +sniprun.setup({ + display = { 'VirtualTextOk', 'VirtualTextErr' }, + show_no_output = { 'Classic', 'TempFloatingWindow' }, + + display_options = { + terminal_width = 45, + notification_timeout = 5, + }, + + inline_messages = 0, + borders = 'single', +}) diff --git a/lua/plugins/lang/surround.lua b/lua/plugins/lang/surround.lua new file mode 100644 index 0000000..73e4478 --- /dev/null +++ b/lua/plugins/lang/surround.lua @@ -0,0 +1,25 @@ +local surround = require('mini.surround') + +surround.setup({ + custom_surroundings = nil, + mappings = { + add = 'gsa', + delete = 'gsd', + find = 'gsf', + find_left = 'gsF', + highlight = 'gsh', + replace = 'gsr', + update_n_lines = 'gsn', + + suffix_last = 'l', -- Suffix to search with "prev" method + suffix_next = 'n', -- Suffix to search with "next" method + }, + + -- How to search for surrounding + -- 'cover', 'cover_or_next', 'cover_or_prev','cover_or_nearest', 'next', 'previous', 'nearest'. + search_method = 'cover_or_nearest', + highlight_duration = 500, + n_lines = 20, + respect_selection_type = false, + silent = false, +}) diff --git a/lua/plugins/lang/textobjects.lua b/lua/plugins/lang/textobjects.lua new file mode 100644 index 0000000..ccc83da --- /dev/null +++ b/lua/plugins/lang/textobjects.lua @@ -0,0 +1,115 @@ +local textobjects = { + select = { + enable = true, + lookahead = true, + + keymaps = { + ['a='] = { query = '@assignment.outer', desc = 'Select outer part of an assignment' }, + ['i='] = { query = '@assignment.inner', desc = 'Select inner part of an assignment' }, + ['al='] = { query = '@assignment.lhs', desc = 'Select left hand side of an assignment' }, + ['ar='] = { + query = '@assignment.rhs', + desc = 'Select right hand side of an assignment', + }, + + ['a:'] = { query = '@property.outer', desc = 'Select outer part of an object property' }, + ['i:'] = { query = '@property.inner', desc = 'Select inner part of an object property' }, + ['l:'] = { query = '@property.lhs', desc = 'Select left part of an object property' }, + ['r:'] = { query = '@property.rhs', desc = 'Select right part of an object property' }, + + ['aa'] = { + query = '@parameter.outer', + desc = 'Select outer part of a parameter/argument', + }, + ['ia'] = { + query = '@parameter.inner', + desc = 'Select inner part of a parameter/argument', + }, + + ['ai'] = { query = '@conditional.outer', desc = 'Select outer part of a conditional' }, + ['ii'] = { query = '@conditional.inner', desc = 'Select inner part of a conditional' }, + + ['al'] = { query = '@loop.outer', desc = 'Select outer part of a loop' }, + ['il'] = { query = '@loop.inner', desc = 'Select inner part of a loop' }, + + ['af'] = { query = '@call.outer', desc = 'Select outer part of a function call' }, + ['if'] = { query = '@call.inner', desc = 'Select inner part of a function call' }, + + ['am'] = { + query = '@function.outer', + desc = 'Select outer part of a method/function definition', + }, + ['im'] = { + query = '@function.inner', + desc = 'Select inner part of a method/function definition', + }, + + ['ac'] = { query = '@class.outer', desc = 'Select outer part of a class' }, + ['ic'] = { query = '@class.inner', desc = 'Select inner part of a class' }, + }, + }, + swap = { + enable = true, + swap_next = { + ['rna'] = '@parameter.inner', -- swap object property with next + ['rn:'] = '@property.outer', -- swap parameters/argument with next + ['rnm'] = '@function.outer', -- swap function with next + }, + swap_previous = { + ['rpa'] = '@parameter.inner', -- swap parameters/argument with prev + ['rp:'] = '@property.outer', -- swap object property with prev + ['rpm'] = '@function.outer', -- swap function with previous + }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + [']f'] = { query = '@call.outer', desc = 'Next function call start' }, + [']m'] = { query = '@function.outer', desc = 'Next method/function def start' }, + [']c'] = { query = '@class.outer', desc = 'Next class start' }, + [']i'] = { query = '@conditional.outer', desc = 'Next conditional start' }, + [']l'] = { query = '@loop.outer', desc = 'Next loop start' }, + + -- You can pass a query group to use query from `queries//.scm file in your runtime path. + -- Below example nvim-treesitter's `locals.scm` and `folds.scm`. They also provide highlights.scm and indent.scm. + [']S'] = { query = '@scope', query_group = 'locals', desc = 'Next scope' }, + [']z'] = { query = '@fold', query_group = 'folds', desc = 'Next fold' }, + }, + goto_next_end = { + [']F'] = { query = '@call.outer', desc = 'Next function call end' }, + [']M'] = { query = '@function.outer', desc = 'Next method/function def end' }, + [']C'] = { query = '@class.outer', desc = 'Next class end' }, + [']I'] = { query = '@conditional.outer', desc = 'Next conditional end' }, + [']L'] = { query = '@loop.outer', desc = 'Next loop end' }, + }, + goto_previous_start = { + ['[f'] = { query = '@call.outer', desc = 'Prev function call start' }, + ['[m'] = { query = '@function.outer', desc = 'Prev method/function def start' }, + ['[c'] = { query = '@class.outer', desc = 'Prev class start' }, + ['[i'] = { query = '@conditional.outer', desc = 'Prev conditional start' }, + ['[l'] = { query = '@loop.outer', desc = 'Prev loop start' }, + }, + goto_previous_end = { + ['[F'] = { query = '@call.outer', desc = 'Prev function call end' }, + ['[M'] = { query = '@function.outer', desc = 'Prev method/function def end' }, + ['[C'] = { query = '@class.outer', desc = 'Prev class end' }, + ['[I'] = { query = '@conditional.outer', desc = 'Prev conditional end' }, + ['[L'] = { query = '@loop.outer', desc = 'Prev loop end' }, + }, + }, +} + +local ts_repeat_move = require('nvim-treesitter.textobjects.repeatable_move') + +-- vim way: ; goes to the direction you were moving. +vim.keymap.set({ 'n', 'x', 'o' }, ';', ts_repeat_move.repeat_last_move) +vim.keymap.set({ 'n', 'x', 'o' }, ',', ts_repeat_move.repeat_last_move_opposite) + +-- Optionally, make builtin f, F, t, T also repeatable with ; and , +vim.keymap.set({ 'n', 'x', 'o' }, 'f', ts_repeat_move.builtin_f) +vim.keymap.set({ 'n', 'x', 'o' }, 'F', ts_repeat_move.builtin_F) +vim.keymap.set({ 'n', 'x', 'o' }, 't', ts_repeat_move.builtin_t) +vim.keymap.set({ 'n', 'x', 'o' }, 'T', ts_repeat_move.builtin_T) + +return textobjects diff --git a/lua/plugins/lang/treesitter.lua b/lua/plugins/lang/treesitter.lua new file mode 100644 index 0000000..28efb08 --- /dev/null +++ b/lua/plugins/lang/treesitter.lua @@ -0,0 +1,78 @@ +local treesitter = require('nvim-treesitter.configs') +local textobjects = require('plugins.lang.textobjects') + +local auto_install = require('lib.util').get_user_config('auto_install', true) +local installed_parsers = {} +if auto_install then + installed_parsers = require('plugins.list').ts_parsers +end + +treesitter.setup({ + ensure_installed = installed_parsers, + sync_install = false, + ignore_install = {}, + auto_install = true, + + textobjects = textobjects, + autopairs = { enable = true }, + endwise = { enable = true }, + autotag = { enable = true }, + matchup = { enable = true }, + indent = { enable = true }, + + highlight = { + enable = true, + disable = {}, + additional_vim_regex_highlighting = false, + }, + + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + scope_incremental = false, + node_decremental = '', + }, + }, + + textsubjects = { + enable = true, + prev_selection = ',', + keymaps = { + ['.'] = { 'textsubjects-smart', desc = 'Select the current text subject' }, + ['a;'] = { + 'textsubjects-container-outer', + desc = 'Select outer container (class, function, etc.)', + }, + ['i;'] = { + 'textsubjects-container-inner', + desc = 'Select inside containers (classes, functions, etc.)', + }, + }, + }, + + refactor = { + highlight_definitions = { + enable = true, + clear_on_cursor_move = true, + }, + highlight_current_scope = { enable = true }, + smart_rename = { + enable = true, + keymaps = { + smart_rename = 'rr', + }, + }, + navigation = { + enable = true, + keymaps = { + goto_definition = 'rd', + list_definitions = 'rl', + list_definitions_toc = 'rh', + goto_next_usage = 'rj', + goto_previous_usage = 'rk', + }, + }, + }, +}) diff --git a/lua/plugins/lazy.lua b/lua/plugins/lazy.lua new file mode 100644 index 0000000..94843c9 --- /dev/null +++ b/lua/plugins/lazy.lua @@ -0,0 +1,109 @@ +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', + '--single-branch', + 'https://github.com/folke/lazy.nvim.git', + lazypath, + }) +end +vim.opt.runtimepath:prepend(lazypath) + +local status_ok, lazy = pcall(require, 'lazy') +if not status_ok then + return +end + +local icons = require('lib.icons') +local plugins = require('plugins.list').plugins + +lazy.setup({ + root = vim.fn.stdpath('data') .. '/lazy', + defaults = { lazy = true }, + spec = plugins, + lockfile = vim.fn.stdpath('config') .. '/lua/plugins/lock.json', + concurrency = 8, + dev = { path = '~/Projects/GitHub/', patterns = {}, fallback = false }, + install = { missing = true, colorscheme = { 'onedark' } }, + + git = { + log = { '--since=3 days ago' }, + timeout = 120, + url_format = 'https://github.com/%s.git', + filter = true, + }, + + ui = { + size = { width = 0.9, height = 0.8 }, + wrap = true, + border = 'rounded', + icons = { + cmd = icons.ui.Terminal, + config = icons.ui.Gear, + event = icons.ui.Electric, + ft = icons.documents.File, + init = icons.ui.Rocket, + import = icons.documents.Import, + keys = icons.ui.Keyboard, + lazy = icons.ui.Sleep, + loaded = icons.ui.CircleSmall, + not_loaded = icons.ui.CircleSmallEmpty, + plugin = icons.ui.Package, + runtime = icons.ui.Neovim, + source = icons.ui.Code, + start = icons.ui.Play, + task = icons.ui.Check, + list = { + icons.ui.CircleSmall, + icons.ui.Arrow, + icons.ui.Star, + icons.ui.Minus, + }, + }, + browser = nil, + throttle = 20, + custom_keys = { + ['l'] = function(plugin) + require('lazy.util').float_term({ 'lazygit', 'log' }, { + cwd = plugin.dir, + }) + end, + + ['t'] = function(plugin) + require('lazy.util').float_term(nil, { + cwd = plugin.dir, + }) + end, + }, + }, + + diff = { cmd = 'git' }, + checker = { enabled = false, concurrency = nil, notify = true, frequency = 3600 }, + change_detection = { enabled = true, notify = true }, + performance = { + cache = { enabled = true }, + reset_packpath = true, + rtp = { + reset = true, + paths = {}, + disabled_plugins = { + 'gzip', + 'tarPlugin', + 'zipPlugin', + 'tohtml', + -- 'tutor', + -- 'matchit', + -- 'matchparen', + -- 'netrwPlugin', + }, + }, + }, + readme = { + root = vim.fn.stdpath('state') .. '/lazy/readme', + files = { 'README.md', 'lua/**/README.md' }, + skip_if_doc_exists = true, + }, + state = vim.fn.stdpath('state') .. '/lazy/state.json', +}) diff --git a/lua/plugins/list.lua b/lua/plugins/list.lua new file mode 100644 index 0000000..23a70f2 --- /dev/null +++ b/lua/plugins/list.lua @@ -0,0 +1,547 @@ +local function load_config(package) + return function() + require('plugins.' .. package) + end +end + +local plugins = { + -- UI + { + 'navarasu/onedark.nvim', + config = load_config('ui.onedark'), + lazy = false, + priority = 1000, + }, + { + 'nvim-lualine/lualine.nvim', + config = load_config('ui.lualine'), + event = { 'BufReadPre', 'BufNewFile' }, + }, + { + 'lukas-reineke/indent-blankline.nvim', + config = load_config('ui.indentline'), + main = 'ibl', + event = { 'BufReadPre', 'BufNewFile' }, + }, + { + 'HiPhish/rainbow-delimiters.nvim', + config = load_config('ui.rainbow'), + event = { 'BufReadPre', 'BufNewFile' }, + }, + { + 'rcarriga/nvim-notify', + config = load_config('ui.notify'), + event = 'VeryLazy', + cmd = 'Notifications', + }, + { + 'stevearc/dressing.nvim', + config = load_config('ui.dressing'), + event = { 'BufReadPre', 'BufNewFile' }, + }, + { + 'nvimdev/dashboard-nvim', + dependencies = { + "rubiin/fortune.nvim", + config = true, + }, + config = load_config('ui.dashboard'), + -- Only load when no arguments + event = function() + if vim.fn.argc() == 0 then + return 'VimEnter' + end + end, + cmd = 'Dashboard', + }, + { + 'folke/noice.nvim', + event = 'VimEnter', + dependencies = { + 'MunifTanjim/nui.nvim', + 'rcarriga/nvim-notify', + }, + config = load_config('ui.noice'), + }, + { + 'folke/zen-mode.nvim', + dependencies = { + 'folke/twilight.nvim', + config = load_config('ui.twilight'), + }, + config = load_config('ui.zen-mode'), + cmd = { 'ZenMode', 'Twilight' }, + }, + + -- Language + { + 'mfussenegger/nvim-dap', + dependencies = { + 'rcarriga/nvim-dap-ui', + }, + config = load_config('lang.dap'), + cmd = { 'DapUIToggle', 'DapToggleRepl', 'DapToggleBreakpoint' }, + }, + { + 'nvim-neotest/neotest', + dependencies = { + 'nvim-neotest/nvim-nio', + 'olimorris/neotest-rspec', + 'nvim-neotest/neotest-jest', + 'nvim-neotest/neotest-python', + }, + config = load_config('lang.neotest'), + cmd = 'Neotest', + }, + { + 'michaelb/sniprun', + build = 'bash ./install.sh', + config = load_config('lang.sniprun'), + cmd = 'SnipRun', + }, + { + 'ThePrimeagen/refactoring.nvim', + config = load_config('lang.refactoring'), + }, + { + 'windwp/nvim-autopairs', + config = load_config('lang.autopairs'), + event = 'InsertEnter', + }, + { + 'echasnovski/mini.comment', + version = '*', + dependencies = 'JoosepAlviste/nvim-ts-context-commentstring', + config = load_config('lang.comment'), + event = { 'BufReadPre', 'BufNewFile' }, + }, + { + 'echasnovski/mini.surround', + version = '*', + config = load_config('lang.surround'), + event = { 'BufReadPre', 'BufNewFile' }, + }, + { + 'echasnovski/mini.ai', + version = '*', + config = load_config('lang.ai'), + event = { 'BufReadPre', 'BufNewFile' }, + }, + { + 'alvan/vim-closetag', + ft = { "html", "javascriptreact", "typescriptreact" }, + }, + -- Tresitter + { + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', + dependencies = { + 'nvim-treesitter/nvim-treesitter-refactor', + 'nvim-treesitter/nvim-treesitter-textobjects', + 'RRethy/nvim-treesitter-endwise', + 'RRethy/nvim-treesitter-textsubjects', + 'windwp/nvim-ts-autotag', + }, + config = load_config('lang.treesitter'), + event = { 'BufReadPre', 'BufNewFile' }, + }, + { + 'ckolkey/ts-node-action', + dependencies = { 'nvim-treesitter' }, + }, + -- LSP + { + 'neovim/nvim-lspconfig', + dependencies = { + 'williamboman/mason-lspconfig.nvim', + 'hrsh7th/cmp-nvim-lsp', + }, + config = load_config('lang.lspconfig'), + event = { 'BufReadPre', 'BufNewFile' }, + }, + { + 'folke/lazydev.nvim', + ft = 'lua', + }, + { + 'nvimdev/lspsaga.nvim', + config = load_config('lang.lspsaga'), + event = 'LspAttach', + }, + { + 'Maan2003/lsp_lines.nvim', + config = load_config('lang.lsp-lines'), + event = 'LspAttach', + }, + { + 'williamboman/mason.nvim', + config = load_config('lang.mason'), + cmd = 'Mason', + }, + { + 'nvimtools/none-ls.nvim', + dependencies = { 'neovim/nvim-lspconfig', 'jay-babu/mason-null-ls.nvim' }, + config = load_config('lang.null-ls'), + event = { 'BufReadPre', 'BufNewFile' }, + }, + + -- Completion + { + 'hrsh7th/nvim-cmp', + dependencies = { + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-path', + 'hrsh7th/cmp-cmdline', + 'hrsh7th/cmp-nvim-lua', + 'L3MON4D3/LuaSnip', + 'rafamadriz/friendly-snippets', + 'saadparwaiz1/cmp_luasnip', + }, + config = load_config('lang.cmp'), + event = 'InsertEnter', + }, + { + 'Exafunction/codeium.vim', + event = 'BufEnter', + cmd = 'Codeium', + build = 'Codeium Auth:', + dependencies = { + 'nvim-lua/plenary.nvim', + 'hrsh7th/nvim-cmp', + }, + }, + -- Tools + { + 'sontungexpt/url-open', + cmd = 'URLOpenUnderCursor', + config = load_config('tools.url-open'), + }, + { + 'stevearc/conform.nvim', + event = { 'BufReadPre', 'BufNewFile' }, + config = load_config('tools.conform'), + }, + { + 'nvim-tree/nvim-tree.lua', + dependencies = { + 'nvim-tree/nvim-web-devicons', + }, + config = load_config('tools.nvim-tree'), + cmd = 'NvimTreeToggle', + }, + { + 'windwp/nvim-spectre', + config = load_config('tools.spectre'), + cmd = 'Spectre', + }, + { + 'abecodes/tabout.nvim', + config = load_config('tools.tabout'), + event = 'InsertEnter', + }, + { + 'folke/flash.nvim', + config = load_config('tools.flash'), + keys = { + { + 's', + mode = { 'n', 'x', 'o' }, + function() + require('flash').jump() + end, + desc = 'Flash', + }, + { + 'S', + mode = { 'n', 'x', 'o' }, + function() + require('flash').treesitter() + end, + desc = 'Flash Treesitter', + }, + }, + }, + { + 'numToStr/Navigator.nvim', + config = load_config('tools.navigator'), + event = function() + if vim.fn.exists('$TMUX') == 1 then + return 'VeryLazy' + end + end, + }, + { + 'm4xshen/hardtime.nvim', + dependencies = { 'MunifTanjim/nui.nvim', 'nvim-lua/plenary.nvim' }, + config = function() + require('hardtime').setup({ enabled = true }) + end, + cmd = 'Hardtime', + }, + { + 'chrisgrieser/nvim-spider', + config = load_config('tools.spider'), + event = { 'BufReadPre', 'BufNewFile' }, + }, + { + 'folke/which-key.nvim', + config = load_config('tools.which-key'), + event = 'VeryLazy', + }, + { + 'iamcco/markdown-preview.nvim', + build = function() + vim.fn['mkdp#util#install']() + end, + ft = 'markdown', + cmd = { 'MarkdownPreviewToggle', 'MarkdownPreview' }, + }, + { + 'uga-rosa/ccc.nvim', + config = load_config('tools.ccc'), + cmd = { 'CccHighlighterToggle', 'CccConvert', 'CccPick' }, + }, + { + '2kabhishek/termim.nvim', + cmd = { 'Fterm', 'FTerm', 'Sterm', 'STerm', 'Vterm', 'VTerm' }, + }, + { + '2kabhishek/tdo.nvim', + dependencies = 'nvim-telescope/telescope.nvim', + cmd = { 'Tdo', 'TdoEntry', 'TdoNote', 'TdoTodos', 'TdoToggle', 'TdoFind', 'TdoFiles' }, + keys = { '[t', ']t' }, + }, + { + 'kndndrj/nvim-dbee', + dependencies = { + 'MunifTanjim/nui.nvim', + }, + build = function() + -- "curl", "wget", "bitsadmin", "go" + require('dbee').install('curl') + end, + config = load_config('tools.dbee'), + cmd = 'DBToggle', + enabled = false, + }, + { + 'aurum77/live-server.nvim', + build = function() + require("live_server.util").install() + end, + cmd = { "LiveServer", "LiveServerStart", "LiveServerStop" }, + keys = { + { "", ft = "html", "LiveServer", desc = "Live Server" }, + { "", ft = "html", "LiveServerStop", desc = "Live Server Stop" }, + }, + }, + { + 'Zeioth/compiler.nvim', + cmd = { "CompilerOpen", "CompilerToggleResults", "CompilerRedo" }, + dependencies = { "stevearc/overseer.nvim" }, + opts = {}, + keys = { + { "", "CompilerOpen", desc = "Open Compiler" }, + { "", function() vim.cmd("CompilerStop") vim.cmd("CompilerRedo") end, desc = "Redo Compiler" }, + { "", "CompilerToggleResults", desc = "Toggle Compiler Results" }, + }, + }, + { + 'stevearc/overseer.nvim', + cmd = { + "OverseerOpen", + "OverseerClose", + "OverseerToggle", + "OverseerSaveBundle", + "OverseerLoadBundle", + "OverseerDeleteBundle", + "OverseerRunCmd", + "OverseerRun", + "OverseerInfo", + "OverseerBuild", + "OverseerQuickAction", + "OverseerTaskAction ", + "OverseerClearCache", + }, + opts = { + task_list = { + direction = "bottom", + min_height = 15, + max_height = 15, + default_detail = 1, + }, + }, + }, + { + 'okuuva/auto-save.nvim', + event = 'VeryLazy', + config = load_config('tools.auto-save'), + }, + -- Telescope + { + 'nvim-telescope/telescope.nvim', + branch = '0.1.x', + dependencies = { + 'nvim-lua/plenary.nvim', + { + 'nvim-telescope/telescope-fzf-native.nvim', + build = 'make', + }, + 'nvim-telescope/telescope-file-browser.nvim', + 'nvim-telescope/telescope-symbols.nvim', + 'molecule-man/telescope-menufacture', + 'debugloop/telescope-undo.nvim', + }, + config = load_config('tools.telescope'), + cmd = 'Telescope', + }, + { + 'ThePrimeagen/harpoon', + branch = 'harpoon2', + config = load_config('tools.harpoon'), + event = { 'BufReadPre', 'BufNewFile' }, + }, + { + '2kabhishek/nerdy.nvim', + dependencies = { 'stevearc/dressing.nvim' }, + cmd = 'Nerdy', + }, + { + -- 'chentoast/marks.nvim', + '2kabhishek/markit.nvim', + config = load_config('tools.marks'), + event = { 'BufReadPre', 'BufNewFile' }, + }, + + -- Git + { + '2kabhishek/co-author.nvim', + dependencies = { 'stevearc/dressing.nvim' }, + cmd = 'CoAuthor', + }, + { + 'ruifm/gitlinker.nvim', + config = load_config('tools.gitlinker'), + keys = 'yg', + }, + { + 'lewis6991/gitsigns.nvim', + config = load_config('tools.gitsigns'), + cmd = 'Gitsigns', + event = { 'BufReadPre', 'BufNewFile' }, + }, + { + 'tpope/vim-fugitive', + cmd = 'Git', + }, +} + +local ts_parsers = { + 'bash', + 'c', + 'css', + 'dart', + 'elixir', + 'gitcommit', + 'go', + 'html', + 'java', + 'javascript', + 'json', + 'kotlin', + 'lua', + 'markdown', + 'markdown_inline', -- markdown code blocks + 'python', + 'ruby', + 'rust', + 'typescript', + 'vim', + 'vimdoc', + 'yaml', +} + +local null_ls_sources = { + 'shellcheck', -- bash lint +} + +local lsp_servers = { + 'bashls', + 'jsonls', + 'lua_ls', + 'html', + 'kotlin_language_server', + 'sqlls', + 'typos_lsp', -- check typos + 'vimls', + 'volar', + 'yamlls', + 'tailwindcss', + 'cmake', + 'tsserver', + 'pylsp', +} + +local util = require('lib.util') + +if util.is_present('npm') then + table.insert(lsp_servers, 'eslint') + table.insert(lsp_servers, 'tsserver') +end + +if util.is_present('gem') then + local ror_nvim = { + 'weizheheng/ror.nvim', + branch = 'main', + ft = 'ruby', + config = load_config('lang.ror'), + keys = { + { + 'rc', + mode = { 'n' }, + function() + vim.cmd('RorCommands') + end, + desc = 'Rails Commands', + }, + }, + } + local vim_rails = { + 'tpope/vim-rails', + ft = 'ruby', + } + + table.insert(lsp_servers, 'solargraph') + table.insert(lsp_servers, 'ruby_lsp') + table.insert(lsp_servers, 'rubocop') + table.insert(plugins, ror_nvim) + table.insert(plugins, vim_rails) +end + +if util.is_present('dart') then + table.insert(lsp_servers, 'dartls') +end + +if util.is_present('java') then + table.insert(lsp_servers, 'jdtls') +end + +if util.is_present('pip') then + table.insert(lsp_servers, 'ruff_lsp') + table.insert(lsp_servers, 'pylsp') +end + +if util.is_present('mix') then + table.insert(lsp_servers, 'elixirls') +end + +if util.is_present('cargo') then + table.insert(lsp_servers, 'rust_analyzer') +end + +return { + plugins = plugins, + lsp_servers = lsp_servers, + null_ls_sources = null_ls_sources, + ts_parsers = ts_parsers, +} diff --git a/lua/plugins/lock.json b/lua/plugins/lock.json new file mode 100644 index 0000000..296d51c --- /dev/null +++ b/lua/plugins/lock.json @@ -0,0 +1,90 @@ +{ + "LuaSnip": { "branch": "master", "commit": "7552e6504ee95a9c8cfc6db53e389122ded46cd4" }, + "Navigator.nvim": { "branch": "master", "commit": "91d86506ac2a039504d5205d32a1d4bc7aa57072" }, + "auto-save.nvim": { "branch": "main", "commit": "5fe9ab0c42f0457f2a973e814a6352b8eeb04730" }, + "ccc.nvim": { "branch": "main", "commit": "4fb5abaef2f2e0540fe22d4d74a9841205fff9e4" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "co-author.nvim": { "branch": "main", "commit": "db0debbde453c0ce10d1b925cd9f3139e4291c42" }, + "codeium.vim": { "branch": "main", "commit": "e0342fde9474fdd0a36ff9692fe0031b7611a19f" }, + "compiler.nvim": { "branch": "main", "commit": "892c1aac059b7df16dc636eea9e34be53f53ff96" }, + "conform.nvim": { "branch": "master", "commit": "25d48271e3d4404ba017cb92a37d3a681c1ad149" }, + "dashboard-nvim": { "branch": "master", "commit": "fabf5feec96185817c732d47d363f34034212685" }, + "dressing.nvim": { "branch": "master", "commit": "6741f1062d3dc6e4755367a7e9b347b553623f04" }, + "flash.nvim": { "branch": "main", "commit": "34c7be146a91fec3555c33fe89c7d643f6ef5cf1" }, + "fortune.nvim": { "branch": "master", "commit": "29a99fbf887a2d48693f1eaa1893f84cde60af54" }, + "friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" }, + "gitlinker.nvim": { "branch": "master", "commit": "cc59f732f3d043b626c8702cb725c82e54d35c25" }, + "gitsigns.nvim": { "branch": "main", "commit": "58bd9e98d8e3c5a1c98af312e85247ee1afd3ed2" }, + "hardtime.nvim": { "branch": "main", "commit": "91c6be1a54fa057002e21ae209a49436bd215355" }, + "harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" }, + "indent-blankline.nvim": { "branch": "master", "commit": "3fe94b8034dd5241cb882bb73847303b58857ecf" }, + "lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" }, + "lazydev.nvim": { "branch": "main", "commit": "491452cf1ca6f029e90ad0d0368848fac717c6d2" }, + "live-server.nvim": { "branch": "main", "commit": "f6f00a3f541251f0320910bb0d03c4ae14ee6d10" }, + "lsp_lines.nvim": { "branch": "main", "commit": "dbfd8e96ec2696e1ceedcd23fd70e842256e3dea" }, + "lspsaga.nvim": { "branch": "main", "commit": "a751b92b5d765a99fe3a42b9e51c046f81385e15" }, + "lualine.nvim": { "branch": "master", "commit": "544dd1583f9bb27b393f598475c89809c4d5e86b" }, + "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, + "markit.nvim": { "branch": "main", "commit": "6a59bcc5140bed8fcf9cec2cba8d442072b1b76d" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "62360f061d45177dda8afc1b0fd1327328540301" }, + "mason-null-ls.nvim": { "branch": "main", "commit": "de19726de7260c68d94691afb057fa73d3cc53e7" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "mini.ai": { "branch": "main", "commit": "a7e90f110e6274262616311b93cef12cd2667a2d" }, + "mini.comment": { "branch": "main", "commit": "c8406379987c321ecdef9f53e1ca741a55002104" }, + "mini.surround": { "branch": "main", "commit": "3cb5b509ad34f2402df4b977be607a614c8c7524" }, + "neotest": { "branch": "master", "commit": "32ff2ac21135a372a42b38ae131e531e64833bd3" }, + "neotest-jest": { "branch": "main", "commit": "514fd4eae7da15fd409133086bb8e029b65ac43f" }, + "neotest-python": { "branch": "master", "commit": "2e83d2bc00acbcc1fd529dbf0a0e677cabfe6b50" }, + "neotest-rspec": { "branch": "main", "commit": "53fc108a06ae43d7f873d42ee5189c2301e33623" }, + "nerdy.nvim": { "branch": "main", "commit": "b467d6609b78d6a5f1e12cbc08fcc1ac87af20f5" }, + "noice.nvim": { "branch": "main", "commit": "448bb9c524a7601035449210838e374a30153172" }, + "none-ls.nvim": { "branch": "main", "commit": "cfa65d86e21eeb60544d5e823f6db43941322a53" }, + "nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" }, + "nvim-autopairs": { "branch": "master", "commit": "e38c5d837e755ce186ae51d2c48e1b387c4425c6" }, + "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" }, + "nvim-dap": { "branch": "master", "commit": "dcc85d12d6e2c18c5fa0f9a304d9f5e767e1401a" }, + "nvim-dap-ui": { "branch": "master", "commit": "a5606bc5958db86f8d92803bea7400ee26a8d7e4" }, + "nvim-lspconfig": { "branch": "master", "commit": "6c505d4220b521f3b0e7b645f6ce45fa914d0eed" }, + "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, + "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, + "nvim-spectre": { "branch": "master", "commit": "ba7fb777edff6c1fbbeffd343e113af64c04e90a" }, + "nvim-spider": { "branch": "main", "commit": "508b3504a350fb9a93bd0b7c0d41b8b5fc732b5e" }, + "nvim-tree.lua": { "branch": "master", "commit": "48d0e82f9434691cc50d970898142a8c084a49d6" }, + "nvim-treesitter": { "branch": "master", "commit": "1aad04ecde5ebf8f2b3eea5c6f39d38b251757f5" }, + "nvim-treesitter-endwise": { "branch": "master", "commit": "8b34305ffc28bd75a22f5a0a9928ee726a85c9a6" }, + "nvim-treesitter-refactor": { "branch": "master", "commit": "65ad2eca822dfaec2a3603119ec3cc8826a7859e" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "33a17515b79ddb10d750320fa994098bdc3e93ef" }, + "nvim-treesitter-textsubjects": { "branch": "master", "commit": "a8d2844bba925d9450ef7ab215f3b054028288ca" }, + "nvim-ts-autotag": { "branch": "main", "commit": "dc5e1687ab76ee02e0f11c5ce137f530b36e98b3" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "6b5f95aa4d24f2c629a74f2c935c702b08dbde62" }, + "nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" }, + "onedark.nvim": { "branch": "master", "commit": "fae34f7c635797f4bf62fb00e7d0516efa8abe37" }, + "overseer.nvim": { "branch": "master", "commit": "cbcdcbae3704c21d3ff96a1927d952b8a966b08a" }, + "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, + "rainbow-delimiters.nvim": { "branch": "master", "commit": "a727bd368e70808125b7cf589328cc595faf3d5a" }, + "refactoring.nvim": { "branch": "master", "commit": "c406fc5fb4d7ba5fce7b668637075fad6e75e9f8" }, + "ror.nvim": { "branch": "main", "commit": "9d31ad3953be83ac8dd542725ca4881c861f64a5" }, + "sniprun": { "branch": "master", "commit": "a29d7b1c313b00980015ad79fa0ab512a0729940" }, + "tabout.nvim": { "branch": "master", "commit": "923aea2613c9e7abf81e099d46086f62c7e54896" }, + "tdo.nvim": { "branch": "main", "commit": "f8d4ee275309c8a696236fcee92d78ecd98971bd" }, + "telescope-file-browser.nvim": { "branch": "master", "commit": "a46780830b576049c675680650f773bedfa8677a" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, + "telescope-menufacture": { "branch": "main", "commit": "8c547e82a703fe90c7f69af04d0b4e47a59cc971" }, + "telescope-symbols.nvim": { "branch": "master", "commit": "a6d0127a53d39b9fc2af75bd169d288166118aec" }, + "telescope-undo.nvim": { "branch": "main", "commit": "51be9ae7c42fc27c0b05505e3a0162e0f05fbb6a" }, + "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, + "termim.nvim": { "branch": "main", "commit": "58344167abb97bcef9bf720a762ea653a94e9daa" }, + "ts-node-action": { "branch": "master", "commit": "6d3b60754fd87963d70eadaa2f77873b447eac26" }, + "twilight.nvim": { "branch": "main", "commit": "1584c0b0a979b71fd86b18d302ba84e9aba85b1b" }, + "url-open": { "branch": "main", "commit": "9f8f4a56ac709f26aa17d8ef921b272bf2262a30" }, + "vim-closetag": { "branch": "master", "commit": "d0a562f8bdb107a50595aefe53b1a690460c3822" }, + "vim-fugitive": { "branch": "master", "commit": "0444df68cd1cdabc7453d6bd84099458327e5513" }, + "vim-rails": { "branch": "master", "commit": "2fba7907f585819a8653f0bc7dd7f437a822d9c6" }, + "which-key.nvim": { "branch": "main", "commit": "6c1584eb76b55629702716995cca4ae2798a9cca" }, + "zen-mode.nvim": { "branch": "main", "commit": "29b292bdc58b76a6c8f294c961a8bf92c5a6ebd6" } +} diff --git a/lua/plugins/tools/auto-save.lua b/lua/plugins/tools/auto-save.lua new file mode 100644 index 0000000..05e485e --- /dev/null +++ b/lua/plugins/tools/auto-save.lua @@ -0,0 +1,4 @@ +require("auto-save").setup({ + execution_message = { enabled = false }, + debounce_delay = 1000, +}) diff --git a/lua/plugins/tools/ccc.lua b/lua/plugins/tools/ccc.lua new file mode 100644 index 0000000..580a9d3 --- /dev/null +++ b/lua/plugins/tools/ccc.lua @@ -0,0 +1,10 @@ +vim.opt.termguicolors = true + +local ccc = require('ccc') + +ccc.setup({ + highlighter = { + auto_enable = true, + lsp = true, + }, +}) diff --git a/lua/plugins/tools/conform.lua b/lua/plugins/tools/conform.lua new file mode 100644 index 0000000..862c79a --- /dev/null +++ b/lua/plugins/tools/conform.lua @@ -0,0 +1,36 @@ +local conform = require('conform') + + conform.setup({ + formatters_by_ft = { + lua = { "stylua" }, + svelte = { { "prettierd", "prettier" } }, + javascript = { { "prettierd", "prettier" } }, + typescript = { { "prettierd", "prettier" } }, + javascriptreact = { { "prettierd", "prettier" } }, + typescriptreact = { { "prettierd", "prettier" } }, + json = { { "prettierd", "prettier" } }, + graphql = { { "prettierd", "prettier" } }, + java = { "google-java-format" }, + kotlin = { "ktlint" }, + ruby = { "standardrb" }, + markdown = { { "prettierd", "prettier" } }, + erb = { "htmlbeautifier" }, + html = { "htmlbeautifier" }, + bash = { "beautysh" }, + proto = { "buf" }, + rust = { "rustfmt" }, + yaml = { "yamlfix" }, + toml = { "taplo" }, + css = { { "prettierd", "prettier" } }, + scss = { { "prettierd", "prettier" } }, + sh = { { "shellcheck" } }, + }, + }) + + vim.keymap.set({ "n", "v" }, "l", function() + conform.format({ + lsp_fallback = true, + async = false, + timeout_ms = 1000, + }) + end, { desc = "Format file or range (in visual mode)" }) diff --git a/lua/plugins/tools/dbee.lua b/lua/plugins/tools/dbee.lua new file mode 100644 index 0000000..6b883e6 --- /dev/null +++ b/lua/plugins/tools/dbee.lua @@ -0,0 +1,19 @@ +local dbee = require('dbee') + +dbee.setup({ + sources = { + require('dbee.sources').EnvSource:new('NVIM_DB'), + -- require("dbee.sources").MemorySource:new({ + -- { + -- name = "dbname", + -- type = "postgres", + -- url = "postgres://pguser:pguser@localhost:5602/dbname?sslmode=disable" + -- }, + -- }), + -- require("dbee.sources").FileSource:new(vim.fn.stdpath("cache") .. "/dbee/config.json"), + }, +}) + +vim.api.nvim_create_user_command('DBToggle', function() + require('dbee').toggle() +end, {}) diff --git a/lua/plugins/tools/flash.lua b/lua/plugins/tools/flash.lua new file mode 100644 index 0000000..f7cffa4 --- /dev/null +++ b/lua/plugins/tools/flash.lua @@ -0,0 +1,57 @@ +local flash = require('flash') +local icons = require('lib.icons') + +flash.setup({ + -- exact, fuzzy, regex, custom function + mode = 'fuzzy', + -- behave like `incsearch` + incremental = true, + + jump = { + -- save location in the jumplist + jumplist = true, + -- automatically jump when there is only one match + autojump = true, + }, + label = { + rainbow = { + enabled = true, + -- number between 1 and 9 + shade = 4, + }, + }, + prompt = { + enabled = true, + prefix = { { icons.ui.Separator .. icons.ui.Rocket .. icons.ui.ChevronRight .. ' ', 'FlashPromptIcon' } }, + win_config = { relative = 'editor', width = 1, height = 1, row = 1, col = 0, zindex = 1000 }, + }, + modes = { + search = { + enabled = true, + }, + char = { + enabled = false, + jump_labels = false, + }, + }, +}) + +vim.api.nvim_create_user_command('FlashDiagnostics', function() + require('flash').jump({ + matcher = function(win) + return vim.tbl_map(function(diag) + return { + pos = { diag.lnum + 1, diag.col }, + end_pos = { diag.end_lnum + 1, diag.end_col - 1 }, + } + end, vim.diagnostic.get(vim.api.nvim_win_get_buf(win))) + end, + action = function(match, state) + vim.api.nvim_win_call(match.win, function() + vim.api.nvim_win_set_cursor(match.win, match.pos) + vim.diagnostic.open_float() + end) + state:restore() + end, + }) +end, {}) diff --git a/lua/plugins/tools/gitlinker.lua b/lua/plugins/tools/gitlinker.lua new file mode 100644 index 0000000..a16dbcd --- /dev/null +++ b/lua/plugins/tools/gitlinker.lua @@ -0,0 +1,24 @@ +local gitlinker = require('gitlinker') + +gitlinker.setup({ + opts = { + remote = nil, + add_current_line_on_normal_mode = true, + action_callback = require('gitlinker.actions').copy_to_clipboard, + print_url = true, + }, + callbacks = { + ['github.com'] = require('gitlinker.hosts').get_github_type_url, + ['gitlab.com'] = require('gitlinker.hosts').get_gitlab_type_url, + ['try.gitea.io'] = require('gitlinker.hosts').get_gitea_type_url, + ['codeberg.org'] = require('gitlinker.hosts').get_gitea_type_url, + ['bitbucket.org'] = require('gitlinker.hosts').get_bitbucket_type_url, + ['try.gogs.io'] = require('gitlinker.hosts').get_gogs_type_url, + ['git.sr.ht'] = require('gitlinker.hosts').get_srht_type_url, + ['git.launchpad.net'] = require('gitlinker.hosts').get_launchpad_type_url, + ['repo.or.cz'] = require('gitlinker.hosts').get_repoorcz_type_url, + ['git.kernel.org'] = require('gitlinker.hosts').get_cgit_type_url, + ['git.savannah.gnu.org'] = require('gitlinker.hosts').get_cgit_type_url, + }, + mappings = 'yg', +}) diff --git a/lua/plugins/tools/gitsigns.lua b/lua/plugins/tools/gitsigns.lua new file mode 100644 index 0000000..018a329 --- /dev/null +++ b/lua/plugins/tools/gitsigns.lua @@ -0,0 +1,63 @@ +local gitsigns = require('gitsigns') +local icons = require('lib.icons') + +gitsigns.setup({ + signs = { + add = { text = icons.ui.SeparatorLight }, + change = { text = icons.ui.SeparatorLight }, + delete = { text = icons.ui.SeparatorLight }, + topdelete = { text = icons.ui.Topline }, + changedelete = { text = icons.ui.SeparatorLight }, + untracked = { text = icons.ui.SeparatorDashed }, + }, + signcolumn = true, + numhl = false, + linehl = false, + word_diff = false, + watch_gitdir = { interval = 1000, follow_files = true }, + attach_to_untracked = true, + current_line_blame = false, + current_line_blame_opts = { + virt_text = true, + virt_text_pos = 'eol', + delay = 0, + ignore_whitespace = false, + }, + current_line_blame_formatter = ', - ', + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, + max_file_length = 40000, + preview_config = { border = 'rounded', style = 'minimal', relative = 'cursor', row = 0, col = 1 }, + on_attach = function(bufnr) + local gs = package.loaded.gitsigns + + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + map('n', ']c', function() + if vim.wo.diff then + return ']c' + end + vim.schedule(function() + gs.next_hunk() + end) + return '' + end, { expr = true, desc = 'Next Change' }) + + map('n', '[c', function() + if vim.wo.diff then + return '[c' + end + vim.schedule(function() + gs.prev_hunk() + end) + return '' + end, { expr = true, desc = 'Previous Change' }) + + map({ 'o', 'x' }, 'ih', ':Gitsigns select_hunk') + end, +}) diff --git a/lua/plugins/tools/harpoon.lua b/lua/plugins/tools/harpoon.lua new file mode 100644 index 0000000..975465e --- /dev/null +++ b/lua/plugins/tools/harpoon.lua @@ -0,0 +1,55 @@ +local harpoon = require('harpoon') +harpoon:setup({}) + +local conf = require('telescope.config').values +local function toggle_telescope(harpoon_files) + local file_paths = {} + for _, item in ipairs(harpoon_files.items) do + table.insert(file_paths, item.value) + end + + require('telescope.pickers') + .new({}, { + prompt_title = 'Harpoon', + finder = require('telescope.finders').new_table({ + results = file_paths, + }), + previewer = conf.file_previewer({}), + sorter = conf.generic_sorter({}), + }) + :find() +end + +vim.keymap.set('n', 'ha', function() + harpoon:list():append() +end, { desc = 'Add Mark' }) +vim.keymap.set('n', 'hh', function() + toggle_telescope(harpoon:list()) +end, { desc = 'Telescope Marks' }) +vim.keymap.set('n', 'hm', function() + harpoon.ui:toggle_quick_menu(harpoon:list()) +end, { desc = 'Open UI' }) +vim.keymap.set('n', 'hd', function() + harpoon:list():remove(selected_entry) +end, { desc = 'Delete Mark' } +) +vim.keymap.set('n', '[h', function() + harpoon:list():prev() +end, { desc = 'Prev Mark' }) +vim.keymap.set('n', ']h', function() + harpoon:list():next() +end, { desc = 'Next Mark' }) + +vim.keymap.set('n', 'hk', function() + harpoon:list():prev() +end, { desc = 'Prev Mark' }) +vim.keymap.set('n', 'hj', function() + harpoon:list():next() +end, { desc = 'Next Mark' }) + +for i = 1, 9 do + vim.keymap.set('n', 'h' .. i, function() + harpoon:list():select(i) + end, { desc = 'Mark ' .. i }) +end + diff --git a/lua/plugins/tools/marks.lua b/lua/plugins/tools/marks.lua new file mode 100644 index 0000000..04e3d3b --- /dev/null +++ b/lua/plugins/tools/marks.lua @@ -0,0 +1,37 @@ +local marks = require('marks') +local icons = require('lib.icons') + +marks.setup({ + default_mappings = true, + builtin_marks = { '.', '<', '>', '^' }, + cyclic = true, + force_write_shada = false, + sign_priority = { lower = 10, upper = 15, builtin = 8, bookmark = 20 }, + excluded_filetypes = {}, + excluded_buftypes = { 'nofile' }, + -- supports up to 10 bookmark groups + bookmark_1 = { + sign = icons.ui.Flag, + virt_text = 'flag', + annotate = false, + }, + bookmark_2 = { + sign = icons.ui.Eye, + virt_text = 'watch', + annotate = false, + }, + bookmark_3 = { + sign = icons.ui.Star, + virt_text = 'star', + annotate = false, + }, + bookmark_4 = { + sign = icons.ui.Bug, + virt_text = 'bug', + annotate = false, + }, + mappings = { + set = 'M', + toggle_mark = 'm', + }, +}) diff --git a/lua/plugins/tools/navigator.lua b/lua/plugins/tools/navigator.lua new file mode 100644 index 0000000..a16a9d7 --- /dev/null +++ b/lua/plugins/tools/navigator.lua @@ -0,0 +1,8 @@ +local navigator = require('Navigator') + +navigator.setup({ + auto_save = 'current', + disable_on_zoom = false, + mux = 'auto', +}) + diff --git a/lua/plugins/tools/nvim-tree.lua b/lua/plugins/tools/nvim-tree.lua new file mode 100644 index 0000000..5ffcf04 --- /dev/null +++ b/lua/plugins/tools/nvim-tree.lua @@ -0,0 +1,92 @@ +local nvim_tree = require('nvim-tree') + +local icons = require('lib.icons') + +local function on_attach(bufnr) + local api = require('nvim-tree.api') + + local function opts(desc) + return { + desc = 'nvim-tree: ' .. desc, + buffer = bufnr, + noremap = true, + silent = true, + nowait = true, + } + end + + api.config.mappings.default_on_attach(bufnr) + vim.keymap.set('n', 'Y', api.fs.copy.filename, opts('Copy Name')) + vim.keymap.set('n', 'y', api.fs.copy.relative_path, opts('Copy Relative Path')) + vim.keymap.set('n', 'l', api.node.open.edit, opts('Open')) + vim.keymap.set('n', '', api.node.open.edit, opts('Open')) + vim.keymap.set('n', 'h', api.node.navigate.parent_close, opts('Close Directory')) + vim.keymap.set('n', 'v', api.node.open.vertical, opts('Open: Vertical Split')) + vim.keymap.set('n', 'o', api.node.open.horizontal, opts('Open: Horizontal Split')) +end + +nvim_tree.setup({ + on_attach = on_attach, + hijack_directories = { enable = true }, + update_cwd = true, + filters = {}, + renderer = { + add_trailing = false, + group_empty = false, + highlight_git = false, + highlight_opened_files = 'none', + root_folder_modifier = ':t', + indent_markers = { + enable = false, + icons = { corner = icons.ui.Corner, edge = icons.ui.Edge, none = icons.ui.Edge }, + }, + icons = { + webdev_colors = true, + git_placement = 'before', + padding = ' ', + symlink_arrow = icons.ui.Arrow, + show = { file = true, folder = true, folder_arrow = true, git = true }, + glyphs = { + default = icons.documents.File, + symlink = icons.documents.SymLink, + folder = { + arrow_open = icons.ui.ArrowOpen, + arrow_closed = icons.ui.ArrowClosed, + default = icons.documents.Folder, + open = icons.documents.OpenFolder, + empty = icons.documents.FolderEmpty, + empty_open = icons.documents.OpenFolderEmpty, + symlink = icons.documents.SymlinkFolder, + symlink_open = icons.documents.SymlinkFolder, + }, + git = { + unstaged = icons.git.Mod, + staged = icons.git.Add, + unmerged = icons.git.Diff, + renamed = icons.git.Rename, + untracked = icons.git.Untrack, + deleted = icons.git.Remove, + ignored = icons.git.Ignore, + }, + }, + }, + }, + diagnostics = { + enable = true, + icons = { + hint = icons.diagnostics.Hint, + info = icons.diagnostics.Information, + warning = icons.diagnostics.Warning, + error = icons.diagnostics.Error, + }, + }, + update_focused_file = { enable = true, update_cwd = true, ignore_list = {} }, + git = { enable = true, ignore = true, timeout = 500 }, + view = { + width = 50, + side = 'left', + adaptive_size = false, + number = true, + relativenumber = true, + }, +}) diff --git a/lua/plugins/tools/spectre.lua b/lua/plugins/tools/spectre.lua new file mode 100644 index 0000000..6808f38 --- /dev/null +++ b/lua/plugins/tools/spectre.lua @@ -0,0 +1,125 @@ +local spectre = require('spectre') + +spectre.setup({ + color_devicons = true, + highlight = { + ui = 'String', + search = 'DiffChange', + replace = 'DiffDelete', + }, + mapping = { + ['toggle_line'] = { + map = 't', + cmd = "lua require('spectre').toggle_line()", + desc = 'toggle current item', + }, + ['enter_file'] = { + map = '', + cmd = "lua require('spectre.actions').select_entry()", + desc = 'goto current file', + }, + ['send_to_qf'] = { + map = 'Q', + cmd = "lua require('spectre.actions').send_to_qf()", + desc = 'send all item to quickfix', + }, + ['replace_cmd'] = { + map = 'c', + cmd = "lua require('spectre.actions').replace_cmd()", + desc = 'input replace vim command', + }, + ['show_option_menu'] = { + map = 'o', + cmd = "lua require('spectre').show_options()", + desc = 'show option', + }, + ['run_replace'] = { + map = 'R', + cmd = "lua require('spectre.actions').run_replace()", + desc = 'replace all', + }, + ['change_view_mode'] = { + map = 'm', + cmd = "lua require('spectre').change_view()", + desc = 'change result view mode', + }, + ['toggle_ignore_case'] = { + map = 'I', + cmd = "lua require('spectre').change_options('ignore-case')", + desc = 'toggle ignore case', + }, + ['toggle_ignore_hidden'] = { + map = 'H', + cmd = "lua require('spectre').change_options('hidden')", + desc = 'toggle search hidden', + }, + }, + find_engine = { + ['rg'] = { + cmd = 'rg', + args = { + '--color=never', + '--no-heading', + '--with-filename', + '--line-number', + '--column', + }, + options = { + ['ignore-case'] = { + value = '--ignore-case', + icon = '[I]', + desc = 'ignore case', + }, + ['hidden'] = { + value = '--hidden', + desc = 'hidden file', + icon = '[H]', + }, + }, + }, + ['ag'] = { + cmd = 'ag', + args = { + '--vimgrep', + '-s', + }, + options = { + ['ignore-case'] = { + value = '-i', + icon = '[I]', + desc = 'ignore case', + }, + ['hidden'] = { + value = '--hidden', + desc = 'hidden file', + icon = '[H]', + }, + }, + }, + }, + replace_engine = { + ['sed'] = { + cmd = 'sed', + args = nil, + }, + options = { + ['ignore-case'] = { + value = '--ignore-case', + icon = '[I]', + desc = 'ignore case', + }, + }, + }, + default = { + find = { + cmd = 'rg', + options = { 'ignore-case' }, + }, + replace = { + cmd = 'sed', + }, + }, + replace_vim_cmd = 'cdo', + is_open_target_win = true, + is_insert_mode = true, +}) diff --git a/lua/plugins/tools/spider.lua b/lua/plugins/tools/spider.lua new file mode 100644 index 0000000..5903072 --- /dev/null +++ b/lua/plugins/tools/spider.lua @@ -0,0 +1,10 @@ +local spider = require('spider') + +spider.setup({ + skipInsignificantPunctuation = true, +}) + +vim.keymap.set({ 'n', 'o', 'x' }, 'w', "lua require('spider').motion('w')", { desc = 'Spider-w' }) +vim.keymap.set({ 'n', 'o', 'x' }, 'e', "lua require('spider').motion('e')", { desc = 'Spider-e' }) +vim.keymap.set({ 'n', 'o', 'x' }, 'b', "lua require('spider').motion('b')", { desc = 'Spider-b' }) +vim.keymap.set({ 'n', 'o', 'x' }, 'ge', "lua require('spider').motion('ge')", { desc = 'Spider-ge' }) diff --git a/lua/plugins/tools/tabout.lua b/lua/plugins/tools/tabout.lua new file mode 100644 index 0000000..465c290 --- /dev/null +++ b/lua/plugins/tools/tabout.lua @@ -0,0 +1,22 @@ +local tabout = require('tabout') + +tabout.setup({ + tabkey = '', + backwards_tabkey = '', + act_as_tab = true, + act_as_shift_tab = true, + default_tab = '', + default_shift_tab = '', + enable_backwards = false, + completion = true, + tabouts = { + { open = "'", close = "'" }, + { open = '"', close = '"' }, + { open = '`', close = '`' }, + { open = '(', close = ')' }, + { open = '[', close = ']' }, + { open = '{', close = '}' }, + }, + ignore_beginning = true, + exclude = { 'markdown' }, +}) diff --git a/lua/plugins/tools/telescope-multiopen.lua b/lua/plugins/tools/telescope-multiopen.lua new file mode 100644 index 0000000..44d2a13 --- /dev/null +++ b/lua/plugins/tools/telescope-multiopen.lua @@ -0,0 +1,67 @@ +local actions = require('telescope.actions') +local action_state = require('telescope.actions.state') +local transform_mod = require('telescope.actions.mt').transform_mod + +local function multiopen(prompt_bufnr, method) + local cmd_map = { + vertical = 'vsplit', + horizontal = 'split', + tab = 'tabe', + default = 'edit', + } + local picker = action_state.get_current_picker(prompt_bufnr) + local multi_selection = picker:get_multi_selection() + + if #multi_selection > 0 then + require('telescope.pickers').on_close_prompt(prompt_bufnr) + pcall(vim.api.nvim_set_current_win, picker.original_win_id) + + for i, entry in ipairs(multi_selection) do + local cmd = i == 1 and 'edit' or cmd_map[method] + vim.cmd(string.format('%s %s', cmd, entry.value)) + end + else + actions['select_' .. method](prompt_bufnr) + end +end + +local custom_actions = transform_mod({ + multi_selection_open_vertical = function(prompt_bufnr) + multiopen(prompt_bufnr, 'vertical') + end, + multi_selection_open_horizontal = function(prompt_bufnr) + multiopen(prompt_bufnr, 'horizontal') + end, + multi_selection_open_tab = function(prompt_bufnr) + multiopen(prompt_bufnr, 'tab') + end, + multi_selection_open = function(prompt_bufnr) + multiopen(prompt_bufnr, 'default') + end, +}) + +local function stopinsert(callback) + return function(prompt_bufnr) + vim.cmd.stopinsert() + vim.schedule(function() + callback(prompt_bufnr) + end) + end +end + +local multi_open_mappings = { + i = { + [''] = stopinsert(custom_actions.multi_selection_open_vertical), + [''] = stopinsert(custom_actions.multi_selection_open_horizontal), + [''] = stopinsert(custom_actions.multi_selection_open_tab), + [''] = stopinsert(custom_actions.multi_selection_open), + }, + n = { + [''] = custom_actions.multi_selection_open_vertical, + [''] = custom_actions.multi_selection_open_horizontal, + [''] = custom_actions.multi_selection_open_tab, + [''] = custom_actions.multi_selection_open, + }, +} + +return multi_open_mappings diff --git a/lua/plugins/tools/telescope.lua b/lua/plugins/tools/telescope.lua new file mode 100644 index 0000000..137b8e2 --- /dev/null +++ b/lua/plugins/tools/telescope.lua @@ -0,0 +1,170 @@ +local telescope = require('telescope') +local actions = require('telescope.actions') +local icons = require('lib.icons') + +local function flash(prompt_bufnr) + require('flash').jump({ + pattern = '^', + label = { after = { 0, 0 } }, + search = { + mode = 'search', + exclude = { + function(win) + return vim.bo[vim.api.nvim_win_get_buf(win)].filetype ~= 'TelescopeResults' + end, + }, + }, + action = function(match) + local picker = require('telescope.actions.state').get_current_picker(prompt_bufnr) + picker:set_selection(match.pos[1] - 1) + end, + }) +end + +telescope.setup({ + defaults = { + layout_config = { + height = 0.8, + width = 0.9, + prompt_position = 'top', + bottom_pane = { + height = 0.5, + preview_width = 0.6, + preview_cutoff = 120, + }, + center = { + height = 0.4, + preview_cutoff = 40, + }, + cursor = { + preview_cutoff = 40, + preview_width = 0.6, + }, + horizontal = { + preview_width = 0.6, + preview_cutoff = 120, + }, + vertical = { + preview_cutoff = 40, + }, + }, + prompt_prefix = icons.ui.Telescope .. icons.ui.ChevronRight, + selection_caret = icons.ui.Play, + multi_icon = icons.ui.Check, + path_display = { 'smart' }, + -- path_display = { filename_first = { reverse_directories = false } }, + sorting_strategy = 'ascending', + + mappings = { + i = { + [''] = actions.close, + [''] = actions.cycle_history_next, + [''] = actions.cycle_history_prev, + + [''] = actions.move_selection_next, + [''] = actions.move_selection_previous, + + [''] = actions.close, + + [''] = actions.move_selection_next, + [''] = actions.move_selection_previous, + + [''] = actions.select_default, + [''] = actions.select_horizontal, + [''] = actions.select_vertical, + [''] = actions.select_horizontal, + [''] = actions.select_vertical, + [''] = actions.select_tab, + [''] = flash, + + [''] = actions.preview_scrolling_up, + [''] = actions.preview_scrolling_down, + + [''] = actions.results_scrolling_up, + [''] = actions.results_scrolling_down, + + [''] = actions.toggle_selection + actions.move_selection_worse, + [''] = actions.toggle_selection + actions.move_selection_better, + [''] = actions.send_to_qflist + actions.open_qflist, + [''] = actions.send_selected_to_qflist + actions.open_qflist, + [''] = actions.complete_tag, + }, + + n = { + ['q'] = actions.close, + [''] = actions.close, + [''] = actions.select_default, + [''] = actions.select_horizontal, + [''] = actions.select_vertical, + [''] = actions.select_tab, + ['s'] = flash, + + [''] = actions.toggle_selection + actions.move_selection_worse, + [''] = actions.toggle_selection + actions.move_selection_better, + [''] = actions.send_to_qflist + actions.open_qflist, + [''] = actions.send_selected_to_qflist + actions.open_qflist, + + ['j'] = actions.move_selection_next, + ['k'] = actions.move_selection_previous, + ['H'] = actions.move_to_top, + ['M'] = actions.move_to_middle, + ['L'] = actions.move_to_bottom, + + [''] = actions.move_selection_next, + [''] = actions.move_selection_previous, + ['gg'] = actions.move_to_top, + ['G'] = actions.move_to_bottom, + + [''] = actions.preview_scrolling_up, + [''] = actions.preview_scrolling_down, + + [''] = actions.results_scrolling_up, + [''] = actions.results_scrolling_down, + + ['?'] = actions.which_key, + }, + }, + }, + extensions = { + fzf = { + fuzzy = true, + override_generic_sorter = true, + override_file_sorter = true, + case_mode = 'smart_case', + }, + undo = { + use_delta = true, + use_custom_command = nil, + side_by_side = true, + vim_diff_opts = { + ctxlen = vim.o.scrolloff * 2, + }, + entry_format = 'state #$ID, $STAT, $TIME', + -- time_format = '%d %b %H:%M', + saved_only = false, + layout_strategy = 'vertical', + layout_config = { + preview_height = 0.7, + }, + mappings = { + i = { + [''] = require('telescope-undo.actions').yank_additions, + [''] = require('telescope-undo.actions').yank_deletions, + [''] = require('telescope-undo.actions').restore, + }, + }, + }, + menufacture = { mappings = { main_menu = { [{ 'i', 'n' }] = '' } } }, + }, +}) + +require('telescope').load_extension('fzf') +require('telescope').load_extension('menufacture') +require('telescope').load_extension('undo') +telescope.load_extension('marks_nvim') +require('telescope').load_extension('harpoon') +require('telescope').load_extension('notify') +require('telescope').load_extension('noice') +require('telescope').load_extension('refactoring') +require('telescope').load_extension('file_browser') + diff --git a/lua/plugins/tools/url-open.lua b/lua/plugins/tools/url-open.lua new file mode 100644 index 0000000..541a650 --- /dev/null +++ b/lua/plugins/tools/url-open.lua @@ -0,0 +1,23 @@ +require("url-open").setup({ + -- default will open url with default browser of your system or you can choose your browser like this + -- open_app = "micorsoft-edge-stable", + -- google-chrome, firefox, micorsoft-edge-stable, opera, brave, vivaldi + open_app = "default", + open_only_when_cursor_on_url = true, + highlight_url = { + all_urls = { + enabled = true, + fg = "#21d5ff", -- nil will use default color + bg = nil, -- transparent + underline = true, + }, + cursor_move = { + enabled = true, + fg = "#199eff", -- nil will use default color + bg = nil, -- transparent + underline = true, + }, + }, + deep_pattern = false, + extra_patterns = { }, +}) diff --git a/lua/plugins/tools/which-key.lua b/lua/plugins/tools/which-key.lua new file mode 100644 index 0000000..4fffcc9 --- /dev/null +++ b/lua/plugins/tools/which-key.lua @@ -0,0 +1,522 @@ +local which_key = require('which-key') +local icons = require('lib.icons') + +local setup = { + preset = 'modern', + plugins = { + marks = true, + registers = true, + spelling = { + enabled = true, + suggestions = 30, + }, + presets = { + operators = true, + motions = true, + text_objects = true, + windows = true, + nav = true, + z = true, + g = true, + }, + }, + icons = { + breadcrumb = icons.ui.ArrowOpen, + separator = icons.ui.Arrow, + group = '', + keys = { + Space = icons.ui.Rocket, + }, + rules = false, -- enable auto icon rules + }, + win = { + no_overlap = true, + border = 'rounded', + width = 0.8, + height = { min = 5, max = 25 }, + padding = { 1, 2 }, + title = true, + title_pos = 'center', + zindex = 1000, + wo = { + winblend = 10, + }, + }, + layout = { + width = { min = 20 }, + spacing = 6, + align = 'center', + }, + show_help = false, + show_keys = true, + triggers = { + { '', mode = 'nixsotc' }, + { '', mode = { 'n', 'v' } }, + }, +} + +local n_mappings = { + mode = 'n', + { 'b', group = '๏†ˆ Debug' }, + { 'bO', 'DapStepOut', desc = 'Out' }, + { 'bR', 'DapRestartFrame', desc = 'Restart Frame' }, + { 'bb', 'DapToggleBreakpoint', desc = 'Breakpoint' }, + { 'bc', 'DapContinue', desc = 'Continue' }, + { 'bi', 'DapStepInto', desc = 'Into' }, + { 'bl', "lua require'dap'.run_last()", desc = 'Last' }, + { 'bo', 'DapStepOver', desc = 'Over' }, + { 'br', 'DapToggleRepl', desc = 'Repl' }, + { 'bt', 'DapUIToggle', desc = 'Debugger' }, + { 'bx', 'DapTerminate', desc = 'Exit' }, + + { 'c', group = '๏ฏ Code' }, + { 'cF', 'retab', desc = 'Fix Tabs' }, + { 'cP', 'CccConvert', desc = 'Convert Color' }, + { 'cR', 'ReloadConfig', desc = 'Reload Configs' }, + { 'cc', 'CccHighlighterToggle', desc = 'Highlight Colors' }, + { 'cd', 'RootDir', desc = 'Root Directory' }, + { 'cf', 'lua vim.lsp.buf.format({async = true})', desc = 'Format File' }, + { 'ch', 'Hardtime toggle', desc = 'Hardtime' }, + { 'cl', ':g/^\\s*$/d', desc = 'Clean Empty Lines' }, + { 'cm', 'MarkdownPreviewToggle', desc = 'Markdown Preview' }, + { 'cn', 'Telescope notify', desc = 'Notifications' }, + { 'co', 'Dashboard', desc = 'Dashboard' }, + { 'cp', 'CccPick', desc = 'Pick Color' }, + { 'cr', 'Telescope reloader', desc = 'Reload Module' }, + { 'cx', '%SnipRun', desc = 'Run File' }, + + { 'd', group = '๏‡€ Database' }, + { 'dS', 'lua require("dbee").store("json", "buffer", { extra_arg = 0 })', desc = 'To JSON' }, + { 'db', 'DBToggle', desc = 'DB Explorer' }, + { 'dj', 'lua require("dbee").next()', desc = 'DB Next' }, + { 'dk', 'lua require("dbee").prev()', desc = 'DB Prev' }, + { 'ds', 'lua require("dbee").store("csv", "buffer", { extra_arg = 0 })', desc = 'To CSV' }, + { 'dt', 'lua require("dbee").store("table", "buffer", { extra_arg = 0 })', desc = 'To Table' }, + + { 'e', group = '๏€ Edit' }, + { 'ea', 'b#', desc = 'Alternate File' }, + { 'ec', 'e $MYVIMRC', desc = 'Config' }, + { + 'ed', + 'lua require("telescope.builtin").find_files({cwd = vim.fn.stdpath("config")})', + desc = 'Config Dir', + }, + { 'ee', 'NvimTreeToggle', desc = 'Explorer' }, + { 'ef', 'gf', desc = 'File Under Cursor' }, + { 'el', 'e ~/.config/shell/local.sh', desc = 'Local Config' }, + { 'em', 'e README.md', desc = 'Readme' }, + { 'en', 'enew', desc = 'New File' }, + { 'ez', 'e $ZDOTDIR/.zshrc', desc = 'Zsh Config' }, + + { 'f', group = '๏‘ซ Find' }, + { 'fa', 'lua require("telescope").extensions.menufacture.find_files()', desc = 'All Files' }, + { 'fb', 'Telescope buffers', desc = 'Buffers' }, + { 'fc', 'Telescope git_bcommits', desc = 'File Commits' }, + { 'ff', 'lua require("telescope").extensions.menufacture.git_files()', desc = 'Find files' }, + { 'fg', 'lua require("telescope").extensions.menufacture.live_grep()', desc = 'Find Text' }, + { 'fl', 'Telescope loclist', desc = 'Location List' }, + { 'fm', 'Telescope git_status', desc = 'Modified files' }, + { 'fo', 'Telescope live_grep grep_open_files=true', desc = 'Find in Open Files' }, + { 'fp', 'Telescope resume', desc = 'Last Search' }, + { 'fq', 'Telescope quickfix', desc = 'Quickfix' }, + { 'fr', 'Telescope oldfiles', desc = 'Recent Files' }, + { 'fs', 'Telescope current_buffer_fuzzy_find', desc = 'Fuzzy Find in File' }, + { 'ft', 'Telescope', desc = 'Panel' }, + { 'fu', 'Telescope undo', desc = 'Undo History' }, + { 'fw', 'lua require("telescope").extensions.menufacture.grep_string()', desc = 'Find Word' }, + + { 'g', group = '๏„“ Git' }, + { 'gA', 'Gitsigns stage_buffer', desc = 'Stage Buffer' }, + { 'gC', 'CoAuthor', desc = 'Co-Authors' }, + { 'gP', 'Git push', desc = 'Push' }, + { 'gR', 'Gitsigns reset_buffer', desc = 'Reset Buffer' }, + { 'gS', 'Telescope git_stash', desc = 'Stashed Changes' }, + { 'ga', 'Gitsigns stage_hunk', desc = 'Stage Hunk' }, + { 'gb', "lua require('gitsigns').blame_line({full = true})", desc = 'Blame' }, + { 'gc', 'Telescope git_commits', desc = 'Find Commits' }, + { 'gd', 'Gitsigns diffthis HEAD', desc = 'Diff' }, + { 'gf', 'Git', desc = 'Fugitive Panel' }, + { 'gg', 'Fterm lazygit', desc = 'Lazygit' }, + { 'gi', 'Gitsigns preview_hunk', desc = 'Hunk Info' }, + { 'gj', 'Gitsigns next_hunk', desc = 'Next Hunk' }, + { 'gk', 'Gitsigns prev_hunk', desc = 'Prev Hunk' }, + { 'gl', 'Git log', desc = 'Log' }, + { 'gp', 'Git pull', desc = 'Pull' }, + { 'gr', 'Gitsigns reset_hunk', desc = 'Reset Hunk' }, + { 'gs', 'Telescope git_branches', desc = 'Switch Branch' }, + { 'gt', group = 'Toggle' }, + { 'gtb', 'Gitsigns toggle_current_line_blame', desc = 'Blame' }, + { 'gtd', 'Gitsigns toggle_deleted', desc = 'Deleted' }, + { 'gtl', 'Gitsigns toggle_linehl', desc = 'Line HL' }, + { 'gtn', 'Gitsigns toggle_numhl', desc = 'Number HL' }, + { 'gts', 'Gitsigns toggle_signs', desc = 'Signs' }, + { 'gtw', 'Gitsigns toggle_word_diff', desc = 'Word Diff' }, + { 'gu', 'Gitsigns undo_stage_hunk', desc = 'Undo Stage Hunk' }, + { 'gv', 'Gitsigns select_hunk', desc = 'Select Hunk' }, + + { 'h', group = '๏„จ Help' }, + { 'hh', 'Telescope help_tags', desc = 'Help Pages' }, + { 'hi', 'vim.show_pos', desc = 'Inspect Position' }, + { 'hk', 'Lspsaga hover_doc', desc = 'Hover Doc' }, + { 'hm', 'Telescope man_pages', desc = 'Man Pages' }, + + { 'i', group = '๏‰ Insert' }, + { 'iP', 'put %:p', desc = 'Absolute Path' }, + { 'id', "put =strftime('## %a, %d %b, %Y, %r')", desc = 'Date' }, + { 'ie', 'Telescope symbols', desc = 'Emojis' }, + { 'if', "put =expand('%:t')", desc = 'File Name' }, + { 'in', 'Nerdy', desc = 'Nerd Glyphs' }, + { 'ip', 'put %', desc = 'Relative Path' }, + { 'ir', 'Telescope registers', desc = 'Registers' }, + { 'it', "put =strftime('## %r')", desc = 'Time' }, + + { 'j', group = '๏“ฒ Jump' }, + { + 'jN', + "lua require('flash').jump({search = { forward = false, wrap = false, multi_window = false },})", + desc = 'Search Backward', + }, + { 'jc', '*', desc = 'Word' }, + { 'jd', 'FlashDiagnostics', desc = 'Diagnostics' }, + { 'jf', 'Telescope jumplist', desc = 'Jumplist' }, + { 'jh', '', desc = 'Backward' }, + { 'jj', "lua require('flash').remote()", desc = 'Remote' }, + { 'jk', "lua require('flash').treesitter()", desc = 'Treesitter' }, + { 'jl', '', desc = 'Forward' }, + { + 'jn', + "lua require('flash').jump({search = { forward = true, wrap = false, multi_window = false },})", + desc = 'Search Forward', + }, + { 'jp', "lua require('flash').jump({continue = true})", desc = 'Previous Jump' }, + { 'js', "lua require('flash').jump()", desc = 'Search' }, + { 'jt', "lua require('flash').treesitter_search()", desc = 'Remote Treesitter' }, + { + 'jw', + 'lua require("flash").jump({ pattern = vim.fn.expand("")})', + desc = 'Current Word', + }, + + { 'k', group = '๏„œ Keys' }, + { 'kc', 'Telescope commands', desc = 'Commands' }, + { 'kh', 'Telescope command_history', desc = 'Command History' }, + { 'kk', 'Telescope keymaps', desc = 'Keymaps' }, + { 'ks', 'Telescope search_history', desc = 'Search History' }, + + { 'l', group = '๏‡‹ LSP' }, + { 'lF', 'Telescope lsp_references layout_strategy=vertical', desc = 'References' }, + { 'lL', 'Lspsaga show_workspace_diagnostics', desc = 'Workspace Diagnostics' }, + { 'lP', 'Telescope lsp_outgoing_calls', desc = 'Outgoing Calls' }, + { 'lQ', 'LspRestart', desc = 'Restart LSP' }, + { 'lR', 'Lspsaga project_replace', desc = 'Replace' }, + { 'lS', 'Telescope lsp_dynamic_workspace_symbols', desc = 'Workspace Symbols' }, + { 'lT', 'Lspsaga goto_type_definition', desc = 'Goto Type Definition' }, + { 'la', 'Lspsaga code_action', desc = 'Code Action' }, + { 'ld', 'Lspsaga peek_definition', desc = 'Peek Definition' }, + { 'lf', 'Lspsaga finder', desc = 'Finder' }, + { 'lg', 'Lspsaga goto_definition', desc = 'Goto Definition' }, + { 'lh', 'Lspsaga hover_doc', desc = 'Hover' }, + { 'li', 'LspInfo', desc = 'LSP Info' }, + { 'lj', 'Lspsaga diagnostic_jump_next', desc = 'Next Diagnostic' }, + { 'lk', 'Lspsaga diagnostic_jump_prev', desc = 'Prev Diagnostic' }, + { 'll', 'Telescope diagnostics layout_strategy=vertical', desc = 'File Diagnostics' }, + { 'lo', 'Lspsaga outline', desc = 'Outline' }, + { 'lp', 'Telescope lsp_incoming_calls', desc = 'Incoming Calls' }, + { 'lq', 'LspStop', desc = 'Stop LSP' }, + { 'lr', 'Lspsaga rename', desc = 'Rename' }, + { 'ls', 'Telescope lsp_document_symbols theme=get_ivy', desc = 'Document Symbols' }, + { 'lt', 'Lspsaga peek_type_definition', desc = 'Peek Type Definition' }, + + { 'm', group = '๏€ฎ Marks' }, + { 'm1', "lua require('marks').toggle_bookmark1()", desc = 'Toggle Bookmark 0' }, + { 'm2', "lua require('marks').toggle_bookmark2()", desc = 'Toggle Bookmark 2' }, + { 'm3', "lua require('marks').toggle_bookmark3()", desc = 'Toggle Bookmark 3' }, + { 'm4', "lua require('marks').toggle_bookmark4()", desc = 'Toggle Bookmark 4' }, + { 'mD', "lua require('marks').delete_buf()", desc = 'Delete Buffer' }, + { 'mP', "lua require('marks').preview()", desc = 'Preview' }, + { + 'mb', + "lua require('telescope').extensions.marks_nvim.bookmarks_list_all()", + desc = 'Bookmarks', + }, + { 'md', "lua require('marks').delete_line()", desc = 'Delete Line' }, + { 'mh', "lua require('marks').next_bookmark()", desc = 'Next Bookmark' }, + { 'mj', "lua require('marks').next()", desc = 'Next' }, + { 'mk', "lua require('marks').prev()", desc = 'Previous' }, + { 'ml', "lua require('marks').prev_bookmark()", desc = 'Previous Bookmark' }, + { 'mm', 'Telescope marks', desc = 'All Marks' }, + { 'mn', group = 'Next Bookmark Group' }, + { 'mn1', "lua require('marks').next_bookmark1()", desc = 'Next Bookmark 1' }, + { 'mn2', "lua require('marks').next_bookmark2()", desc = 'Next Bookmark 2' }, + { 'mn3', "lua require('marks').next_bookmark3()", desc = 'Next Bookmark 3' }, + { 'mn4', "lua require('marks').next_bookmark4()", desc = 'Next Bookmark 4' }, + { 'mp', group = 'Previous Bookmark Group' }, + { 'mp1', "lua require('marks').prev_bookmark1()", desc = 'Previous Bookmark 1' }, + { 'mp2', "lua require('marks').prev_bookmark2()", desc = 'Previous Bookmark 2' }, + { 'mp3', "lua require('marks').prev_bookmark3()", desc = 'Previous Bookmark 3' }, + { 'mp4', "lua require('marks').prev_bookmark4()", desc = 'Previous Bookmark 4' }, + { 'ms', "lua require('marks').set_next()", desc = 'Set Next' }, + { 'mt', "lua require('marks').toggle()", desc = 'Toggle' }, + { 'mx', "lua require('marks').delete_bookmark()", desc = 'Delete Bookmark' }, + + { 'n', group = '๏‰‰ Notes' }, + { 'nd', 'Tdo', desc = "Today's Todo" }, + { 'ne', 'TdoEntry', desc = "Today's Entry" }, + { 'nf', 'TdoFiles', desc = 'All Notes' }, + { 'ng', 'TdoFind', desc = 'Find Notes' }, + { 'nh', 'Tdo -1', desc = "Yesterday's Todo" }, + { 'nl', 'Tdo 1', desc = "Tomorrow's Todo" }, + { 'nn', 'TdoNote', desc = 'New Note' }, + { + 'ns', + 'lua require("tdo").run_with("commit " .. vim.fn.expand("%:p")) vim.notify("Committed!")', + desc = 'Commit Note', + }, + { 'nt', 'TdoTodos', desc = 'Incomplete Todos' }, + { 'nx', 'TdoToggle', desc = 'Toggle Todo' }, + + { 'o', group = '๏ฃ Options' }, + { 'oc', 'Telescope colorscheme', desc = 'Colorscheme' }, + { 'oh', 'Telescope highlights', desc = 'Highlight Colors' }, + { 'on', 'set relativenumber!', desc = 'Relative Numbers' }, + { 'oo', 'Telescope vim_options', desc = 'All Options' }, + + { 'p', group = '๏†ฒ Packages' }, + { 'pP', 'Lazy profile', desc = 'Profile' }, + { 'pc', 'Lazy check', desc = 'Check' }, + { 'pd', 'Lazy debug', desc = 'Debug' }, + { 'pi', 'Lazy install', desc = 'Install' }, + { 'pl', 'Lazy log', desc = 'Log' }, + { 'pm', 'Mason', desc = 'Mason' }, + { 'pp', 'Lazy', desc = 'Plugins' }, + { 'pr', 'Lazy restore', desc = 'Restore' }, + { 'ps', 'Lazy sync', desc = 'Sync' }, + { 'pu', 'Lazy update', desc = 'Update' }, + { 'px', 'Lazy clean', desc = 'Clean' }, + + { 'q', group = '๏€ Quit' }, + { 'qa', 'qall', desc = 'Quit All' }, + { 'qb', 'bw', desc = 'Close Buffer' }, + { 'qd', 'bdelete', desc = 'Delete Buffer' }, + { 'qf', 'qall!', desc = 'Force Quit' }, + { 'qq', 'q', desc = 'Quit' }, + { 'qs', 'c', desc = 'Close Split' }, + { 'qw', 'wq', desc = 'Write and Quit' }, + + { 'r', group = '๏„ก Refactor' }, + { + 'rR', + "lua require('telescope').extensions.refactoring.refactors()", + desc = 'Refactor Commands', + }, + { 'rS', "lua require('spectre').open()", desc = 'Replace' }, + { 'rb', "lua require('spectre').open_file_search()", desc = 'Replace Buffer' }, + { 'rd', '', desc = 'Go To Definition' }, + { 're', "lua require('refactoring').refactor('Extract Block')", desc = 'Extract Block' }, + { + 'rf', + "lua require('refactoring').refactor('Extract Block To File')", + desc = 'Extract To File', + }, + { 'rh', '', desc = 'List Definition Head' }, + { 'ri', "lua require('refactoring').refactor('Inline Variable')", desc = 'Inline Variable' }, + { 'rj', '', desc = 'Next Usage' }, + { 'rk', '', desc = 'Previous Usage' }, + { 'rl', '', desc = 'List Definition' }, + { 'rn', '', desc = 'Swap Next' }, + { 'rp', '', desc = 'Swap Previous' }, + { 'rr', '', desc = 'Smart Rename' }, + { 'rs', ':%s/\\<\\>//gI', desc = 'Replace Word' }, + { 'rv', "lua require('refactoring').refactor('Extract Variable')", desc = 'Extract Variable' }, + { 'rw', "lua require('spectre').open_visual({select_word=true})", desc = 'Replace Word' }, + + { 's', group = '๏…บ Split' }, + { 's+', 'resize +10', desc = 'Increase window height' }, + { 's-', 'vertical resize -20', desc = 'Decrease window width' }, + { 's/', 's', desc = 'Split Below' }, + { 's=', 'vertical resize +20', desc = 'Increase window width' }, + { 'sH', 'vertical resize -10', desc = 'Decrease window width' }, + { 'sJ', 'resize -5', desc = 'Decrease window height' }, + { 'sK', 'resize +5', desc = 'Increase window height' }, + { 'sL', 'vertical resize +10', desc = 'Increase window width' }, + { 's\\', 'v', desc = 'Split Right' }, + { 's_', 'resize -10', desc = 'Decrease window height' }, + { 's`', 'p', desc = 'Previous Window' }, + { 'sa', 'split', desc = 'Horizontal Split' }, + { 'sc', 'tabclose', desc = 'Close Tab' }, + { 'sf', 'tabfirst', desc = 'First Tab' }, + { 'sh', 'h', desc = 'Move Left' }, + { 'sj', 'j', desc = 'Move Down' }, + { 'sk', 'k', desc = 'Move Up' }, + { 'sl', 'l', desc = 'Move Right' }, + { 'sp', 'NavigatorPrevious', desc = 'Previous Pane' }, + { 'sq', 'c', desc = 'Close Split' }, + { 'ss', 'vsplit', desc = 'Vertical Split' }, + + { 't', group = '๏’‰ Terminal' }, + { 't`', 'Sterm', desc = 'Horizontal Terminal' }, + { 'tc', 'Sterm bundle exec rails console', desc = 'Rails Console' }, + { 'td', 'Sterm dexe', desc = 'Exe Launcher' }, + { 'tn', 'Sterm node', desc = 'Node' }, + { 'tp', 'Sterm bpython', desc = 'Python' }, + { 'tr', 'Sterm irb', desc = 'Ruby' }, + { 'ts', 'Sterm', desc = 'Horizontal Terminal' }, + { 'tt', 'Fterm', desc = 'Terminal' }, + { 'tv', 'Vterm', desc = 'Vertical Terminal' }, + { 'tw', 'Sterm dexe --wait-before-exit', desc = 'Exe Launcher, Wait' }, + + { 'u', group = '๏ƒƒ Test' }, + { 'uc', 'lua require("neotest").run.run()', desc = 'Run Current Test' }, + { 'uf', 'lua require("neotest").run.run(vim.fn.expand("%"))', desc = 'Run Test File' }, + { 'uo', 'Neotest output-panel', desc = 'Test Output' }, + { 'us', 'Neotest summary', desc = 'Test Summary' }, + + { 'v', group = '๏€… Select' }, + { 'vB', 'vab', desc = 'Around Bracket' }, + { 'vP', 'vap', desc = 'Around Para' }, + { 'vQ', 'vaq', desc = 'Around Quote' }, + { 'vb', 'vib', desc = 'Bracket' }, + { 'vp', 'vip', desc = 'Paragraph' }, + { 'vq', 'viq', desc = 'Quote' }, + + { 'w', group = '๏…œ Writing' }, + { 'wc', 'set spell!', desc = 'Spellcheck' }, + { 'wf', "lua require'utils'.sudo_write()", desc = 'Force Write' }, + { 'wj', ']s', desc = 'Next Misspell' }, + { 'wk', '[s', desc = 'Prev Misspell' }, + { 'wq', 'wq', desc = 'Write and Quit' }, + { 'ws', 'Telescope spell_suggest', desc = 'Suggestions' }, + { 'wt', 'Twilight', desc = 'Twilight' }, + { 'ww', 'w', desc = 'Write and Quit' }, + { 'wz', 'ZenMode', desc = 'ZenMode' }, + { 'x', 'x', desc = '๏ฆ Save and Quit' }, + + { 'y', group = '๏ƒช Yank' }, + { 'yP', 'CopyAbsolutePath', desc = 'Absolute Path' }, + { 'ya', '%y+', desc = 'Copy Whole File' }, + { 'yf', 'CopyFileName', desc = 'File Name' }, + { 'yg', 'lua require"gitlinker".get_buf_range_url()', desc = 'Copy Git URL' }, + { 'yp', 'CopyRelativePath', desc = 'Relative Path' }, +} + +local v_mappings = { + mode = 'v', + { 'c', group = '๏ฏ Code' }, + { 'cS', ':sort!', desc = 'Sort Desc' }, + { 'ci', ':sort i', desc = 'Sort Case Insensitive' }, + { 'cs', ':sort', desc = 'Sort Asc' }, + { 'cu', ':!uniq', desc = 'Unique' }, + { 'cx', "'<,'>SnipRun", desc = 'Run Code' }, + + { 'g', group = '๏„“ Git' }, + { 'ga', 'Gitsigns stage_hunk', desc = 'Stage Hunk' }, + { 'gr', 'Gitsigns reset_hunk', desc = 'Reset Hunk' }, + + { 'j', group = '๏“ฒ Jump' }, + { + 'jN', + "lua require('flash').jump({search = { forward = false, wrap = false, multi_window = false },})", + desc = 'Search Backward', + }, + { 'jd', 'FlashDiagnostics', desc = 'Diagnostics' }, + { 'jj', "lua require('flash').remote()", desc = 'Remote' }, + { 'jk', "lua require('flash').treesitter()", desc = 'Treesitter' }, + { + 'jn', + "lua require('flash').jump({search = { forward = true, wrap = false, multi_window = false },})", + desc = 'Search Forward', + }, + { 'jp', "lua require('flash').jump({continue = true})", desc = 'Previous Jump' }, + { 'js', "lua require('flash').jump()", desc = 'Search' }, + { 'jt', "lua require('flash').treesitter_search()", desc = 'Remote Treesitter' }, + { + 'jw', + 'lua require("flash").jump({ pattern = vim.fn.expand("")})', + desc = 'Current Word', + }, + + { 'l', group = '๏‡‹ LSP' }, + { 'la', desc = 'Lspsaga range_code_action' }, + + { 'r', group = '๏„ก Refactor' }, + { + 're', + "lua require('refactoring').refactor('Extract Function')", + desc = 'Extract Function', + }, + { + 'rf', + "lua require('refactoring').refactor('Extract Function To File')", + desc = 'Extract To File', + }, + { 'ri', "lua require('refactoring').refactor('Inline Variable')", desc = 'Inline Variable' }, + { + 'rr', + "lua require('telescope').extensions.refactoring.refactors()", + desc = 'Refactor Commands', + }, + { + 'rv', + "lua require('refactoring').refactor('Extract Variable')", + desc = 'Extract Variable', + }, + + { 'y', group = '๏ƒช Yank' }, + { 'yg', 'lua require"gitlinker".get_buf_range_url("v")', desc = 'Copy Git URL' }, +} + +local no_leader_mappings = { + mode = 'n', + { '', 'resize -10', desc = 'Decrease window height' }, + { '', 'vertical resize -10', desc = 'Decrease window width' }, + { '', 'vertical resize +10', desc = 'Increase window width' }, + { '', 'resize +10', desc = 'Increase window height' }, + { '', 'Telescope find_files', desc = 'Find Files' }, + { '', 'Fterm lazygit', desc = 'Lazygit' }, + + { '', 'h', desc = 'Move Left' }, + { '', 'j', desc = 'Move Down' }, + { '', 'k', desc = 'Move Up' }, + { '', 'l', desc = 'Move Right' }, + { '', 'p', desc = 'Previous Pane' }, + + { '', 'bprevious', desc = 'Previous Buffer' }, + { '', 'bnext', desc = 'Next Buffer' }, + + { 'K', 'Lspsaga hover_doc', desc = 'LSP Hover' }, + { 'Q', 'qall!', desc = 'Force Quit!' }, + { 'U', 'redo', desc = 'Redo' }, + + { '[', group = '๏‚จ Previous' }, + { '[B', 'bfirst', desc = 'First Buffer' }, + { '[b', 'bprevious', desc = 'Buffer' }, + { '[d', 'Lspsaga diagnostic_jump_prev', desc = 'Diagnostic' }, + { '[e', 'g;', desc = 'Edit' }, + { '[g', 'Gitsigns prev_hunk', desc = 'Git Hunk' }, + { '[j', '', desc = 'Jump' }, + + { ']', group = '๏‚ฉ Next' }, + { ']B', 'blast', desc = 'Buffer' }, + { ']b', 'bnext', desc = 'Buffer' }, + { ']d', 'Lspsaga diagnostic_jump_next', desc = 'Diagnostic' }, + { ']e', 'g,', desc = 'Edit' }, + { ']g', 'Gitsigns next_hunk', desc = 'Git Hunk' }, + { ']j', '', desc = 'Jump' }, +} + +local tmux_mappings = { + { '', 'NavigatorLeft', desc = 'Move Left' }, + { '', 'NavigatorDown', desc = 'Move Down' }, + { '', 'NavigatorUp', desc = 'Move Up' }, + { '', 'NavigatorRight', desc = 'Move Right' }, + { '', 'NavigatorPrevious', desc = 'Previous Pane' }, +} + +which_key.setup(setup) +which_key.add(n_mappings) +which_key.add(v_mappings) +which_key.add(no_leader_mappings) + +if vim.fn.exists('$TMUX') == 1 then + which_key.add(tmux_mappings) +end diff --git a/lua/plugins/ui/dashboard.lua b/lua/plugins/ui/dashboard.lua new file mode 100644 index 0000000..caf5b6c --- /dev/null +++ b/lua/plugins/ui/dashboard.lua @@ -0,0 +1,87 @@ +local dashboard = require('dashboard') +local icons = require('lib.icons') + +dashboard.setup({ + theme = 'hyper', + disable_move = false, + shortcut_type = 'letter', + change_to_vcs_root = true, + hide = { + statusline = true, + tabline = false, + winbar = false, + }, + config = { + header = { '', + + ' โ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ•— ', + ' โ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ–ˆโ–ˆโ•”โ•โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ•‘ ', + ' โ–ˆโ–ˆโ•”โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ–ˆโ–ˆโ–ˆโ–ˆโ•”โ–ˆโ–ˆโ•‘ ', + ' โ–ˆโ–ˆโ•‘โ•šโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ• โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ•šโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘โ•šโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ•‘ ', + ' โ–ˆโ–ˆโ•‘ โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ• โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ• โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘ โ•šโ•โ• โ–ˆโ–ˆโ•‘ ', + ' โ•šโ•โ• โ•šโ•โ•โ•โ•โ•šโ•โ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ• โ•šโ•โ•โ•šโ•โ• โ•šโ•โ• ', + '',}, + week_header = { + enable = false, + append = { '', icons.ui.Circle .. ' Learn, Make, Explore! ' .. icons.ui.Circle }, + }, + packages = { enable = true }, + project = { enable = true, limit = 8 }, + mru = { limit = 8 }, + shortcut = { + { + desc = icons.ui.Package .. 'Mason', + group = '@property', + action = 'Mason', + key = 'm', + }, + { + desc = icons.ui.Sleep .. 'Lazy', + group = '@property', + action = 'Lazy', + key = 'l', + }, + { + desc = icons.documents.OpenFolder .. 'Files', + group = 'Label', + action = 'lua require("telescope").extensions.menufacture.find_files()', + key = 'f', + }, + { + desc = icons.ui.Search .. 'Search', + group = 'Label', + action = 'lua require("telescope").extensions.menufacture.live_grep()', + key = 'g', + }, + { + desc = icons.ui.Note .. 'Todo', + group = 'Label', + action = 'Tdo', + key = 'd', + }, + { + desc = icons.ui.Power, + group = 'Action', + action = 'quit', + key = 'q', + }, + }, + footer = function() + local info = {} + local fortune = require("fortune").get_fortune() + local footer = vim.list_extend(info, fortune) + return footer + end, + }, +}) + +-- Show dashboard when lazy closes +if vim.o.filetype == 'lazy' then + vim.cmd.close() + vim.api.nvim_create_autocmd('User', { + pattern = 'DashboardLoaded', + callback = function() + require('lazy').show() + end, + }) +end diff --git a/lua/plugins/ui/dressing.lua b/lua/plugins/ui/dressing.lua new file mode 100644 index 0000000..eb32f4c --- /dev/null +++ b/lua/plugins/ui/dressing.lua @@ -0,0 +1,27 @@ +local dressing = require('dressing') + +dressing.setup({ + win_options = { + winblend = 10, + winhighlight = 'Normal:DressingInputNormalFloat,NormalFloat:DressingInputNormalFloat,FloatBorder:DressingInputFloatBorder', + }, + input = { + enabled = true, + default_prompt = 'Input:', + prompt_align = 'center', + insert_only = true, + start_in_insert = true, + border = 'rounded', + relative = 'editor', + prefer_width = 40, + width = nil, + max_width = { 140, 0.9 }, + min_width = { 20, 0.2 }, + get_config = nil, + }, + select = { + enabled = true, + backend = { 'telescope', 'fzf_lua', 'fzf', 'nui', 'builtin'}, + trim_prompt = true, + }, +}) diff --git a/lua/plugins/ui/indentline.lua b/lua/plugins/ui/indentline.lua new file mode 100644 index 0000000..41d6845 --- /dev/null +++ b/lua/plugins/ui/indentline.lua @@ -0,0 +1,27 @@ +local highlight = { + 'RainbowRed', + 'RainbowYellow', + 'RainbowBlue', + 'RainbowOrange', + 'RainbowGreen', + 'RainbowViolet', + 'RainbowCyan', +} +local hooks = require('ibl.hooks') +hooks.register(hooks.type.HIGHLIGHT_SETUP, function() + vim.api.nvim_set_hl(0, 'RainbowRed', { fg = '#E06C75' }) + vim.api.nvim_set_hl(0, 'RainbowYellow', { fg = '#E5C07B' }) + vim.api.nvim_set_hl(0, 'RainbowBlue', { fg = '#61AFEF' }) + vim.api.nvim_set_hl(0, 'RainbowOrange', { fg = '#D19A66' }) + vim.api.nvim_set_hl(0, 'RainbowGreen', { fg = '#98C379' }) + vim.api.nvim_set_hl(0, 'RainbowViolet', { fg = '#C678DD' }) + vim.api.nvim_set_hl(0, 'RainbowCyan', { fg = '#56B6C2' }) +end) + +vim.g.rainbow_delimiters = { highlight = highlight } +require('ibl').setup({ + scope = { highlight = highlight }, + exclude = { filetypes = { 'dashboard', 'toggleterm' } }, +}) + +hooks.register(hooks.type.SCOPE_HIGHLIGHT, hooks.builtin.scope_highlight_from_extmark) diff --git a/lua/plugins/ui/lualine.lua b/lua/plugins/ui/lualine.lua new file mode 100644 index 0000000..173a542 --- /dev/null +++ b/lua/plugins/ui/lualine.lua @@ -0,0 +1,196 @@ +local lualine = require('lualine') +local icons = require('lib.icons') + +local colors = { + bg = '#202328', + fg = '#bbc2cf', + yellow = '#ECBE7B', + cyan = '#008080', + darkblue = '#081633', + green = '#98be65', + orange = '#FF8800', + violet = '#a9a1e1', + magenta = '#c678dd', + blue = '#51afef', + red = '#ec5f67', +} + +local mode_color = { + n = colors.green, + i = colors.blue, + v = colors.magenta, + [''] = colors.magenta, + V = colors.magenta, + c = colors.yellow, + t = colors.red, + R = colors.orange, + Rv = colors.orange, + no = colors.fg, + s = colors.violet, + S = colors.violet, + [''] = colors.violet, + ic = colors.yellow, + cv = colors.red, + ce = colors.red, + r = colors.cyan, + rm = colors.cyan, + ['r?'] = colors.cyan, + ['!'] = colors.red, +} + +local conditions = { + buffer_not_empty = function() + return vim.fn.empty(vim.fn.expand('%:t')) ~= 1 + end, + buffer_is_file = function() + return vim.bo.buftype == '' + end, + hide_in_width = function() + return vim.fn.winwidth(0) > 80 + end, + check_git_workspace = function() + local filepath = vim.fn.expand('%:p:h') + local gitdir = vim.fn.finddir('.git', filepath .. ';') + return gitdir and #gitdir > 0 and #gitdir < #filepath + end, +} +local searchcount = { 'searchcount', color = { fg = colors.fg, gui = 'bold' } } +local selectioncount = { 'selectioncount', color = { fg = colors.fg, gui = 'bold' } } +local progress = { 'progress', color = { fg = colors.fg, gui = 'bold' } } +local filetype = { 'filetype', color = { fg = colors.blue, gui = 'bold' } } +local filesize = { 'filesize', color = { fg = colors.fg, gui = 'bold' }, cond = conditions.buffer_not_empty } +local fileformat = { 'fileformat', icons_enabled = true, color = { fg = colors.white, gui = 'bold' } } + +local filename = { + 'filename', + cond = conditions.buffer_not_empty and conditions.buffer_is_file, + color = { fg = colors.magenta, gui = 'bold' }, +} + +local buffers = { + 'buffers', + filetype_names = { + TelescopePrompt = icons.ui.Telescope .. 'Telescope', + dashboard = icons.ui.Dashboard .. 'Dashboard', + lazy = icons.ui.Sleep .. 'Lazy', + mason = icons.ui.Package .. 'Mason', + NvimTree = icons.documents.OpenFolder .. 'Files', + spectre_panel = icons.ui.Search .. 'Spectre', + }, + use_mode_colors = true, +} + +local branch = { + 'branch', + icon = icons.git.Branch, + fmt = function(str) + return str:sub(1, 32) + end, + color = { fg = colors.green, gui = 'bold' }, +} + +local diff_icons = { + 'diff', + symbols = { added = icons.git.AddAlt, modified = icons.git.DiffAlt, removed = icons.git.RemoveAlt }, + diff_color = { + added = { fg = colors.green }, + modified = { fg = colors.orange }, + removed = { fg = colors.red }, + }, + cond = conditions.hide_in_width, +} + +local diagnostics = { + 'diagnostics', + sources = { 'nvim_lsp', 'nvim_diagnostic', 'nvim_workspace_diagnostic' }, + symbols = { + error = icons.diagnostics.Error, + warn = icons.diagnostics.Warning, + info = icons.diagnostics.Information, + hint = icons.diagnostics.Hint, + }, + diagnostics_color = { + color_error = { fg = colors.red }, + color_warn = { fg = colors.yellow }, + color_info = { fg = colors.blue }, + color_hint = { fg = colors.yellow }, + }, +} + +local lsp = { + function() + local msg = 'No LSP' + local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype') + local clients = vim.lsp.get_active_clients() + if next(clients) == nil then + return msg + end + for _, client in ipairs(clients) do + local filetypes = client.config.filetypes + if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then + return client.name + end + end + return msg + end, + icon = icons.ui.Gear, + color = { fg = colors.fg, gui = 'bold' }, +} + +local encoding = { + 'o:encoding', + fmt = string.upper, + cond = conditions.hide_in_width, + color = { fg = colors.green, gui = 'bold' }, +} + +local separator = { + function() + return icons.ui.Separator + end, + color = function() + return { fg = mode_color[vim.fn.mode()] } + end, + padding = { left = 0, right = 0 }, +} + +local function mode(icon) + icon = icon or icons.ui.NeoVim + return { + function() + return icon + end, + color = function() + return { fg = mode_color[vim.fn.mode()] } + end, + padding = { left = 1, right = 0 }, + } +end + +lualine.setup({ + options = { + component_separators = '', + -- section_separators = '', + theme = 'onedark', + disabled_filetypes = { + 'dashboard', + }, + }, + -- extensions = { 'quickfix', 'man', 'mason', 'lazy', 'toggleterm', 'nvim-tree' }, + tabline = { + lualine_a = {}, + lualine_b = { mode(), buffers }, + lualine_c = {}, + lualine_x = { diff_icons, branch }, + lualine_y = { searchcount, selectioncount }, + lualine_z = {}, + }, + sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { separator, mode(icons.ui.Heart), 'location', progress, filename }, + lualine_x = { diagnostics, lsp, filetype, filesize, fileformat, encoding, separator }, + lualine_y = {}, + lualine_z = {}, + }, +}) diff --git a/lua/plugins/ui/noice.lua b/lua/plugins/ui/noice.lua new file mode 100644 index 0000000..9edd01d --- /dev/null +++ b/lua/plugins/ui/noice.lua @@ -0,0 +1,265 @@ +local border_style = { + top_left = "โ”Œ", top = "โ”€", top_right = "โ”", + left = "โ”‚", right = "โ”‚", + bottom_left = "โ””", bottom = "โ”€", bottom_right = "โ”˜", +} +local rounded_border_style = { + top_left = "โ•ญ", top = "โ”€", top_right = "โ•ฎ", + left = "โ”‚", right = "โ”‚", + bottom_left = "โ•ฐ", bottom = "โ”€", bottom_right = "โ•ฏ", +} +require("noice").setup({ + cmdline = { + enabled = true, -- enables the Noice cmdline UI + view = "cmdline_popup", -- view for rendering the cmdline. Change to `cmdline` to get a classic cmdline at the bottom + opts = {}, -- global options for the cmdline. See section on views + ---@type table + format = { + -- conceal: (default=true) This will hide the text in the cmdline that matches the pattern. + -- view: (default is cmdline view) + -- opts: any options passed to the view + -- icon_hl_group: optional hl_group for the icon + -- title: set to anything or empty string to hide + cmdline = { pattern = "^:", icon = "๎šฎ ", lang = "vim", title = " Cmdline " }, + search_down = { kind = "search", pattern = "^/", icon = " ๏€‚ ๏„ƒ", lang = "regex", title = " Search Down " }, + search_up = { kind = "search", pattern = "^%?", icon = " ๏€‚ ๏„‚", lang = "regex" , title = " Search Up " }, + filter = { pattern = "^:%s*!", icon = " ๏„  ", lang = "bash" , title = "Filter" }, + lua = { pattern = { "^:%s*lua%s+", "^:%s*lua%s*=%s*", "^:%s*=%s*" }, icon = " ๎˜  ", lang = "lua", title = " Lua " }, + help = { pattern = "^:%s*he?l?p?%s+", icon = " ๏Ÿ•", title = " Help " }, + input = {}, -- Used by input() + -- lua = false, -- to disable a format, set to `false` + }, + }, + messages = { + -- NOTE: If you enable messages, then the cmdline is enabled automatically. + -- This is a current Neovim limitation. + enabled = true, -- enables the Noice messages UI + view = "mini", -- default view for messages + view_error = "notify", -- view for errors + view_warn = "notify", -- view for warnings + view_history = "messages", -- view for :messages + -- view_search = false, + view_search = "virtualtext", -- view for search count messages. Set to `false` to disable + }, + popupmenu = { + enabled = true, -- enables the Noice popupmenu UI + ---@type 'nui'|'cmp' + backend = "cmp", -- backend to use to show regular cmdline completions + ---@type NoicePopupmenuItemKind|false + -- Icons for completion item kinds (see defaults at noice.config.icons.kinds) + kind_icons = {}, -- set to `false` to disable icons + }, + -- default options for require('noice').redirect + -- see the section on Command Redirection + ---@type NoiceRouteConfig + redirect = { + view = "popup", + filter = { event = "msg_show" }, + }, + -- You can add any custom commands below that will be available with `:Noice command` + ---@type table + commands = { + history = { + -- options for the message history that you get with `:Noice` + view = "split", + opts = { enter = true, format = "details" }, + filter = { + any = { + { event = "notify" }, + { error = true }, + { warning = true }, + { event = "msg_show", kind = { "" } }, + { event = "lsp", kind = "message" }, + }, + }, + }, + -- :Noice last + last = { + view = "popup", + opts = { enter = true, format = "details" }, + filter = { + any = { + { event = "notify" }, + { error = true }, + { warning = true }, + { event = "msg_show", kind = { "" } }, + { event = "lsp", kind = "message" }, + }, + }, + filter_opts = { count = 1 }, + }, + -- :Noice errors + errors = { + -- options for the message history that you get with `:Noice` + view = "popup", + opts = { enter = true, format = "details" }, + filter = { error = true }, + filter_opts = { reverse = true }, + }, + }, + notify = { + -- Noice can be used as `vim.notify` so you can route any notification like other messages + -- Notification messages have their level and other properties set. + -- event is always "notify" and kind can be any log level as a string + -- The default routes will forward notifications to nvim-notify + -- Benefit of using Noice for this is the routing and consistent history view + enabled = true, + view = "notify", + }, + lsp = { + progress = { + enabled = true, + -- Lsp Progress is formatted using the builtins for lsp_progress. See config.format.builtin + -- See the section on formatting for more details on how to customize. + --- @type NoiceFormat|string + format = "lsp_progress", + --- @type NoiceFormat|string + format_done = "lsp_progress_done", + throttle = 1000 / 30, -- frequency to update lsp progress message + view = "mini", + }, + override = { + -- override the default lsp markdown formatter with Noice + ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + -- override the lsp markdown formatter with Noice + ["vim.lsp.util.stylize_markdown"] = true, + -- override cmp documentation with Noice (needs the other options to work) + ["cmp.entry.get_documentation"] = true, + }, + hover = { + enabled = true, + view = nil, -- when nil, use defaults from documentation + ---@type NoiceViewOptions + opts = {}, -- merged with defaults from documentation + }, + signature = { + enabled = true, + auto_open = { + enabled = true, + trigger = true, -- Automatically show signature help when typing a trigger character from the LSP + luasnip = true, -- Will open signature help when jumping to Luasnip insert nodes + throttle = 50, -- Debounce lsp signature help request by 50ms + }, + view = nil, -- when nil, use defaults from documentation + ---@type NoiceViewOptions + opts = {}, -- merged with defaults from documentation + }, + message = { + -- Messages shown by lsp servers + enabled = true, + view = "mini", + opts = {}, + }, + -- defaults for hover and signature help + documentation = { + view = "hover", + ---@type NoiceViewOptions + opts = { + lang = "markdown", + replace = true, + render = "plain", + format = { "{message}" }, + win_options = { concealcursor = "n", conceallevel = 3 }, + }, + }, + }, + markdown = { + hover = { + ["|(%S-)|"] = vim.cmd.help, -- vim help links + ["%[.-%]%((%S-)%)"] = require("noice.util").open, -- markdown links + }, + highlights = { + ["|%S-|"] = "@text.reference", + ["@%S+"] = "@parameter", + ["^%s*(Parameters:)"] = "@text.title", + ["^%s*(Return:)"] = "@text.title", + ["^%s*(See also:)"] = "@text.title", + ["{%S-}"] = "@parameter", + }, + }, + health = { + checker = true, -- Disable if you don't want health checks to run + }, + smart_move = { + -- noice tries to move out of the way of existing floating windows. + enabled = true, -- you can disable this behaviour here + -- add any filetypes here, that shouldn't trigger smart move. + excluded_filetypes = { "cmp_menu", "cmp_docs", "notify" }, + }, + ---@type NoicePresets + presets = { + -- you can enable a preset by setting it to true, or a table that will override the preset config + -- you can also add custom presets that you can enable/disable with enabled=true + bottom_search = false, -- use a classic bottom cmdline for search + command_palette = false, -- position the cmdline and popupmenu together + long_message_to_split = true, -- long messages will be sent to a split + inc_rename = true, -- enables an input dialog for inc-rename.nvim + lsp_doc_border = true, -- add a border to hover docs and signature help + }, + throttle = 1000 / 30, -- how frequently does Noice need to check for ui updates? This has no effect when in blocking mode. + ---@type NoiceConfigViews + views = { + cmdline_popup = { + position = { + row = "50%", + col = "50%", + }, + size = { + width = "40%", + height = "auto", + }, + border = { + style = rounded_border_style, + -- style = "none", + }, + filter_options = {}, + win_options = { + winhighlight = { Normal = "TelescopePromptNormal", FloatBorder = "DiagnosticInfo" }, + }, + }, + split = { + enter = true, + }, + notify = { + size = { + width = 30 + } + }, + mini = { + win_options = { + winblend = 0, + -- winhighlight = {} + } + }, + popupmenu = { + relative = "editor", + position = { + row = 8, + col = "50%", + }, + size = { + width = 60, + height = 10, + }, + border = { + style = rounded_border_style, + padding = { 0, 1 }, + }, + win_options = { + winhighlight = { Normal = "TelescopePromptNormal", FloatBorder = "DiagnosticInfo" }, + }, + }, + }, ---@see section on views + ---@type NoiceRouteConfig[] + routes = { + { + filter = { + event = "msg_show", + -- kind = "search_count", + find = "written" + }, + opts = { skip = true }, + }, + }, --- @see section on routes +}) + diff --git a/lua/plugins/ui/notify.lua b/lua/plugins/ui/notify.lua new file mode 100644 index 0000000..13e636a --- /dev/null +++ b/lua/plugins/ui/notify.lua @@ -0,0 +1,19 @@ +vim.notify = require("notify") + +require("notify").setup({ + background_colour = "Normal", + fps = 30, + icons = { + DEBUG = "๏†ˆ ", + ERROR = "๏— ", + INFO = "๏š ", + TRACE = "โœŽ", + WARN = "๏ช " + }, + level = 2, + minimum_width = 30, + maximum_width = 30, + render = "wrapped-compact", + stages = "slide", + timeout = 2000 +}) diff --git a/lua/plugins/ui/onedark.lua b/lua/plugins/ui/onedark.lua new file mode 100644 index 0000000..fd7e204 --- /dev/null +++ b/lua/plugins/ui/onedark.lua @@ -0,0 +1,26 @@ +local onedark = require('onedark') +local util = require('lib.util') + +onedark.setup({ + style = 'deep', + transparent = true, + term_colors = false, + ending_tildes = false, + cmp_itemkind_reverse = false, + + toggle_style_key = 'ot', + toggle_style_list = { 'dark', 'darker', 'cool', 'warm', 'warmer', 'deep', 'light' }, + + -- Options are italic, bold, underline, none and combos 'italic,bold' + code_style = { + comments = 'italic', + keywords = 'none', + functions = 'none', + strings = 'none', + variables = 'none', + }, + + lualine = { transparent = true }, + diagnostics = { darker = true, undercurl = true, background = false }, +}) +onedark.load() diff --git a/lua/plugins/ui/rainbow.lua b/lua/plugins/ui/rainbow.lua new file mode 100644 index 0000000..be4414c --- /dev/null +++ b/lua/plugins/ui/rainbow.lua @@ -0,0 +1,19 @@ +local rainbow_delimiters = require('rainbow-delimiters') + +vim.g.rainbow_delimiters = { + strategy = { + [''] = rainbow_delimiters.strategy['global'], + commonlisp = rainbow_delimiters.strategy['local'], + }, + query = { [''] = 'rainbow-delimiters', lua = 'rainbow-blocks' }, + highlight = { + 'RainbowDelimiterRed', + 'RainbowDelimiterYellow', + 'RainbowDelimiterBlue', + 'RainbowDelimiterOrange', + 'RainbowDelimiterGreen', + 'RainbowDelimiterViolet', + 'RainbowDelimiterCyan', + }, + blacklist = {}, +} diff --git a/lua/plugins/ui/twilight.lua b/lua/plugins/ui/twilight.lua new file mode 100644 index 0000000..a22d4d0 --- /dev/null +++ b/lua/plugins/ui/twilight.lua @@ -0,0 +1,9 @@ +local twilight = require('twilight') + +twilight.setup({ + dimming = { alpha = 0.45, color = { 'Normal', '#ffffff' }, inactive = false }, + context = 9, + treesitter = true, + expand = { 'function', 'method', 'table', 'if_statement', 'element' }, + exclude = {}, +}) diff --git a/lua/plugins/ui/wilder.lua b/lua/plugins/ui/wilder.lua new file mode 100644 index 0000000..490d112 --- /dev/null +++ b/lua/plugins/ui/wilder.lua @@ -0,0 +1,70 @@ +local wilder = require('wilder') + +wilder.setup({ modes = { ':', '/', '?' } }) + +wilder.set_option('pipeline', { + wilder.branch( + wilder.python_file_finder_pipeline({ + file_command = { 'rg', '--files', '--hidden' }, + dir_command = { 'fd', '-td' }, + filters = { 'fuzzy_filter', 'difflib_sorter' }, + }), + wilder.cmdline_pipeline({ + fuzzy = 2, + }), + wilder.vim_search_pipeline({ + fuzzy = 2, + }), + wilder.python_search_pipeline() + ), +}) + +local accent = wilder.make_hl('WilderAccent', 'Pmenu', { { a = 1 }, { a = 1 }, { foreground = '#00AAFF' } }) +local icons = require('lib.icons') + +local popupmenu_renderer = wilder.popupmenu_renderer(wilder.popupmenu_palette_theme({ + border = 'rounded', + max_height = '75%', + min_height = 0, + prompt_position = 'top', + reverse = 0, + empty_message = wilder.popupmenu_empty_message_with_spinner(), + highlighter = wilder.basic_highlighter(), + highlights = { + accent = accent, + }, + left = { + ' ', + wilder.popupmenu_devicons(), + wilder.popupmenu_buffer_flags({ + flags = ' a + ', + icons = { + ['+'] = icons.ui.Pencil, + a = icons.documents.File, + h = icons.documents.FileEmpty, + }, + }), + }, + right = { + ' ', + wilder.popupmenu_scrollbar(), + }, +})) + +local wildmenu_renderer = wilder.wildmenu_renderer({ + highlighter = wilder.basic_highlighter(), + highlights = { accent = accent }, + separator = ' | ', + left = { ' ', wilder.wildmenu_spinner(), ' ' }, + right = { ' ', wilder.wildmenu_index() }, +}) + +wilder.set_option( + 'renderer', + wilder.renderer_mux({ + [':'] = popupmenu_renderer, + ['/'] = popupmenu_renderer, + ['?'] = popupmenu_renderer, + substitute = wildmenu_renderer, + }) +) diff --git a/lua/plugins/ui/zen-mode.lua b/lua/plugins/ui/zen-mode.lua new file mode 100644 index 0000000..a56c449 --- /dev/null +++ b/lua/plugins/ui/zen-mode.lua @@ -0,0 +1,31 @@ +local zen = require('zen-mode') + +zen.setup({ + window = { + backdrop = 0.95, + width = 180, + height = 1, + options = { + signcolumn = 'no', + number = false, + relativenumber = false, + cursorline = false, + cursorcolumn = false, + foldcolumn = '0', + list = false, + }, + }, + plugins = { + options = { enabled = true, ruler = true, showcmd = true }, + twilight = { enabled = true }, + gitsigns = { enabled = true }, + tmux = { enabled = true }, + kitty = { enabled = false, font = '+4' }, + }, + on_open = function(win) + vim.o.laststatus = 0 + end, + on_close = function() + vim.o.laststatus = 2 + end, +}) diff --git a/plugin/after/highlights.lua b/plugin/after/highlights.lua new file mode 100644 index 0000000..24ac199 --- /dev/null +++ b/plugin/after/highlights.lua @@ -0,0 +1,28 @@ +-- transparent background +vim.api.nvim_set_hl(0, 'Normal', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'NormalFloat', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'FloatBorder', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'Pmenu', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'Terminal', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'EndOfBuffer', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'FoldColumn', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'Folded', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'SignColumn', { bg = 'none' }) + +-- transparent background for nvim-tree +vim.api.nvim_set_hl(0, 'NvimTreeNormal', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'NvimTreeVertSplit', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'NvimTreeEndOfBuffer', { bg = 'none' }) + +-- set hlsearch color +vim.api.nvim_set_hl(0, 'Search', { bg = '#8BCD5B', fg = '#202020' }) +vim.api.nvim_set_hl(0, 'CurSearch', { bg = '#EFBD5D', fg = '#000000' }) +vim.api.nvim_set_hl(0, 'IncSearch', { bg = '#F15664', fg = '#000000' }) + +-- set cursorline color +vim.api.nvim_set_hl(0, 'CursorLine', { bg = '#1A1A1F' }) +vim.api.nvim_set_hl(0, 'CursorColumn', { bg = '#1A1A1F' }) + +-- set visual highlight +vim.api.nvim_set_hl(0, 'Visual', { bg = '#103070' }) + diff --git a/snippets/c.json b/snippets/c.json new file mode 100644 index 0000000..96cbe4e --- /dev/null +++ b/snippets/c.json @@ -0,0 +1,360 @@ +{ + "for": { + "prefix": "for", + "body": [ + "for (${1:size_t} ${2:i} = ${3:0}; $2 < ${4:length}; $2++) {", + "\t$0", + "}" + ], + "description": "Code snippet for 'for' loop" + }, + "_FOREACH": { + "prefix": "_FOREACH", + "body": [ + "#define foreach(item, array) \\", + "\tfor(int keep = 1, \\", + "\tcount = 0,\\", + "\tsize = sizeof (array) / sizeof *(array); \\", + "\tkeep && count != size; \\", + "\tkeep = !keep, count++) \\", + "\tfor(item = (array) + count; keep; keep = !keep)" + ], + "description": "foreach loop C" + }, + "*": { + "prefix": "*", + "body": ["/* $0 */"], + "description": "Block comment" + }, + "glfw330win": { + "prefix": "glfw330win", + "body": [ + "if (!glfwInit()) {", + "log_warn(\"GLFW failed\");", + "glfwTerminate();", + "return 1;", + "}", + "glfwWindowHint(GLFW_SAMPLES, 4);", + "glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);", + "glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);", + "glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);" + ], + "description": "Glfw window hint for opengl v3.3" + }, + "gl_vertex_arr": { + "prefix": "gl_vertex_arr", + "body": [ + "glGenVertexArrays(${1:size}, &$2);", + "glBindVertexArray($2);" + ], + "description": "GL generate vertex array" + }, + "gl_vertex_buffer": { + "prefix": "gl_vertex_buffer", + "body": [ + "glGenBuffers(${1:1}, &$2);", + "glBindBuffer(${3:buffer_type}, $2);", + "glBufferData($3, sizeof($4), $4, $5)" + ], + "description": "gl generate buffer" + }, + "DBG": { + "prefix": "DBG", + "body": ["#define WHERE fprintf(stderr,\"[LOG]%s:%d\\n\",__FILE__,__LINE__);"], + "description": "Debug code line" + }, + "forr": { + "prefix": "forr", + "body": [ + "for (${1:size_t} ${2:i} = ${3:length} - 1; $2 >= ${4:0}; $2--) {", + "\t$0", + "}" + ], + "description": "Code snippet for reverse 'for' loop" + }, + "mod": { + "prefix": "_MOD", + "body": ["#define MOD(N,M)\t((N)%(M) < 0 ? (N)%(M) + (M) : (N)%(M))\n"], + "description": "mod of N,M" + }, + "between": { + "prefix": "_BETWEEN", + "body": ["#define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b))\n"], + "description": "x is between a, b" + }, + "length" : { + "prefix": "_LENGTH", + "body": ["#define LENGTH(x) sizeof(x)/sizeof(x[0])\n"], + "description": "Array size macro" + }, + "max" : { + "prefix": "_MAX", + "body": ["#define MAX(x,y) (x) > (y) ? (x) : (y)","$0"], + "description": "Get max element" + }, + "min" : { + "prefix": "_MIN", + "body": ["#define MIN(x,y) (x) < (y) ? (x) : (y)","$0"], + "description": "Get min element" + }, + "getbit": { + "prefix": "_GETBIT", + "body": ["#define GETBIT(x,i) (x&(1<"], + "description": "Code snippet for #include < >" + }, + "#def": { + "prefix": "def", + "body": ["#define $0"], + "description": "Code snippet for #define \" \"" + }, + "Main function template": { + "prefix": "main", + "body": [ + "int main (int argc, char *argv[])", + "{", + "\t$0", + "\treturn 0;", + "}" + ], + "description": "A standard main function for a C program" + }, + "Standard Starter Template": { + "prefix": "sst", + "body": [ + "#include ", + "", + "int main ()", + "{", + "\t$0", + "\treturn 0;", + "}" + ], + "description": "A standard starter template for a C program" + }, + "Stdlib Variant Starter Template": { + "prefix": "libsst", + "body": [ + "#include ", + "#include ", + "", + "int main (int argc, char *argv[])", + "{", + "\t$0", + "\treturn 0;", + "}" + ], + "description": "A standard starter template for a C program with stdlib included" + }, + "Create linked list": { + "prefix": "clist", + "body": [ + "typedef struct _node * Link;", + "typedef struct _node node;", + "struct _node {", + "\tint value;", + "\tLink next;", + "};" + ], + "description": "Creates a linked list template" + }, + "Scan integer": { + "prefix": "sci", + "body": ["scanf(\"%d\", &$1);"], + "description": "Scan int" + }, + "Scan 2 integer": { + "prefix": "sci2", + "body": ["scanf(\"%d %d\", &$1, &$2);"], + "description": "Scan 2 int" + }, + "Scan unsigned integer": { + "prefix": "scui", + "body": ["scanf(\"%d\", &$1);"], + "description": "Scan unsigned int" + }, + "Scan float": { + "prefix": "scf", + "body": ["scanf(\"%f\", &$1);"], + "description": "Scan float" + }, + "Scan 2 float": { + "prefix": "scf2", + "body": ["scanf(\"%f %f\", &$1, &$2);"], + "description": "Scan 2 float" + }, + "Scan long": { + "prefix": "scl", + "body": ["scanf(\"%ld\", &$1);"], + "description": "Scan long" + }, + "Scan 2 long": { + "prefix": "scl2", + "body": ["scanf(\"%ld %ld\", &$1, &$2);"], + "description": "Scan 2 long" + }, + "Scan unsigned long": { + "prefix": "scul", + "body": ["scanf(\"%lu\", &$1);"], + "description": "Scan unsigned long" + }, + "Scan unsigned long long": { + "prefix": "scull", + "body": ["scanf(\"%llu\", &$1);"], + "description": "Scan unsigned long long" + }, + "Print variable of type float (2 decimal places)": { + "prefix": "pflo", + "body": ["printf(\"$1 :>> %.2f\\n\", $1);"], + "description": "Calls printf() to log value of variable of type float rounded to 2 decimal places" + }, + "Print variable of type integer": { + "prefix": "pint", + "body": ["printf(\"$1 : %d\\n\", $1);"], + "description": "Calls printf() to log value of variable of type signed integer" + }, + "Print variable of type char": { + "prefix": "pcha", + "body": ["printf(\"$1 : %c\\n\", $1);"], + "description": "Calls printf() to log value of variable of type char" + }, + "Print variable of type pointer": { + "prefix": "ppoint", + "body": ["printf(\"$1 : %p\\n\", (void *) $1);"], + "description": "Calls printf() to log value of variable of type pointer" + }, + "Print variable of type size_t": { + "prefix": "psiz", + "body": ["printf(\"$1 : %zu\\n\", $1);"], + "description": "Calls printf() to log value of variable of type size_t" + }, + "printf": { + "prefix": "printf", + "body": ["printf(\"$1\\n\"$0);"], + "description": "Generic printf() snippet" + }, + "sprintf": { + "prefix": "sprintf", + "body": ["sprintf($1, \"$2\\n\"$0);"], + "description": "Generic sprintf() snippet" + }, + "fprintf": { + "prefix": "fprintf", + "body": ["fprintf(${1:stderr}, \"$2\\n\"$0);"], + "description": "Generic fprintf() snippet" + }, + "scanf": { + "prefix": "scanf", + "body": ["scanf(\"$1\"$0);"], + "description": "Generic scanf() snippet" + }, + "sscanf": { + "prefix": "sscanf", + "body": ["sscanf($1, \"$2\"$0);"], + "description": "Generic sscanf() snippet" + }, + "fscanf": { + "prefix": "fscanf", + "body": ["fscanf($1, \"$2\"$0);"], + "description": "Generic fscanf() snippet" + }, + "Allocate memory using malloc": { + "prefix": "mal", + "body": [ + "${1:int} *${2:v} = malloc(${3:1} * sizeof($1));", + "", + "if (!$2) {", + "\tfprintf(stderr, \"Memory allocation failed!\\n\");", + "\t$4;", + "}", + "$0", + "free($2);" + ], + "description": "Allocates memory to a pointer variable using malloc(), then deallocates using free()." + }, + "Allocate memory using calloc": { + "prefix": "cal", + "body": [ + "${1:int} *${2:v} = calloc(${3:1}, sizeof($1));", + "", + "if (!$2) {", + "\tfprintf(stderr, \"Memory allocation failed!\\n\");", + "\t$4;", + "}", + "$0", + "free($2);" + ], + "description": "Allocates memory to a pointer variable using calloc(), then deallocates using free()." + }, + "X11 default incs": { + "prefix": "_X11", + "body": ["#include \n#include \n#include \n#include \n"], + "description": "X11 default library headers" + }, + "Primitive macros": { + "prefix": "_PRIMITIVE", + "body": [ + "#define i16 short", + "#define ui16 unsigned short", + "#define i32 int", + "#define ui32 unsigned int", + "#define i64 long long", + "#define ui64 unsigned long long" + ], + "description": "Primitive macros for int type" + } +} diff --git a/snippets/cpp.json b/snippets/cpp.json new file mode 100644 index 0000000..c949464 --- /dev/null +++ b/snippets/cpp.json @@ -0,0 +1,219 @@ +{ + "for": { + "prefix": "for", + "body": [ + "for (${1:size_t} ${2:i} = ${3:0}; $2 < ${4:length}; $2++) {", + "\t$0", + "}" + ], + "description": "Code snippet for 'for' loop" + }, + "*": { + "prefix": "*", + "body": ["/* $0 */"], + "description": "Block comment" + }, + "forr": { + "prefix": "forr", + "body": [ + "for (${1:size_t} ${2:i} = ${3:length} - 1; $2 >= ${4:0}; $2--) {", + "\t$0", + "}" + ], + "description": "Code snippet for reverse 'for' loop" + }, + "mod": { + "prefix": "MOD", + "body": ["#define MOD(N,M)\t((N)%(M) < 0 ? (N)%(M) + (M) : (N)%(M))"], + "description": "mod of N,M" + }, + "between": { + "prefix": "between", + "body": ["#define BETWEEN(x, a, b)\t((a) <= (x) && (x) <= (b))"], + "description": "x is between a, b" + }, + "sze" : { + "prefix": "sze", + "body": ["#define SIZE(x) sizeof(x)/sizeof(x[0])","$0"], + "description": "Array size macro" + }, + "do": { + "prefix": "do", + "body": ["do", "{", "\t$1", "} while($2);"], + "description": "Code snippet for do...while loop" + }, + "while": { + "prefix": "while", + "body": ["while ($1) {", "\t$2", "}"], + "description": "" + }, + "foreach": { + "prefix": "foreach", + "body": ["for (${1:auto} ${2:var} : ${3:collection_to_loop}) {", "\t$0", "}"], + "description": "Code snippet for range-based for loop (c++11) statement" + }, + "enum": { + "prefix": "enum", + "body": ["enum ${1:MyEnum} {", "\t$0", "};"], + "description": "Code snippet for enum" + }, + "enum class": { + "prefix": "enum class", + "body": ["enum class ${1:MyClass} {$0};"], + "description": "Code snippet for enum class (c++11)" + }, + "class": { + "prefix": "class", + "body": [ + "class ${1:MyClass}", + "{", + "public:", + "\t$1();", + "\t$1($1 &&) = default;", + "\t$1(const $1 &) = default;", + "\t$1 &operator=($1 &&) = default;", + "\t$1 &operator=(const $1 &) = default;", + "\t~$1();", + "", + "private:", + "\t$2", + "};", + "", + "$1::$1()", + "{", + "}", + "", + "$1::~$1()", + "{", + "}" + ], + "description": "Code snippet for class" + }, + "classi": { + "prefix": "classi", + "body": [ + "class ${1:MyClass}", + "{", + "public:", + "\t$1() = default;", + "\t$1($1 &&) = default;", + "\t$1(const $1 &) = default;", + "\t$1 &operator=($1 &&) = default;", + "\t$1 &operator=(const $1 &) = default;", + "\t~$1() = default;", + "", + "private:", + "\t$2", + "};" + ], + "description": "Code snippet for class with inline constructor/destructor" + }, + "interface": { + "prefix": "interface", + "body": ["__interface I${1:Interface}", "{", "\t$0", "};"], + "description": "Code snippet for interface (Visual C++)" + }, + "namespace": { + "prefix": "namespace", + "body": ["namespace ${1:MyNamespace}", "{", "\t$0", "}"] + }, + "#ifdef": { + "prefix": "#ifdef", + "body": ["#ifdef ${1:DEBUG}", "$0", "#endif // ${DEBUG}"], + "description": "Code snippet for #ifdef" + }, + "#ifndef": { + "prefix": "#ifndef", + "body": ["#ifndef ${1:DEBUG}", "$0", "#endif // !$1"], + "description": "Code snippet for #ifndef" + }, + "#if": { + "prefix": "#if", + "body": ["#if ${1:0}", "$0", "#endif // $1"], + "description": "Code snippet for #if" + }, + "struct": { + "prefix": "struct", + "body": ["struct ${1:MyStruct}", "{", "\t$0", "};"], + "description": "Code snippet for struct" + }, + "switch": { + "prefix": "switch", + "body": ["switch (${1:switch_on}) {", "\tdefault:", "\t\t$0", "\t\tbreak;", "}"], + "description": "Code snippet for switch statement" + }, + "try": { + "prefix": "try", + "body": [ + "try {", + "\t", + "}", + "catch (const std::exception&)", + "{", + "\t$1", + "}" + ], + "description": "Code snippet for try catch" + }, + "union": { + "prefix": "union", + "body": ["union ${1:MyUnion}", "{", "\t$0", "};"], + "description": "Code snippet for union" + }, + "printf": { + "prefix": "printf", + "body": ["printf(\"$1\\n\"$0);"], + "description": "Generic printf() snippet" + }, + "sprintf": { + "prefix": "sprintf", + "body": ["sprintf($1, \"$2\\n\"$0);"], + "description": "Generic sprintf() snippet" + }, + "fprintf": { + "prefix": "fprintf", + "body": ["fprintf(${1:stderr}, \"$2\\n\"$0);"], + "description": "Generic fprintf() snippet" + }, + "scanf": { + "prefix": "scanf", + "body": ["scanf(\"$1\"$0);"], + "description": "Generic scanf() snippet" + }, + "sscanf": { + "prefix": "sscanf", + "body": ["sscanf($1, \"$2\"$0);"], + "description": "Generic sscanf() snippet" + }, + "fscanf": { + "prefix": "fscanf", + "body": ["fscanf($1, \"$2\"$0);"], + "description": "Generic fscanf() snippet" + }, + "#inc": { + "prefix": "#inc", + "body": ["#include \"$0\""], + "description": "Code snippet for #include \" \"" + }, + "#inc<": { + "prefix": "#inc<", + "body": ["#include <$0>"], + "description": "Code snippet for #include < >" + }, + "#def": { + "prefix": "def", + "body": ["#define $0"], + "description": "Code snippet for #define \" \"" + }, + "Main function template": { + "prefix": "main", + "body": [ + "int main (int argc, char *argv[])", + "{", + "\t$0", + "\treturn 0;", + "}" + ], + "description": "A standard main function for a C++ program" + } +} diff --git a/snippets/css.json b/snippets/css.json new file mode 100644 index 0000000..294af23 --- /dev/null +++ b/snippets/css.json @@ -0,0 +1,651 @@ +{ + "align-items": { + "prefix": "ai", + "body": "align-items: ${1|flex-start,flex-end,center,baseline,stretch,start,end,self-start,self-end|};", + "description": "initial value: stretch" + }, + "align-items: baseline": { + "prefix": "aib", + "body": "align-items: baseline;" + }, + "align-items: center": { + "prefix": "aic", + "body": "align-items: center;" + }, + "align-items: flex-start": { + "prefix": "aifs", + "body": "align-items: flex-start;" + }, + "align-items: flex-end": { + "prefix": "aife", + "body": "align-items: flex-end;" + }, + "align-items: stretch": { + "prefix": "ais", + "body": "align-items: stretch;" + }, + "align-self": { + "prefix": "as", + "body": "align-items: ${1|flex-start,flex-end,center,baseline,stretch,auto|};", + "description": "initial value: auto" + }, + "animation": { + "prefix": "ani", + "body": "animation: ${1:name} ${2:1s} ${3|linear,ease-in-out,ease,ease-in,ease-out,step-start,step-end,steps,cubic-bezier|};", + "description": "animation: name duration timing-function delay direction count fill-mode play-state" + }, + "animation-delay": { + "prefix": "anide", + "body": "animation-delay: ${0:1s};" + }, + "animation-direction": { + "prefix": "anidi", + "body": "animation-direction: ${1|alternate,alternate-reverse,reverse,normal|};", + "description": "initial value: normal" + }, + "animation-duratuion": { + "prefix": "anidu", + "body": "animation-duration: ${0:1s};" + }, + "animation-fill-mode": { + "prefix": "anifm", + "body": "animation-fill-mode: ${1|forwards,backwards,both,none|};", + "description": "initial value: none" + }, + "animation-iteration-count": { + "prefix": "aniic", + "body": "animation-iteration-count: ${0:infinite};", + "description": "initial value: 1" + }, + "animation-name": { + "prefix": "anin", + "body": "animation-name: ${0:name};" + }, + "animation-play-state": { + "prefix": "anips", + "body": "animation-play-state: ${1|paused,running|};", + "description": "initial value: running" + }, + "animation-timing-function": { + "prefix": "anitf", + "body": "animation-timing-function: ${1|linear,ease,ease-in-out,ease-in,ease-out,step-start,step-end,steps,cubic-bezier|};", + "description": "initial value: ease" + }, + "background": { + "prefix": "bg", + "body": "background: ${0:#fff};", + "description": "background: image position/size repeat attachment box box" + }, + "background-attachment": { + "prefix": "bga", + "body": "background-attachment: ${1|fixed,scroll,local|};", + "description": "initial value: scroll" + }, + "background-color": { + "prefix": "bgc", + "body": "background-color: ${0:#fff};" + }, + "background-clip": { + "prefix": "bgcl", + "body": "background-clip: ${1|border-box,padding-box,content-box,text|};", + "description": "initial value: border-box" + }, + "background-image": { + "prefix": "bgi", + "body": "background-image: url('${0:background.jpg}');" + }, + "background-origin": { + "prefix": "bgo", + "body": "background-origin: ${1|border-box,padding-box,content-box|};", + "description": "initial value: padding-box" + }, + "background-position": { + "prefix": "bgp", + "body": "background-position: ${1:left} ${2:top};" + }, + "background-repeat": { + "prefix": "bgr", + "body": "background-repeat: ${1|no-repeat,repeat-x,repeat-y,repeat,space,round|};", + "description": "initial value: repeat" + }, + "background-repeat: repeat": { + "prefix": "bgrr", + "body": "background-repeat: repeat;" + }, + "background-repeat: repeat-x": { + "prefix": "bgrx", + "body": "background-repeat: repeat-x;" + }, + "background-repeat: repeat-y": { + "prefix": "bgry", + "body": "background-repeat: repeat-y;" + }, + "background-repeat: no-repeat": { + "prefix": "bgrn", + "body": "background-repeat: no-repeat;" + }, + "background-size": { + "prefix": "bgs", + "body": "background-size: ${0:cover};" + }, + "border": { + "prefix": "bor", + "body": "border: ${1:1px} ${2|solid,dashed,dotted,double,groove,ridge,inset,outset,none,hidden|} ${0:#000};" + }, + "border: none": { + "prefix": "born", + "body": "border: none;" + }, + "border-color": { + "prefix": "borc", + "body": "border-color: ${0:#000};" + }, + "border-style": { + "prefix": "bors", + "body": "border-style: ${1|solid,dashed,dotted,double,groove,ridge,inset,outset,none,hidden|};" + }, + "border-width": { + "prefix": "borw", + "body": "border-width: ${0:1px};" + }, + "border-bottom": { + "prefix": "borb", + "body": "border-bottom: ${1:1px} ${2|solid,dashed,dotted,double,groove,ridge,inset,outset,none,hidden|} ${0:#000};" + }, + "border-left": { + "prefix": "borl", + "body": "border-left: ${1:1px} ${2|solid,dashed,dotted,double,groove,ridge,inset,outset,none,hidden|} ${0:#000};" + }, + "border-right": { + "prefix": "borr", + "body": "border-right: ${1:1px} ${2|solid,dashed,dotted,double,groove,ridge,inset,outset,none,hidden|} ${0:#000};" + }, + "border-top": { + "prefix": "bort", + "body": "border-top: ${1:1px} ${2|solid,dashed,dotted,double,groove,ridge,inset,outset,none,hidden|} ${0:#000};" + }, + "border-radius": { + "prefix": "br", + "body": "border-radius: ${0:2px};" + }, + "bottom": { + "prefix": "bot", + "body": "bottom: ${0:0};" + }, + "box-shadow": { + "prefix": "bos", + "body": "box-shadow: ${1:1px} ${2:1px} ${3:1px} ${4:1px} ${0:rgba(0, 0, 0, .5)};", + "description": "box-shadow: x-offset y-offset blur spread color" + }, + "box-sizing": { + "prefix": "boz", + "body": "box-sizing: ${1|border-box,content-box|};", + "description": "initial value: content-box" + }, + "clear": { + "prefix": "clr", + "body": "clear: ${1|both,left,right,none|};" + }, + "color": { + "prefix": "col", + "body": "color: ${0:#000};" + }, + "content": { + "prefix": "con", + "body": "content: '$0';" + }, + "cursor": { + "prefix": "cur", + "body": "cursor: ${1|auto,default,alias,cell,copy,crosshair,context-menu,help,grab,grabbing,move,none,no-drop,not-allowed,pointer,progress,e-resize,all-scroll,text,wait,vertical-text,zoom-in,zoom-out|};", + "description": "initial value: auto" + }, + "cursor: pointer": { + "prefix": "curp", + "body": "cursor: pointer;" + }, + "cursor: default": { + "prefix": "curd", + "body": "cursor: default;" + }, + "display": { + "prefix": "dis", + "body": "display: ${1|none,block,inline,inline-block,flex,inline-flex,list-item,table,inline-table,table-caption,table-cell,table-row,table-row-group,table-column|};" + }, + "display: block": { + "prefix": "disb", + "body": "display: block;" + }, + "display: inline-block": { + "prefix": "disi", + "body": "display: inline-block;" + }, + "display: none": { + "prefix": "disn", + "body": "display: none;" + }, + "display: flex": { + "prefix": "disf", + "body": "display: flex;" + }, + "flex": { + "prefix": "flex", + "body": "flex: ${1:1} ${2:1} ${3:auto};", + "description": "flex: grow shrink basis" + }, + "flex (alt)": { + "prefix": "fle", + "body": "flex: ${1:1} ${2:1} ${3:auto};" + }, + "flex-direction": { + "prefix": "fld", + "body": "flex-direction: ${1|row,row-reverse,column,column-reverse|};", + "description": "initial value: row" + }, + "flex-direction: row": { + "prefix": "fldr", + "body": "flex-direction: row;" + }, + "flex-direction: column": { + "prefix": "fldc", + "body": "flex-direction: column;" + }, + "flex-flow": { + "prefix": "flf", + "body": "flex-flow: ${1|row,row-reverse,column,column-reverse|} ${2|wrap,wrap-reverse,nowrap|};" + }, + "flex-wrap": { + "prefix": "flw", + "body": "flex-wrap: ${1|wrap,wrap-reverse,nowrap|};", + "description": "initial value: nowrap" + }, + "float": { + "prefix": "fl", + "body": "float: ${1|left,right,none|};" + }, + "float: left": { + "prefix": "fll", + "body": "float: left;" + }, + "float: right": { + "prefix": "flr", + "body": "float: right;" + }, + "float: none": { + "prefix": "fln", + "body": "float: none;" + }, + "font-family": { + "prefix": "ff", + "body": "font-family: ${0:arial};" + }, + "font-size": { + "prefix": "fz", + "body": "font-size: ${0:12px};" + }, + "font-style": { + "prefix": "fst", + "body": "font-style: ${1|italic,oblique,normal|};" + }, + "font-style: italic": { + "prefix": "fsti", + "body": "font-style: italic;" + }, + "font-style: normal": { + "prefix": "fstn", + "body": "font-style: normal;" + }, + "font-style: oblique": { + "prefix": "fsto", + "body": "font-style: oblique;" + }, + "font-weight": { + "prefix": "fw", + "body": "font-weight: ${0:bold};" + }, + "font-weight: bold": { + "prefix": "fwb", + "body": "font-weight: bold;" + }, + "font-weight: light": { + "prefix": "fwl", + "body": "font-weight: light;" + }, + "font-weight: normal": { + "prefix": "fwn", + "body": "font-weight: normal;" + }, + "font": { + "prefix": "ft", + "body": "font: ${0:12px/1.5};", + "description": "font: [weight style variant stretch] size/line-height family" + }, + "height": { + "prefix": "hei", + "body": "height: ${0:1px};" + }, + "justify-content": { + "prefix": "jc", + "body": "justify-content: ${1|flex-start,flex-end,center,space-between,space-around|};", + "description": "initial value: flex-start" + }, + "justify-content: flex-start": { + "prefix": "jcfs", + "body": "justify-content: flex-start;" + }, + "justify-content: flex-end": { + "prefix": "jcfe", + "body": "justify-content: flex-end;" + }, + "justify-content: center": { + "prefix": "jcc", + "body": "justify-content: center;" + }, + "justify-content: space-around": { + "prefix": "jcsa", + "body": "justify-content: space-around;" + }, + "justify-content: space-between": { + "prefix": "jcsb", + "body": "justify-content: space-between;" + }, + "list-style": { + "prefix": "lis", + "body": "list-style: ${1|disc,circle,square,decimal,lower-roman,upper-roman,lower-alpha,upper-alpha,none,armenian,cjk-ideographic,georgian,lower-greek,hebrew,hiragana,hiragana-iroha,katakana,katakana-iroha,lower-latin,upper-latin|} ${2|outside,inside|};", + "description": "list-style: type position image" + }, + "list-style-position": { + "prefix": "lisp", + "body": "${1|outside,inside|}", + "description": "initial value: outside" + }, + "list-style-type": { + "prefix": "list", + "body": "list-style-type: ${1|disc,circle,square,decimal,lower-roman,upper-roman,lower-alpha,upper-alpha,none,armenian,cjk-ideographic,georgian,lower-greek,hebrew,hiragana,hiragana-iroha,katakana,katakana-iroha,lower-latin,upper-latin|};", + "description": "initial value: disc" + }, + "list-style-type: circle": { + "prefix": "listc", + "body": "list-style-type: circle;" + }, + "list-style-type: disc": { + "prefix": "listd", + "body": "list-style-type: disc;" + }, + "list-style-type: none": { + "prefix": "listn", + "body": "list-style-type: none;" + }, + "list-style-type: square": { + "prefix": "lists", + "body": "list-style-type: square;" + }, + "list-style-type: lower-roman": { + "prefix": "listlr", + "body": "list-style-type: lower-roman;" + }, + "list-style-type: upper-roman": { + "prefix": "listur", + "body": "list-style-type: upper-roman;" + }, + "left": { + "prefix": "lef", + "body": "left: ${0:0};" + }, + "line-height": { + "prefix": "lh", + "body": "line-height: ${0:1.5};" + }, + "letter-spacing": { + "prefix": "ls", + "body": "letter-spacing: ${0:2px};" + }, + "letter-spacing: normal": { + "prefix": "lsn", + "body": "letter-spacing: normal;" + }, + "margin": { + "prefix": "mar", + "body": "margin: ${0:0};" + }, + "margin-bottom": { + "prefix": "marb", + "body": "margin-bottom: ${0:0};" + }, + "margin-left": { + "prefix": "marl", + "body": "margin-left: ${0:0};" + }, + "margin-right": { + "prefix": "marr", + "body": "margin-right: ${0:0};" + }, + "margin-top": { + "prefix": "mart", + "body": "margin-top: ${0:0};" + }, + "margin: 0 auto": { + "prefix": "mara", + "body": "margin: 0 auto;" + }, + "min-height": { + "prefix": "mih", + "body": "min-height: ${0:1px};" + }, + "min-width": { + "prefix": "miw", + "body": "min-width: ${0:1px};" + }, + "max-height": { + "prefix": "mah", + "body": "max-height: ${0:1px};" + }, + "max-width": { + "prefix": "maw", + "body": "max-width: ${0:1px};" + }, + "opacity": { + "prefix": "opa", + "body": "opacity: ${0:0};" + }, + "overflow": { + "prefix": "ov", + "body": "overflow: ${1|visible,hidden,scroll,auto,clip|};" + }, + "overflow: auto": { + "prefix": "ova", + "body": "overflow: auto;" + }, + "overflow: hidden": { + "prefix": "ovh", + "body": "overflow: hidden;" + }, + "overflow: scroll": { + "prefix": "ovs", + "body": "overflow: scroll;" + }, + "overflow: visible": { + "prefix": "ovv", + "body": "overflow: visible;" + }, + "padding": { + "prefix": "pad", + "body": "padding: ${0:0};" + }, + "padding-bottom": { + "prefix": "padb", + "body": "padding-bottom: ${0:0};" + }, + "padding-left": { + "prefix": "padl", + "body": "padding-left: ${0:0};" + }, + "padding-right": { + "prefix": "padr", + "body": "padding-right: ${0:0};" + }, + "padding-top": { + "prefix": "padt", + "body": "padding-top: ${0:0};" + }, + "position": { + "prefix": "pos", + "body": "position: ${1|relative,absolute,fixed,sticky,static|};" + }, + "position absolute": { + "prefix": "posa", + "body": "position: absolute;" + }, + "position fixed": { + "prefix": "posf", + "body": "position: fixed;" + }, + "position relative": { + "prefix": "posr", + "body": "position: relative;" + }, + "position sticky": { + "prefix": "poss", + "body": "position: sticky;" + }, + "right": { + "prefix": "rig", + "body": "right: ${0:0};" + }, + "text-align": { + "prefix": "ta", + "body": "text-align: ${1|center,left,right,justify,start,end|};" + }, + "text-align: center": { + "prefix": "tac", + "body": "text-align: center;" + }, + "text-align: left": { + "prefix": "tal", + "body": "text-align: left;" + }, + "text-align: right": { + "prefix": "tar", + "body": "text-align: right;" + }, + "text-decoration": { + "prefix": "td", + "body": "text-decoration: ${1|none,underline,overline,line-through|};" + }, + "text-decoration: underline": { + "prefix": "tdu", + "body": "text-decoration: underline;" + }, + "text-decoration: none": { + "prefix": "tdn", + "body": "text-decoration: none;" + }, + "text-decoration: line-through": { + "prefix": "tdl", + "body": "text-decoration: line-through;" + }, + "text-indent": { + "prefix": "ti", + "body": "text-indent: ${0:2em};" + }, + "text-shadow": { + "prefix": "ts", + "body": "text-shadow: ${1:1px} ${2:1px} ${3:1px} ${4:1px} ${0:rgba(0, 0, 0, .5)};", + "description": "text-shadow: x-offset y-offset blur spread color" + }, + "text-transform": { + "prefix": "tt", + "body": "text-transform: ${1|capitalize,uppercase,lowercase,full-width,none|};" + }, + "top": { + "prefix": "top", + "body": "top: ${0:0};" + }, + "vertical-align": { + "prefix": "va", + "body": "vertical-align: ${1|baseline,middle,top,bottom,sub,super,text-top,text-bottom|};" + }, + "vertical-align: bottom": { + "prefix": "vab", + "body": "vertical-align: bottom;" + }, + "vertical-align: middle": { + "prefix": "vam", + "body": "vertical-align: middle;" + }, + "vertical-align: top": { + "prefix": "vat", + "body": "vertical-align: top;" + }, + "visibility": { + "prefix": "vis", + "body": "visibility: ${1|visible,hidden,collapse|};" + }, + "visibility: visible": { + "prefix": "visv", + "body": "visibility: visible;" + }, + "visibility: hidden": { + "prefix": "vish", + "body": "visibility: hidden;" + }, + "word-break": { + "prefix": "wb", + "body": "word-break: ${1|break-all,keep-all,break-word,normal|};" + }, + "width": { + "prefix": "wid", + "body": "width: ${0:0};" + }, + "width: auto": { + "prefix": "wida", + "body": "width: auto;" + }, + "white-space": { + "prefix": "ws", + "body": "white-space: ${1|nowrap,pre,pre-wrap,pre-line,normal|};" + }, + "white-space: nowrap": { + "prefix": "wsn", + "body": "white-space: nowrap;" + }, + "white-space: pre": { + "prefix": "wsp", + "body": "white-space: pre;" + }, + "word-wrap": { + "prefix": "ww", + "body": "word-wrap: ${1|break-word,break-spaces,normal|};" + }, + "z-index": { + "prefix": "zi", + "body": "z-index: ${0:-1};" + }, + "@import": { + "prefix": "imp", + "body": "@import '${0:filename}';" + }, + "@mixin": { + "prefix": "mix", + "body": "@mixin ${1:name} {\n $0\n}" + }, + "@include": { + "prefix": "inc", + "body": "@include ${0:mixin};" + }, + "@keyframes": { + "prefix": "key", + "body": "@keyframes ${1:name} {\n $0\n}" + }, + "@media": { + "prefix": "med", + "body": "@media screen and (${1:max-width: 300px}) {\n $0\n}" + }, + "!important": { + "prefix": "!", + "body": "!important" + }, + "!important (alt)": { + "prefix": "i", + "body": "!important" + } +} diff --git a/snippets/frameworks/django/filetemplates.json b/snippets/frameworks/django/filetemplates.json new file mode 100644 index 0000000..c6561f3 --- /dev/null +++ b/snippets/frameworks/django/filetemplates.json @@ -0,0 +1,35 @@ +{ + "Django URLFile Template":{ + "prefix": "fturl", + "body": [ + "from django.urls import path", + "from . import views as v", + "\n\napp_name = ${1:AppName}", + "urlpatterns = [", + "\t# TODO: Define $1 URLs here", + "\t${0}", + "]" + ], + "description": "Django File-Template Sinppet For ``URL`` File" + }, + "Django FormFile Template":{ + "prefix": "ftform", + "body": [ + "from django import forms", + "from ${1:.models} import ${2}", + "\n\n# TODO: Create your forms here", + "${0}" + ], + "description": "Django File-Template Sinppet For ``Form`` File" + }, + "Django CustomTagsFile Template":{ + "prefix": "ftcutomtags", + "body": [ + "from django import template", + "\nregister = template.Library()", + "\n# TODO: Create your custom tags here", + "${0}" + ], + "description": "Django File-Template Sinppet For ``CustomTags`` File" + } +} diff --git a/snippets/frameworks/django/forms.json b/snippets/frameworks/django/forms.json new file mode 100644 index 0000000..5b2c319 --- /dev/null +++ b/snippets/frameworks/django/forms.json @@ -0,0 +1,168 @@ +{ + "Django Simple Form ":{ + "prefix": "sform", + "body": [ + "class ${1:Name}Form(forms.Form):", + "\t# Define $1Form fields here", + "\t${0}" + ], + "description": "Django Simple Form" + }, + "Django Model Form ":{ + "prefix": "modelform", + "body": [ + "class ${1:ModelName}Form(forms.ModelForm):", + "\tclass Meta:", + "\t\tmodel = ${2:$1}", + "\t\tfields = (${3:\"__all__\"})", + "\t\t${0}" + ], + "description": "Django Model Form" + }, + "Forms BooleanField":{ + "prefix": "fbool", + "body": "${1:FIELDNAME} = forms.BooleanField(${2})", + "description": "Django forms ``BooleanField``" + }, + "Forms CharField":{ + "prefix": "fchar", + "body": "${1:FIELDNAME} = forms.CharField(${2})", + "description": "Django forms ``CharField``" + }, + "Forms ComboField":{ + "prefix": "fcombo", + "body": "${1:FIELDNAME} = forms.ComboField(${2})", + "description": "Django forms ``ComboField``" + }, + "Forms DateField":{ + "prefix": "fdate", + "body": "${1:FIELDNAME} = forms.DateField(${2})", + "description": "Django forms ``DateField``" + }, + "Forms DateTime":{ + "prefix": "fdatetime", + "body": "${1:FIELDNAME} = forms.DateTime(${2})", + "description": "Django forms ``DateTime``" + }, + "Forms DecimalField":{ + "prefix": "fdecimal", + "body": "${1:FIELDNAME} = forms.DecimalField(${2})", + "description": "Django forms ``DecimalField``" + }, + "Forms DurationField":{ + "prefix": "fduration", + "body": "${1:FIELDNAME} = forms.DurationField(${2})", + "description": "Django forms ``DurationField``" + }, + "Forms EmailField":{ + "prefix": "femail", + "body": "${1:FIELDNAME} = forms.EmailField(${2})", + "description": "Django forms ``EmailField``" + }, + "Forms FileField":{ + "prefix": "ffile", + "body": "${1:FIELDNAME} = forms.FileField(${2})", + "description": "Django forms ``FileField``" + }, + "Forms FilePathField":{ + "prefix": "ffilepath", + "body": "${1:FIELDNAME} = forms.FilePathField(${2})", + "description": "Django forms ``FilePathField``" + }, + "Forms FloatField":{ + "prefix": "ffloat", + "body": "${1:FIELDNAME} = forms.FloatField(${2})", + "description": "Django forms ``FloatField``" + }, + "Forms GenericIPAddressField":{ + "prefix": "fgip", + "body": "${1:FIELDNAME} = forms.GenericIPAddressField(${2})", + "description": "Django forms ``GenericIPAddressField``" + }, + "Forms GenericIPAddressField":{ + "prefix": "fgip", + "body": "${1:FIELDNAME} = forms.GenericIPAddressField(${2})", + "description": "Django forms ``GenericIPAddressField``" + }, + "Forms ImageField":{ + "prefix": "fimg", + "body": "${1:FIELDNAME} = forms.ImageField(${2})", + "description": "Django forms ``ImageField``" + }, + "Forms IntegerField":{ + "prefix": "fint", + "body": "${1:FIELDNAME} = forms.IntegerField(${2})", + "description": "Django forms ``IntegerField``" + }, + "Forms IPAddressField":{ + "prefix": "fip", + "body": "${1:FIELDNAME} = forms.IPAddressField(${2})", + "description": "Django forms ``IPAddressField``" + }, + "Forms ModelChoiceField":{ + "prefix": "fmochoice", + "body": "${1:FIELDNAME} = forms.ModelChoiceField(${2})", + "description": "Django forms ``ModelChoiceField``" + }, + "Forms ModelMultipleChoiceField":{ + "prefix": "fmomuchoice", + "body": "${1:FIELDNAME} = forms.ModelMultipleChoiceField(${2})", + "description": "Django forms ``ModelMultipleChoiceField``" + }, + "Forms MultipleChoiceField":{ + "prefix": "fmuchoice", + "body": "${1:FIELDNAME} = forms.MultipleChoiceField(${2})", + "description": "Django forms ``MultipleChoiceField``" + }, + "Forms MultipleValueField":{ + "prefix": "fmuvalue", + "body": "${1:FIELDNAME} = forms.MultipleValueField(${2})", + "description": "Django forms ``MultipleValueField``" + }, + "Forms NullBooleanField":{ + "prefix": "fnullbool", + "body": "${1:FIELDNAME} = forms.NullBooleanField(${2})", + "description": "Django forms ``NullBooleanField``" + }, + "Forms RegexField":{ + "prefix": "fregex", + "body": "${1:FIELDNAME} = forms.RegexField(${2})", + "description": "Django forms ``RegexField``" + }, + "Forms SlugField":{ + "prefix": "fslug", + "body": "${1:FIELDNAME} = forms.SlugField(${2})", + "description": "Django forms ``SlugField``" + }, + "Forms SplitDateTime":{ + "prefix": "fsdatetime", + "body": "${1:FIELDNAME} = forms.SplitDateTime(${2})", + "description": "Django forms ``SplitDateTime`` Field" + }, + "Forms TimeField":{ + "prefix": "ftime", + "body": "${1:FIELDNAME} = forms.TimeField(${2})", + "description": "Django forms ``TimeField``" + }, + "Forms TypedChoiceField":{ + "prefix": "ftchoice", + "body": "${1:FIELDNAME} = forms.TypedChoiceField(${2})", + "description": "Django forms ``TypedChoiceField``" + }, + "Forms TypedMultipleChoiceField":{ + "prefix": "ftmuchoice", + "body": "${1:FIELDNAME} = forms.TypedMultipleChoiceField(${2})", + "description": "Django forms ``TypedMultipleChoiceField``" + }, + "Forms URLField":{ + "prefix": "fulr", + "body": "${1:FIELDNAME} = forms.URLField(${2})", + "description": "Django forms ``URLField``" + }, + "Forms UUIDField":{ + "prefix": "fuuid", + "body": "${1:FIELDNAME} = forms.UUIDField(${2})", + "description": "Django forms ``UUIDField``" + } + +} diff --git a/snippets/frameworks/django/imports.json b/snippets/frameworks/django/imports.json new file mode 100644 index 0000000..d099fb9 --- /dev/null +++ b/snippets/frameworks/django/imports.json @@ -0,0 +1,43 @@ +{ + "Import forms":{ + "prefix": "di-forms", + "body": "from django import forms", + "description": "Import Django ``forms``" + }, + "Import models":{ + "prefix": "di-model", + "body": "from django import models", + "description": "Import Django ``models``" + }, + "Import get_user_model":{ + "prefix": "di-getusermodel", + "body": "from django.contrib.auth import get_user_model", + "description": "Import Django ``get_user_model``" + }, + "Import generic views":{ + "prefix": "di-generic", + "body": "from django.views import generic", + "description": "Import Django ``generic``" + }, + "Import JsonResponse":{ + "prefix": "di-jsonresponse", + "body": "from django.http import JsonResponse", + "description": "Import Django ``JsonResponse``" + }, + "Import reverse":{ + "prefix": "di-reverse", + "body": "from django.urls import reverse", + "description": "Import Django ``reverse``" + }, + "Import reverse_lazy":{ + "prefix": "di-reverse_lazy", + "body": "from django.urls import revers_lazy", + "description": "Import Django ``revers_lazy``" + }, + + "Import messages":{ + "prefix": "di-messages", + "body": "from django.contrib import messages", + "description": "Import Django ``messages``" + } +} diff --git a/snippets/frameworks/django/models.json b/snippets/frameworks/django/models.json new file mode 100644 index 0000000..c0b656c --- /dev/null +++ b/snippets/frameworks/django/models.json @@ -0,0 +1,183 @@ +{ + "Django Simple Model": { + "prefix": "smodel", + "body": [ + "class ${1:ModelName}(models.Model):", + "\t# Define $1 fields here", + "\t${2}", + "\n\tclass Meta:", + "\t\tordering = [\"${3:-pk}\"]", + "\t\tverbose_name = \"${4:$1}\"", + "\t\tverbose_name_plural = \"${5:$1s}\"", + "\n\tdef __str__(self):", + "\t\treturn ${6:super().__str__()}", + "\n\t# Define $1 properties here", + "\t${0}" + ], + "description": "Django Simple Model with properties and attributes" + }, + "Django Full Model": { + "prefix": "model", + "body": [ + "class ${1:ModelName}(models.Model):", + "\t# Define $1 fields here", + "\t${2}", + "\n\tclass Meta:", + "\t\tordering = [\"${3:-pk}\"]", + "\t\tverbose_name = \"${4:$1}\"", + "\t\tverbose_name_plural = \"${5:$1s}\"", + "\n\tdef __str__(self):", + "\t\treturn ${6:super().__str__()}", + "\n\tdef save(self, *args, **kwargs):", + "\t\treturn ${7:super().save(*args, **kwargs)}", + "\n\tdef get_absolute_url(self):", + "\t\treturn reverse('${8:view_or_url_name}', kwargs={${9:'pk'}: ${10: self.pk}})", + "\n\t# Define $1 properties here", + "\t${0}" + ], + "description": "Django Full Model with properties and attributes" + }, + + "Models AutoField":{ + "prefix": "mauto", + "body": "${1:FIELDNAME} = models.AutoField(${2})", + "description": "Django model ``AutoField``" + }, + "Models BigIntegerField":{ + "prefix": "mbigint", + "body": "${1:FIELDNAME} = models.AutoField(${2})", + "description": "Django model ``AutoField``" + }, + "Models BinaryField":{ + "prefix": "mbinary", + "body": "${1:FIELDNAME} = models.BinaryField(${2})", + "description": "Django model ``BinaryField``" + }, + "Models Boolean":{ + "prefix": "mbool", + "body": "${1:FIELDNAME} = models.BooleanField(default=${2:False})", + "description": "Django model ``BooleanField``" + }, + "Models CharField":{ + "prefix": "mchar", + "body": "${1:FieldName} = models.CharField(max_length=${2:32})", + "description": "Django model ``CharField``" + }, + "Models CommaSeparatedIntegerField":{ + "prefix": "mcomma", + "body": "${1:FIELDNAME} = models.CommaSeparatedIntegerField(max_length=${2})", + "description": "Django model ``CommaSeparatedIntegerField``" + }, + "Models DateField":{ + "prefix": "mdate", + "body": "${1:FIELDNAME} = models.DateField(auto_now_add=${2:True}, auto_now=${3:False}})", + "description": "Django model ``DateField``" + }, + "Models DateTimeField":{ + "prefix": "mdatetime", + "body": "${1:FIELDNAME} = models.DateTimeField(auto_now_add=${2:True}, auto_now=${3:False})", + "description": "Django model ``DateTimeField``" + }, + "Models DecimalField":{ + "prefix": "mdecimal", + "body": "${1:FIELDNAME} = models.DecimalField(max_digits=${2}, decimal_places=${3})", + "description": "Django model ``DecimalField``" + }, + "Models EmailField":{ + "prefix": "memail", + "body": "${1:FIELDNAME} = models.EmailField(${2})", + "description": "Django model ``EmailField``" + }, + "Models FileField":{ + "prefix": "mfile", + "body": "${1:FIELDNAME} = models.FileField(upload_to=${2:path/for/upload})", + "description": "Django model ``FileField``" + }, + "Models FilePathField":{ + "prefix": "mfilepath", + "body": "${1:FIELDNAME} = models.FilePathField(path=${2:\"/abs/path/to/dir\"}${3:, max_length=100}${4:, match=\"*.ext\"}${4:, recursive=True})", + "description": "Django model ``FilePathField``" + }, + "Models FloatField":{ + "prefix": "mfloat", + "body": "${1:FIELDNAME} = models.FloatField(${2})", + "description": "Django model ``FloatField``" + }, + "Models ImageField":{ + "prefix": "mimg", + "body": "${1:FIELDNAME} = models.ImageField(upload_to=${2:path/for/upload}${3:, height_field=height, width_field=width}${4:, max_length=100})", + "description": "Django model ``ImageField``" + }, + "Models IntegerField":{ + "prefix": "mint", + "body": "${1:FIELDNAME} = models.IntegerField(${2})", + "description": "Django model ``IntegerField``" + }, + "Models IPAddressField":{ + "prefix": "mip", + "body": "${1:FIELDNAME} = models.IPAddressField(${2})", + "description": "Django model ``IPAddressField``" + }, + "Models NullBooleanField":{ + "prefix": "mnullboolean", + "body": "${1:FIELDNAME} = models.NullBooleanField(${2})", + "description": "Django model ``NullBooleanField``" + }, + "Models PositiveIntegerField":{ + "prefix": "mposint", + "body": "${1:FIELDNAME} = models.PositiveIntegerField(${2})", + "description": "Django model ``PositiveIntegerField``" + }, + "Models PositiveSmallIntegerField":{ + "prefix": "mpossmallint", + "body": "${1:FIELDNAME} = models.PositiveSmallIntegerField(${2})", + "description": "Django model ``PositiveSmallIntegerField``" + }, + "Models SlugField":{ + "prefix": "mslug", + "body": "${1:FIELDNAME} = models.SlugField(${2})", + "description": "Django model ``SlugField``" + }, + "Models SmallIntegerField":{ + "prefix": "msmallint", + "body": "${1:FIELDNAME} = models.SmallIntegerField(${2})", + "description": "Django model ``SmallIntegerField``" + }, + "Models TextField":{ + "prefix": "mtext", + "body": "${1:FIELDNAME} = models.TextField(${2})", + "description": "Django model ``TextField``" + }, + "Models TimeField":{ + "prefix": "mtime", + "body": "${1:FIELDNAME} = models.TimeField(auto_now_add=${2:True}, auto_now=${3:False})", + "description": "Django model ``TimeField``" + }, + "Models URLField":{ + "prefix": "murl", + "body": "${1:FIELDNAME} = models.URLField(verify_exists=${2:False})", + "description": "Django model ``URLField``" + }, + "Models XMLField":{ + "prefix": "mxml", + "body": "${1:FIELDNAME} = models.XMLField(schema_path=${2:None})", + "description": "Django model ``XMLField``" + }, + + "Models ForeignKey":{ + "prefix": "fk", + "body": "${1:FIELDNAME} = models.ForeignKey(${2:OtherModel}, on_delete=models.${3:CASCADE}, related_name=\"${4:RelatedName}\" ${0:, limit_choices_to=})", + "description": "Django model ``ForeignKey``" + }, + "Models ManyToManyField":{ + "prefix": "m2m", + "body": "${1:FIELDNAME} = models.ManyToManyField(${2:OtherModel}, related_name=\"${3:RelatedName}\" ${0:, limit_choices_to=})", + "description": "Django model ``ManyToManyField``" + }, + "Models OneToOneField":{ + "prefix": "o2o", + "body": "${1:FIELDNAME} = models.OneToOneField(${2:OtherModel}, related_name=\"${4:RelatedName}\"${0:, to_field=''})", + "description": "Django model ``OneToOneField``" + } +} + diff --git a/snippets/frameworks/django/views.json b/snippets/frameworks/django/views.json new file mode 100644 index 0000000..4faa917 --- /dev/null +++ b/snippets/frameworks/django/views.json @@ -0,0 +1,243 @@ +{ + "Django CreateView":{ + "prefix": "createview", + "body": [ + "class ${1:ModelName}CreateView(generic.CreateView):", + "\tmodel = ${2:$1}", + "\ttemplate_name = \"${3:$1/$1_form.html}\"", + "\tform_class = ${4:forms.$1Form}", + "\tsuccess_url = \"${5:.}\"" + ], + "description": "Django CBV ``CreateView``" + }, + "Django UpdateView":{ + "prefix": "updateview", + "body": [ + "class ${1:ModelName}UpdateView(generic.UpdateView):", + "\tmodel = ${2:$1}", + "\ttemplate_name = \"${3:$1/$1_form.html}\"", + "\tform_class = ${4:forms.$1Form}", + "\tsuccess_url = \"${5:.}\"", + "\n\tdef get_object(self):", + "\t\treturn $1.objects.get(pk=${6:self.kwargs.get(\"pk\")})" + ], + "description": "Django CBV ``UpdateView``" + }, + "Django DeleteView":{ + "prefix": "deleteview", + "body": [ + "class ${1:ModelName}DeleteView(generic.DeleteView):", + "\tmodel = ${2:$1}", + "\n\tdef get_success_url(self):", + "\t\treturn reverse(\"${3:$1:list}\")", + "\n\tdef get(self, request, *args, **kwargs):", + "\t\treturn post(request, *args, **kwargs)" + ], + "description": "Django CBV ``DeleteView``" + }, + "Django DetailView":{ + "prefix": "detailview", + "body": [ + "class ${1:ModelName}DetailView(generic.DetailView):", + "\tmodel = ${2:$1}", + "\ttemplate_name = \"${3:$1/$1_detail.html}\"", + "\n\tdef get_object(self):", + "\t\treturn $1.objects.get(pk=${4:self.kwargs.get(\"pk\")})", + "\n\tdef get_queryset(self):", + "\t\treturn $1.objects.filter(${5})" + ], + "description": "Django CBV ``DetailView``" + }, + "Django ListView":{ + "prefix": "listview", + "body": [ + "class ${1:ModelName}ListView(generic.ListView):", + "\tmodel = ${2:$1}", + "\ttemplate_name = \"${3:$1/$1_list.html}\"", + "\n\tdef get_queryset(self):", + "\t\treturn $1.objects.filter(${4})" + ], + "description": "Django CBV ``ListView``" + }, + "Django TemplateView":{ + "prefix": "templateview", + "body": [ + "class ${1:ModelName}TemplateView(generic.TemplateView):", + "\ttemplate_name = \"${2:$1/$1_list.html}\"", + "\n${3}" + ], + "description": "Django CBV ``TemplateView``" + }, + "Django FormView":{ + "prefix": "formview", + "body": [ + "class ${1:ModelName}FormView(generic.FormView):", + "\tform_class = ${2:forms.$1Form}", + "\ttemplate_name = \"${3}\"" + ], + "description": "Django CBV ``FormView``" + }, + "Django AdminView":{ + "prefix": "adminview", + "body": [ + "@admin.register($1)", + "class ${1:ModelName}Admin(admin.ModelAdmin):", + "\tlist_display = ${2:\"pk\",}", + "\tsearch_fields = ${3:\"pk\",}", + "\tlist_filter = ${4:\"FilterFields\",}" + ], + "description": "Django AdminView for ``admin.py``" + }, + "Django AdminTabularInline":{ + "prefix": "tabularinline", + "body": [ + "class ${1:ModelName}Inline(admin.TabularInline):", + "\tmodel = ${2:$1}", + "\tmin_num = ${4:0}", + "\tmax_num = ${4:8}", + "\textra = ${5:1}" + ], + "description": "Django TabularInline for ``admin.py``" + }, + "Django AdminStackedInline":{ + "prefix": "stackedinline", + "body": [ + "class ${1:ModelName}Inline(admin.StackedInline):", + "\tmodel = ${2:$1}", + "\tmin_num = ${4:0}", + "\tmax_num = ${4:8}", + "\textra = ${5:1}" + ], + "description": "Django StackedInline for ``admin.py``" + }, + + "Django Views get_context_data":{ + "prefix": "getcontextdata", + "body": [ + "def get_context_data(self, *args, **kwargs):", + "\tcontext = super().get_context_data(*args, **kwargs)", + "\treturn context" + ], + "description": "Django Views ``get_context_data`` method" + }, + "Django Views get_success_url":{ + "prefix": "getsuccessurl", + "body": [ + "def get_success_url(self):", + "\treturn reverse(\"${1:ViewName}\", kwargs={${2:\"pk\": self.get_object().pk}})" + ], + "description": "Django Views ``get_success_url`` method" + }, + "Django Views get_queryset":{ + "prefix": "getqueryset", + "body": [ + "def get_queryset(self):", + "\treturn ${1:ModelName}.objects.filter(${2})" + ], + "description": "Django Views ``get_queryset`` method" + }, + "Django Views get_object":{ + "prefix": "getobject", + "body": [ + "def get_object(self):", + "\treturn ${1:ModelName}.objects.get(${2})" + ], + "description": "Django Views ``get_object`` method" + }, + "Django Views form_valid":{ + "prefix": "formvalid", + "body": [ + "def form_valid(self, form):", + "\treturn super().form_valid(form)" + ], + "description": "Django Views ``form_valid`` method" + }, + "Django Views form_invalid":{ + "prefix": "forminvalid", + "body": [ + "def form_invalid(self, form):", + "\treturn super().form_invalid(form)" + ], + "description": "Django Views ``form_invalid`` method" + }, + "Django Views get_form_kwargs":{ + "prefix": "getformkwargs", + "body": [ + "def get_form_kwargs(self, form):", + "\tkwargs = super().get_form_kwargs()", + "\treturn kwargs" + ], + "description": "Django Views ``get_form_kwargs`` method" + }, + "Django Views dispatch":{ + "prefix": "dispatch", + "body": [ + "def dispatch(self, request, *args, **kwargs):", + "\treturn super().dispatch(request, *args, **kwargs)" + ], + "description": "Django Views ``dispatch`` method" + }, + "Django Views get_initial":{ + "prefix": "getinitial", + "body": [ + "def get_initial(self):", + "\tinit = super().get_initial()", + "\treturn init" + ], + "description": "Django Views ``get_initial`` method" + }, + "Django Views post":{ + "prefix": "post", + "body": [ + "def post(self, request, *args, **kwargs):", + "\treturn super().post(request, *args, **kwargs)" + ], + "description": "Django Views ``post`` method" + }, + "Django Views get":{ + "prefix": "get", + "body": [ + "def get(self, request, *args, **kwargs):", + "\treturn super().get(request, *args, **kwargs)" + ], + "description": "Django Views ``post`` method" + }, + + + "Django Forms field_clean":{ + "prefix": "cleanf", + "body": [ + "def clean_${1:FieldName}(self):", + "\t$1 = self.cleaned_data[\"$1\"]", + "\t${0}", + "\treturn $1" + ], + "description": "Django Views ``field_clean`` method" + }, + "Django Forms clean":{ + "prefix": "cleanff", + "body": [ + "def clean(self):", + "\tcleaned_data = super().clean()", + "\t${0}" + ], + "description": "Django Views ``clean`` method" + }, + + + "Django FBV Path":{ + "prefix": "fpath", + "body": "path(\"${1:Path}\", v.${2:View}, name=${0:PathName})", + "description": "Django Path For ``Function Based Views``" + }, + "Django CBV Path":{ + "prefix": "cpath", + "body": "path(\"${1:Path}\", v.${2:View}.as_viewJ(), name=${0:PathName})", + "description": "Django Path For ``Class Based Views``" + }, + "Django Path as Include":{ + "prefix": "ipath", + "body": "path(\"${1:Path}\", include(\"${2}.urls\", namespace=${0:Name})", + "description": "Django Path as ``Include``" + } +} diff --git a/snippets/frameworks/ejs.json b/snippets/frameworks/ejs.json new file mode 100644 index 0000000..477ecf5 --- /dev/null +++ b/snippets/frameworks/ejs.json @@ -0,0 +1,87 @@ +{ + "EJS No Output": { + "prefix": "ejs", + "body": [ + "<% $1 %> $2" + ], + "description": "EJS No Output" + }, + "EJS Output Value": { + "prefix": "ejsout", + "body": [ + "<%= $1 %> $2" + ], + "description": "EJS outputs no value" + }, + "EJS Output Escaped": { + "prefix": "ejsesc", + "body": [ + "<%- $1 %> $2" + ], + "description": "EJS outputs value" + }, + "EJS Comment": { + "prefix": "ejscom", + "body": [ + "<%# $1 %> $2" + ], + "description": "EJS comment tag with no output" + }, + "EJS Literal": { + "prefix": "ejslit", + "body": [ + "<%% $1 %> $2" + ], + "description": "EJS outputs a literal '<%'" + }, + "EJS Include": { + "prefix": "ejsinc", + "body": [ + "<% include $1 %> $2" + ], + "description": "EJS include statement" + }, + "EJS For Loop": { + "prefix": "ejsfor", + "body": [ + "<% for( let ${1:index} = 0; ${1:index} < ${2:array}.length; ${1:index}++ ) { %>", + "$3", + "<% } %>" + ], + "description": "EJS For Loop" + }, + "EJS ForEach": { + "prefix": "ejseach", + "body": [ + "<% ${1:array}.forEach(${2:element} => { %>", + " $3", + "<% }) %>" + ], + "description": "EJS ForEach Loop" + }, + "EJS If Statement": { + "prefix": "ejsif", + "body": [ + "<% if (${1:condition}) { %>", + " $2", + "<% } %>" + ], + "description": "EJS if statement" + }, + "EJS Else Statement": { + "prefix": "ejselse", + "body": [ + "<% } else { %>", + " $1" + ], + "description": "EJS if statement" + }, + "EJS Else If Statement": { + "prefix": "ejselif", + "body": [ + "<% } else if ({$1:condition}) { %>", + " $2" + ], + "description": "EJS if statement" + } +} diff --git a/snippets/frameworks/flutter.json b/snippets/frameworks/flutter.json new file mode 100644 index 0000000..594eeba --- /dev/null +++ b/snippets/frameworks/flutter.json @@ -0,0 +1,498 @@ +{ + "Stateless Widget": { + "prefix": "statelessW", + "body": [ + "class ${1:name} extends StatelessWidget {", + " const ${1:name}({Key? key}) : super(key: key);\n", + " @override", + " Widget build(BuildContext context) {", + " return Container(", + " child: ${2:null},", + " );", + " }", + "}" + ], + "description": "Create a Stateless widget" + }, + "Stateful Widget": { + "prefix": "statefulW", + "body": [ + "class ${1:name} extends StatefulWidget {", + " ${1:name}({Key? key}) : super(key: key);\n", + " @override", + " _${1:WidgetName}State createState() => _${1:WidgetName}State();", + "}\n", + "class _${1:index}State extends State<${1:index}> {", + " @override", + " Widget build(BuildContext context) {", + " return Container(", + " child: ${2:null},", + " );", + " }", + "}" + ], + "description": "Create a Stateful widget" + }, + "Build Method": { + "prefix": "build", + "body": [ + "@override", + "Widget build(BuildContext context) {", + " return ${0:};", + "}" + ], + "description": "Describes the part of the user interface represented by this widget." + }, + "Custom Painter ": { + "prefix": "customPainter", + "body": [ + "class ${0:name}Painter extends CustomPainter {", + "", + " @override", + " void paint(Canvas canvas, Size size) {", + " }", + "", + " @override", + " bool shouldRepaint(${0:name}Painter oldDelegate) => false;", + "", + " @override", + " bool shouldRebuildSemantics(${0:name}Painter oldDelegate) => false;", + "}" + ], + "description": "Used for creating custom paint" + }, + "Custom Clipper ": { + "prefix": "customClipper", + "body": [ + "class ${0:name}Clipper extends CustomClipper {", + "", + " @override", + " Path getClip(Size size) {", + " }", + "", + " @override", + " bool shouldReclip(CustomClipper oldClipper) => false;", + "}" + ], + "description": "Used for creating custom shapes" + }, + "InitState ": { + "prefix": "initS", + "body": [ + "@override", + "void initState() { ", + " super.initState();", + " ${0:}", + "}" + ], + "description": "Called when this object is inserted into the tree. The framework will call this method exactly once for each State object it creates." + }, + "Dispose": { + "prefix": "dis", + "body": [ + "@override", + "void dispose() { ", + " ${0:}", + " super.dispose();", + "}" + ], + "description": "Called when this object is removed from the tree permanently. The framework calls this method when this State object will never build again." + }, + "Reassemble": { + "prefix": "reassemble", + "body": [ + "@override", + "void reassemble(){", + " super.reassemble();", + " ${0:}", + "}" + ], + "description": "Called whenever the application is reassembled during debugging, for example during hot reload." + }, + "didChangeDependencies": { + "prefix": "didChangeD", + "body": [ + "@override", + "void didChangeDependencies() {", + " super.didChangeDependencies();", + " ${0:}", + "}" + ], + "description": "Called when a dependency of this State object changes" + }, + "didUpdateWidget": { + "prefix": "didUpdateW", + "body": [ + "@override", + "void didUpdateWidget (${1:Type} ${2:oldWidget}) {", + " super.didUpdateWidget(${2:oldWidget});", + " ${0:}", + "}" + ], + "description": "Called whenever the widget configuration changes." + }, + "ListView.Builder": { + "prefix": "listViewB", + "body": [ + "ListView.builder(", + " itemCount: ${1:1},", + " itemBuilder: (BuildContext context, int index) {", + " return ${2:};", + " },", + ")," + ], + "description": "Creates a scrollable, linear array of widgets that are created on demand.Providing a non-null `itemCount` improves the ability of the [ListView] to estimate the maximum scroll extent." + }, + "ListView.Separated": { + "prefix": "listViewS", + "body": [ + "ListView.separated(", + " itemCount: ${1:1},", + " separatorBuilder: (BuildContext context, int index) {", + " return ${2:};", + " },", + " itemBuilder: (BuildContext context, int index) {", + " return ${3:};", + " },", + ")," + ], + "description": "Creates a fixed-length scrollable linear array of list 'items' separated by list item 'separators'." + }, + "GridView.Builder": { + "prefix": "gridViewB", + "body": [ + "GridView.builder(", + " gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(", + " crossAxisCount: ${1:2},", + " ),", + " itemCount: ${2:2},", + " itemBuilder: (BuildContext context, int index) {", + " return ${3:};", + " },", + ")," + ], + "description": "Creates a scrollable, 2D array of widgets that are created on demand. Providing a non-null `itemCount` improves the ability of the [GridView] to estimate the maximum scroll extent." + }, + "GridView.Count": { + "prefix": "gridViewC", + "body": [ + "GridView.count(", + " crossAxisSpacing: ${1:1},", + " mainAxisSpacing: ${2:2},", + " crossAxisCount: ${3:2},", + " children: [", + " ${4:}", + " ],", + ")," + ], + "description": "Creates a scrollable, 2D array of widgets with a fixed number of tiles in the cross axis." + }, + "GridView.Extent": { + "prefix": "gridViewE", + "body": [ + "GridView.extent(", + " maxCrossAxisExtent: ${1:2},", + " children: [", + " ${2:}", + " ],", + ")," + ], + "description": "Creates a scrollable, 2D array of widgets with tiles that each have a maximum cross-axis extent." + }, + "Custom Scroll View": { + "prefix": "customScrollV", + "body": [ + "CustomScrollView(", + " slivers: [", + " ${0:}", + " ],", + ")," + ], + "description": "Creates a `ScrollView` that creates custom scroll effects using slivers. If the `primary` argument is true, the `controller` must be null." + }, + "Stream Builder": { + "prefix": "streamBldr", + "body": [ + "StreamBuilder(", + " stream: ${1:stream},", + " initialData: ${2:initialData},", + " builder: (BuildContext context, AsyncSnapshot snapshot) {", + " return Container(", + " child: ${3:child},", + " );", + " },", + ")," + ], + "description": "Creates a new `StreamBuilder` that builds itself based on the latest snapshot of interaction with the specified `stream`" + }, + "Animated Builder": { + "prefix": "animatedBldr", + "body": [ + "AnimatedBuilder(", + " animation: ${1:animation},", + " child: ${2:child},", + " builder: (BuildContext context, Widget child) {", + " return ${3:};", + " },", + ")," + ], + "description": "Creates an Animated Builder. The widget specified to `child` is passed to the `builder` " + }, + "Stateful Builder": { + "prefix": "statefulBldr", + "body": [ + "StatefulBuilder(", + " builder: (BuildContext context, setState) {", + " return ${0:};", + " },", + ")," + ], + "description": "Creates a widget that both has state and delegates its build to a callback. Useful for rebuilding specific sections of the widget tree." + }, + "Orientation Builder": { + "prefix": "orientationBldr", + "body": [ + "OrientationBuilder(", + " builder: (BuildContext context, Orientation orientation) {", + " return Container(", + " child: ${3:child},", + " );", + " },", + ")," + ], + "description": "Creates a builder which allows for the orientation of the device to be specified and referenced" + }, + "Layout Builder": { + "prefix": "layoutBldr", + "body": [ + "LayoutBuilder(", + " builder: (BuildContext context, BoxConstraints constraints) {", + " return ${0:};", + " },", + ")," + ], + "description": "Similar to the Builder widget except that the framework calls the builder function at layout time and provides the parent widget's constraints." + }, + "Single Child ScrollView": { + "prefix": "singleChildSV", + "body": [ + "SingleChildScrollView(", + " controller: ${1:controller,}", + " child: Column(", + " ${0:}", + " ),", + ")," + ], + "description": "Creates a scroll view with a single child" + }, + "Future Builder": { + "prefix": "futureBldr", + "body": [ + "FutureBuilder(", + " future: ${1:Future},", + " initialData: ${2:InitialData},", + " builder: (BuildContext context, AsyncSnapshot snapshot) {", + " return ${3:};", + " },", + ")," + ], + "description": "Creates a Future Builder. This builds itself based on the latest snapshot of interaction with a Future." + }, + "No Such Method": { + "prefix": "nosm", + "body": [ + "@override", + "dynamic noSuchMethod(Invocation invocation) {", + " ${1:}", + "}" + ], + "description": "This method is invoked when a non-existent method or property is accessed." + }, + "Inherited Widget": { + "prefix": "inheritedW", + "body": [ + "class ${1:Name} extends InheritedWidget {", + " ${1:Name}({Key? key, required this.child}) : super(key: key, child: child);", + "", + " final Widget child;", + "", + " static ${1:Name}? of(BuildContext context) {", + " return context.dependOnInheritedWidgetOfExactType<${1:Name}>();", + " }", + "", + " @override", + " bool updateShouldNotify(${1:Name} oldWidget) {", + " return ${2:true};", + " }", + "}" + ], + "description": "Class used to propagate information down the widget tree" + }, + "Mounted": { + "prefix": "mounted", + "body": [ + "@override", + "bool get mounted {", + " ${0:}", + "}" + ], + "description": "Whether this State object is currently in a tree." + }, + "Sink": { + "prefix": "snk", + "body": [ + "Sink<${1:type}> get ${2:name} => _${2:name}Controller.sink;", + "final _${2:name}Controller = StreamController<${1:type}>();" + ], + "description": "A Sink is the input of a stream." + }, + "Stream": { + "prefix": "strm", + "body": [ + "Stream<${1:type}> get ${2:name} => _${2:name}Controller.stream;", + "final _${2:name}Controller = StreamController<${1:type}>();" + ], + "description": "A source of asynchronous data events. A stream can be of any data type " + }, + "Subject": { + "prefix": "subj", + "body": [ + "Stream<${1:type}> get ${2:name} => _${2:name}Subject.stream;", + "final _${2:name}Subject = BehaviorSubject<${1:type}>();" + ], + "description": "A BehaviorSubject is also a broadcast StreamController which returns an Observable rather than a Stream." + }, + "toString": { + "prefix": "toStr", + "body": [ + "@override", + "String toString() {", + "return ${1:toString};", + " }" + ], + "description": "Returns a string representation of this object." + }, + "debugPrint": { + "prefix": "debugP", + "body": [ + "debugPrint(${1:statement});" + ], + "description": "Prints a message to the console, which you can access using the flutter tool's `logs` command (flutter logs)." + }, + "Material Package": { + "prefix": "importM", + "body": "import 'package:flutter/material.dart';", + "description": "Import flutter material package" + }, + "Cupertino Package": { + "prefix": "importC", + "body": "import 'package:flutter/cupertino.dart';", + "description": "Import Flutter Cupertino package" + }, + "flutter_test Package": { + "prefix": "importFT", + "body": "import 'package:flutter_test/flutter_test.dart';", + "description": "Import flutter_test package" + }, + "Material App": { + "prefix": "mateapp", + "description": "Create a MaterialApp", + "body": [ + "import 'package:flutter/material.dart';", + " ", + "void main() => runApp(MyApp());", + " ", + "class MyApp extends StatelessWidget {", + " @override", + " Widget build(BuildContext context) {", + " return MaterialApp(", + " title: 'Material App',", + " home: Scaffold(", + " appBar: AppBar(", + " title: Text('Material App Bar'),", + " ),", + " body: Center(", + " child: Container(", + " child: Text('Hello World'),", + " ),", + " ),", + " ),", + " );", + " }", + "}" + ] + }, + "Cupertino App": { + "prefix": "cupeapp", + "description": "Create a CupertinoApp", + "body": [ + "import 'package:flutter/cupertino.dart';", + " ", + "void main() => runApp(MyApp());", + " ", + "class MyApp extends StatelessWidget {", + " @override", + " Widget build(BuildContext context) {", + " return CupertinoApp(", + " title: 'Cupertino App',", + " home: CupertinoPageScaffold(", + " navigationBar: CupertinoNavigationBar(", + " middle: Text('Cupertino App Bar'),", + " ),", + " child: Center(", + " child: Container(", + " child: Text('Hello World'),", + " ),", + " ),", + " ),", + " );", + " }", + "}" + ] + }, + "Tween Animation Builder": { + "prefix": "tweenAnimationBuilder", + "body": [ + "TweenAnimationBuilder(", + " duration: ${1:const Duration(),}", + " tween: ${2:Tween(),}", + " builder: (BuildContext context, ${3:dynamic} value, Widget? child) {", + " return ${4:Container();}", + " },", + " ), " + ], + "description": "Widget builder that animates a property of a Widget to a target value whenever the target value changes." + }, + "Value Listenable Builder": { + "prefix": "valueListenableBuilder", + "body": [ + "ValueListenableBuilder(", + " valueListenable: ${1: null},", + " builder: (BuildContext context, ${2:dynamic} value, Widget? child) {", + " return ${3: Container();}", + " },", + " )," + ], + "description": "Given a ValueListenable and a builder which builds widgets from concrete values of T, this class will automatically register itself as a listener of the ValueListenable and call the builder with updated values when the value changes." + }, + "Test": { + "prefix": "f-test", + "body": [ + "test(", + " \"${1:test description}\",", + " () {},", + ");" + ], + "description": "Create a test function" + }, + "Test Widgets": { + "prefix": "widgetTest", + "body": [ + "testWidgets(", + " \"${1:test description}\",", + " (WidgetTester tester) async {},", + ");" + ], + "description": "Create a testWidgets function" + } +} \ No newline at end of file diff --git a/snippets/frameworks/jekyll.json b/snippets/frameworks/jekyll.json new file mode 100644 index 0000000..9a11714 --- /dev/null +++ b/snippets/frameworks/jekyll.json @@ -0,0 +1,526 @@ +{ + "Show": { + "prefix": "show", + "description": "Output markup: {{ }}", + "body": "{{ $1 }}" + }, + + "Execute": { + "prefix": "execute", + "description": "Tag markup: {%- -%}", + "body": "{%- $1 -%}" + }, + + "Tag assign": { + "prefix": "assign", + "description": "Variable tag: assign", + "body": [ + "{%- assign ${variable} = ${value} -%}" + ] + }, + + "Tag break": { + "prefix": "break", + "description": "Iteration tag: break", + "body": [ + "{%- break -%}" + ] + }, + + "Tag capture": { + "prefix": "capture", + "description": "Variable tag: capture", + "body": [ + "{%- capture ${variable} -%}${code:}{%- endcapture -%}" + ] + }, + + "Tag case": { + "prefix": "case", + "description": "Control flow tag: case", + "body": [ + "{%- case ${variable} -%}", + "\t{%- when ${condition} -%}", + "\t\t${code1:}", + "\t{%- else -%}", + "\t\t${code2:}", + "{%- endcase -%}" + ] + }, + + "Tag comment": { + "prefix": "comment", + "description": "Control flow tag: case", + "body": [ + "{%- comment -%}${description:}{%- endcomment -%}" + ] + }, + + "Tag context variable": { + "prefix": "convar", + "description": "Context Variable", + "body": [ + "{{ ${variable:} }}" + ] + }, + + "Tag continue": { + "prefix": "continue", + "description": "Iteration tag: continue", + "body": [ + "{%- continue -%}" + ] + }, + + "Tag cycle": { + "prefix": "cycle", + "description": "Iteration tag: cycle", + "body": [ + "{%- cycle '${0:odd}', '${1:even}' -%}" + ] + }, + + "Tag collection directory": { + "prefix": "cdirp", + "description": "The full path to the collection's source direcotry", + "body": [ + "{{ site.${my_collection}.directory }}" + ] + }, + + "Tag collection relative path": { + "prefix": "crelp", + "description": "The path to the document's source file realtive to the site source", + "body": [ + "{{ site.collections.${my_collection}.relative_path }}" + ] + }, + + "Tag decrement": { + "prefix": "decrement", + "description": "Variable tag: decrement", + "body": [ + "{%- decrement ${variable} -%}" + ] + }, + + "Tag for": { + "prefix": "for", + "description": "Iteration tag: for", + "body": [ + "{%- for ${item} in ${collection} -%}", + "\t${code:}", + "{%- endfor -%}" + ] + }, + + "Tag increment": { + "prefix": "increment", + "description": "Variable tag: increment", + "body": [ + "{%- increment ${variable} -%}" + ] + }, + + "Tag if": { + "prefix": "if", + "description": "Control flow tag: if", + "body": [ + "{%- if ${condition} -%}", + "\t${code:}", + "{%- endif -%}" + ] + }, + + "Tag else": { + "prefix": "else", + "description": "Control flow tag: else", + "body": [ + "{%- else -%}" + ] + }, + + "Tag elsif": { + "prefix": "elsif", + "description": "Control flow tag: elsif", + "body": [ + "{%- elsif ${condition} -%}" + ] + }, + + "Tag if else": { + "prefix": "ifelse", + "description": "Control flow tag: if else", + "body": [ + "{%- if ${condition} -%}", + "\t${code1:}", + "{%- else -%}", + "\t${code2:}", + "{%- endif -%}" + ] + }, + + "Tag gist": { + "prefix": "gist", + "description": "Add a gist code block", + "body": [ + "{%- gist ${gist:user/gist-id} -%}" + ] + }, + + "Tag highlight": { + "prefix": "highlight", + "description": "Syntax tag: highlight", + "body": [ + "{%- highlight ${lang:javascript} -%}", + "\t\t${code:}", + "{%- endhighlight -%}" + ] + }, + + "Tag include": { + "prefix": "include", + "description": "Tag: include", + "body": [ + "{%- include ${snippet} -%}" + ] + }, + + "Site Vairable Date": { + "prefix": "date", + "description": "Tag: site.date", + "body": [ + "{{ site.date | date: '${format: %b %d, %Y}' }}" + ] + }, + + "Tag include relative": { + "prefix": "increl", + "description": "Tag: include relative", + "body": [ + "{%- include_relative '${file:}' -%}" + ] + }, + + "Tag Post URL": { + "prefix": "posturl", + "description": "Tag: post_url", + "body": [ + "{%- post_url ${url:} -%}" + ] + }, + + "Tag unless": { + "prefix": "unless", + "description": "Control flow tag: unless", + "body": [ + "{%- unless ${condition} -%}", + "\t${code:}", + "{%- endunless -%}" + ] + }, + + "Tag when": { + "prefix": "when", + "description": "Control flow tag: when", + "body": [ + "{%- when ${condition} -%}", + "${code:}" + ] + }, + + "Tag Option limit": { + "prefix": "limit", + "description": "For loops option", + "body": [ + "limit: ${limit:5}" + ] + }, + + "Tag Option offset": { + "prefix": "offset", + "description": "For loops option", + "body": [ + "offset: ${offset:0}" + ] + }, + + "Tag Option reversed": { + "prefix": "reversed", + "description": "For loops option", + "body": [ + "reversed" + ] + }, + + "Tag raw": { + "prefix": "raw", + "description": "Tag: raw", + "body": [ + "{%- raw -%}${code:}{%- endraw -%}" + ] + }, + + "Tag paginate next or previous page": { + "prefix": "paginate", + "description": "Tag: paginate next or previous page", + "body": [ + "{{ paginator.${next:previous}_page }}" + ] + }, + + "Filter jsonify": { + "prefix": "json", + "description": "Array filter: jsonify", + "body": "| jsonify }}'" + }, + + "Filter join": { + "prefix": "join", + "description": "Array filter: join", + "body": "| join: '${seperator:, }}'" + }, + + "Filter first": { + "prefix": "first", + "description": "Array filter: first", + "body": "| first" + }, + + "Filter last": { + "prefix": "last", + "description": "Array filter: last", + "body": "| last" + }, + + "Filter map": { + "prefix": "map", + "description": "Array filter: map", + "body": "| map: '${key}'" + }, + + "Filter size": { + "prefix": "size", + "description": "Array filter: size", + "body": "| size" + }, + + "Filter sort": { + "prefix": "sort", + "description": "Array filter: sort", + "body": "| sort" + }, + + "Filter uniq": { + "prefix": "uniq", + "description": "Array filter: uniq", + "body": "| uniq" + }, + + "Filter ceil": { + "prefix": "ceil", + "description": "Math filter: ceil", + "body": "| ceil" + }, + + "Filter divided by": { + "prefix": "divided_by", + "description": "Math filter: divided by", + "body": "| divided_by: ${divided_by:2}" + }, + + "Filter floor": { + "prefix": "floor", + "description": "Math filter: floor", + "body": "| floor" + }, + + "Filter minus": { + "prefix": "minus", + "description": "Math filter: minus", + "body": "| minus: ${minus:1}" + }, + + "Filter modulo": { + "prefix": "modulo", + "description": "Math filter: modulo", + "body": "| modulo: ${modulo:2}" + }, + + "Filter plus": { + "prefix": "plus", + "description": "Math filter: plus", + "body": "| plus: ${plus:1}" + }, + + "Filter round": { + "prefix": "round", + "description": "Math filter: round", + "body": "| round: ${round:0}" + }, + + "Filter times": { + "prefix": "times", + "description": "Math filter: times", + "body": "| times: ${times:1}" + }, + + "Filter append": { + "prefix": "append", + "description": "String filter: append", + "body": "| append: '${string}' }}" + }, + + "Filter capitalize": { + "prefix": "capitalize", + "description": "String filter: capitalize", + "body": "| capitalize }}" + }, + + "Filter downcase": { + "prefix": "downcase", + "description": "String filter: downcase", + "body": "| downcase }}" + }, + + "Filter escape": { + "prefix": "escape", + "description": "String filter: escape", + "body": "| escape }}" + }, + + "Filter markdownify": { + "prefix": "markdown", + "description": "String filter: markdownify", + "body": "| markdownify }}" + }, + + "Filter prepend": { + "prefix": "prepend", + "description": "String filter: prepend", + "body": "| prepend: '${string}' }}" + }, + + "Filter remove": { + "prefix": "remove", + "description": "String filter: remove", + "body": "| remove: '${string}' }}" + }, + + "Filter remove first": { + "prefix": "remove_first", + "description": "String filter: remove first", + "body": "| remove_first: '${string}' }}" + }, + + "Filter replace": { + "prefix": "replace", + "description": "String filter: replace", + "body": "| replace: '${target}', '${replace}' }}" + }, + + "Filter replace first": { + "prefix": "replace_first", + "description": "String filter: replace first", + "body": "| replace_first: '${target}', '${replace}' }}" + }, + + "Filter slice": { + "prefix": "slice", + "description": "String filter: slice", + "body": "| slice: ${from:0}, ${to:5} }}" + }, + + "Filter slice single character": { + "prefix": "slice_single", + "description": "String filter: slice with single parameter", + "body": "| slice: ${at} }}" + }, + + "Filter split": { + "prefix": "split", + "description": "String filter: split", + "body": "| split: '${splitter:,}' }}" + }, + + "Filter strip": { + "prefix": "strip", + "description": "String filter: strip", + "body": "| strip }}" + }, + + "Filter lstrip": { + "prefix": "lstrip", + "description": "String filter: lstrip", + "body": "| lstrip }}" + }, + + "Filter rstrip": { + "prefix": "rstrip", + "description": "String filter: rstrip", + "body": "| rstrip }}" + }, + + "Filter strip html": { + "prefix": "strip_html", + "description": "String filter: strip html", + "body": "| strip_html }}" + }, + + "Filter strip newlines": { + "prefix": "strip_newlines", + "description": "String filter: strip newlines", + "body": "| strip_newlines }}" + }, + + "Filter truncate": { + "prefix": "truncate", + "description": "String filter: truncate", + "body": "| truncate: ${length:20}, '${ellipsis:...}' }}" + }, + + "Filter truncatewords": { + "prefix": "truncatewords", + "description": "String filter: truncatewords", + "body": "| truncatewords: ${length:5}, '${ellipsis:...}' }}" + }, + + "Filter upcase": { + "prefix": "upcase", + "description": "String filter: upcase }}", + "body": "| upcase }}" + }, + + "Filter url encode": { + "prefix": "url_encode", + "description": "String filter: url encode", + "body": "| url_encode }}" + }, + + "Filter uri escape": { + "prefix": "uri_escape", + "description": "String filter: uri escape", + "body": "| uri_escape }}" + }, + + "Filter xml escape": { + "prefix": "xml_escape", + "description": "String filter: xml escape", + "body": "| xml_escape }}" + }, + + "Front Matter": { + "prefix": "fm", + "description": "Add front matter", + "body": [ + "---", + "layout: ${layout:default}", + "title: ${title}", + "categories: ${category}", + "permalink: ${path}", + "tags: ${tag}", + "excerpt: ${description}", + "---" + ] + } +} diff --git a/snippets/frameworks/rails.json b/snippets/frameworks/rails.json new file mode 100644 index 0000000..db095a9 --- /dev/null +++ b/snippets/frameworks/rails.json @@ -0,0 +1,294 @@ +{ + "Before action": { + "prefix": "ba", + "body": [ + "before_action :${0:method}" + ], + "description": "before_action" + }, + "Before validation": { + "prefix": "bv", + "body": [ + "before_validation :${0:method}" + ], + "description": "before_validation" + }, + "Before create": { + "prefix": "bc", + "body": [ + "before_create :${0:method}" + ], + "description": "before_create" + }, + "Before update": { + "prefix": "bu", + "body": [ + "before_update :${0:method}" + ], + "description": "before_update" + }, + "Before save": { + "prefix": "bs", + "body": [ + "before_save :${0:method}" + ], + "description": "before_save" + }, + "Before destroy": { + "prefix": "bd", + "body": [ + "before_destroy :${0:method}" + ], + "description": "before_destroy" + }, + "After create": { + "prefix": "ac", + "body": [ + "after_create :${0:method}" + ], + "description": "after_create" + }, + "After validation": { + "prefix": "av", + "body": [ + "after_validation :${0:method}" + ], + "description": "after_validation" + }, + " update": { + "prefix": "au", + "body": [ + "after_update :${0:method}" + ], + "description": "after_update" + }, + " save": { + "prefix": "as", + "body": [ + "after_save :${0:method}" + ], + "description": "after_create" + }, + " destroy": { + "prefix": "ad", + "body": [ + "after_destroy :${0:method}" + ], + "description": "after_destroy" + }, + "Belongs to": { + "prefix": "bt", + "body": [ + "belongs_to :${0:association}" + ], + "description": "belongs_to assocation" + }, + "Belongs to polymorphic": { + "prefix": "btp", + "body": [ + "belongs_to :${0:association}, polymorphic: true" + ], + "description": "belongs_to polymorphic assocation" + }, + "Create action": { + "prefix": "create", + "body": [ + "def create", + "\t@${1:model_class_name} = ${2:ModelClassName}.new($1_params)", + "\trespond_to do |format|", + "\t\tif @$1.save", + "\t\t\tformat.html { redirect_to @$1, notice: '$2 created' }", + "\t\telse", + "\t\t\tformat.html { render :new, status: :unprocessable_entity }", + "\t\tend", + "\tend", + "end" + ], + "description": "def create" + }, + "Destroy action": { + "prefix": "destroy", + "body": [ + "def destroy", + "\t@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])", + "\t@$1.destroy!", + "\tredirect_to $1s_path, notice: '$2 removed'", + "end" + ], + "description": "def destroy" + }, + "Edit action": { + "prefix": "edit", + "body": [ + "def edit", + "\t@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])", + "end" + ], + "description": "def edit" + }, + "Index action": { + "prefix": "index", + "body": [ + "def index", + "\t@${1:model_class_name} = ${2:ModelClassName}.all", + "end" + ], + "description": "def index" + }, + "New action": { + "prefix": "new", + "body": [ + "def new", + "\t@${1:model_class_name} = ${2:ModelClassName}.new", + "end" + ], + "description": "def new" + }, + "Show action": { + "prefix": "show", + "body": [ + "def show", + "\t@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])", + "end" + ], + "description": "def show" + }, + "Update action": { + "prefix": "update", + "body": [ + "def update", + "\t@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])", + "\trespond_to do |format|", + "\t\tif @$1.update($1_params)", + "\t\t\tformat.html { redirect_to @$1, notice: '$2 updated' }", + "\t\telse", + "\t\t\tformat.html { render :edit, status: :unprocessable_entity }", + "\t\tend", + "\tend", + "end" + ], + "description": "def update" + }, + "Model Params": { + "prefix": "params", + "body": [ + "def ${1:model_class_name}_params", + "\tparams.require(:$1).permit(${2:attributes})", + "end" + ], + "description": "def model_params" + }, + "Getting Params": { + "prefix": "pa", + "body": [ + "params[:${1:id}]" + ], + "description": "getting params using attribute" + }, + "Delegate to": { + "prefix": "dt", + "body": [ + "delegate: :${1:method}, to: :${0:object}" + ], + "description": "delegate to" + }, + "Delegate to with prefix": { + "prefix": "dtp", + "body": [ + "delegate: :${1:method}, to: :${2:object}, prefix: :${3:prefix}, allow_nil: ${0:allow_nil}" + ], + "description": "delegate to" + }, + "Scope": { + "prefix": "scope", + "body": [ + "scope :${1:name}, -> { where(${2:field}: ${0:value}) }" + ], + "description": "AR scope" + }, + "Validate presence": { + "prefix": "vp", + "body": [ + "validates :${1:attribute}, presence: true" + ], + "description": "validates presence" + }, + "Validate uniqueness": { + "prefix": "vu", + "body": [ + "validates :${1:attribute}, uniqueness: true" + ], + "description": "validates presence" + }, + "Migration add column": { + "prefix": "mac", + "body": [ + "add_column :${1:table_name}, :${2:column_name}, :${0:data_type}" + ], + "description": "Migration add column" + }, + "Migration add index": { + "prefix": "mai", + "body": [ + "add_index :${1:table_name}, :${0:column_name}" + ], + "description": "Migration add index" + }, + "Migration remove column": { + "prefix": "mrc", + "body": [ + "remove_column :${1:table_name}, :${0:column_name}" + ], + "description": "Migration remove column" + }, + "Migration rename column": { + "prefix": "mrnc", + "body": [ + "rename_column :${1:table_name}, :${2:old_column_name}, :${0:new_column_name}" + ], + "description": "Migration rename column" + }, + "Migration change column": { + "prefix": "mcc", + "body": [ + "change_column :${1:table_name}, :${2:old_column_name}, :${0:data_type}" + ], + "description": "Migration change column" + }, + "Has many dependent": { + "prefix": "hmd", + "body": [ + "has_many :${1:object}, dependent: :${0:destroy}" + ], + "description": "has_many dependent" + }, + "Has many": { + "prefix": "hm", + "body": [ + "has_many :${0:object}" + ], + "description": "has_many association" + }, + "Has many through": { + "prefix": "hmt", + "body": [ + "has_many :${1:object}, through: :${0:object}" + ], + "description": "has_many through association" + }, + "Has one": { + "prefix": "ho", + "body": [ + "has_one :${0:object}" + ], + "description": "has_one association" + }, + "Has one dependent": { + "prefix": "hod", + "body": [ + "has_one :${1:object}, dependent: :${0:destroy}" + ], + "description": "has_one dependent" + } +} + diff --git a/snippets/frameworks/twig.json b/snippets/frameworks/twig.json new file mode 100644 index 0000000..b9a7469 --- /dev/null +++ b/snippets/frameworks/twig.json @@ -0,0 +1,536 @@ +{ + "asset": { + "prefix": "asset", + "body": + "{% set asset = ${1:entry.assetFieldHandle}.one() %}\n\n{% if asset %}\n\t\"{{\n{% endif %}", + "description": "asset" + }, + "assets": { + "prefix": "assets", + "body": + "{% for image in craft.assets.\n\t.sourceId(\"${1:1}\")\n\t.kind(\"${2:image}\")\n\t.limit(${3:10})\n}).all() %}\n\t\"{{\n{% endfor %}\n$0", + "description": "craft.assets" + }, + "autoescape": { + "prefix": "autoescape", + "body": "{% autoescape \"${1:type}\" %}\n\t$0\n{% endautoescape %}", + "description": "autoescape" + }, + "blockb": { + "prefix": "blockb", + "body": "{% block ${1:name} %}\n\t$0\n{% endblock %}", + "description": "block (block)" + }, + "block": { + "prefix": "block", + "body": "{% block ${1:name} %}$0{% endblock %}", + "description": "block" + }, + "blockf": { + "prefix": "blockf", + "body": "{{ block(\"${1:name}\") }}$0", + "description": "blockf" + }, + "cache": { + "prefix": "cache", + "body": "{% cache %}\n\t$1\n{% endcache %}\n$0", + "description": "cache" + }, + "case": { + "prefix": "case", + "body": "{% case \"${1:value}\" %}\n\t$0", + "description": "case" + }, + "children": { + "prefix": "children", + "body": "{% children %}$0", + "description": "children" + }, + "ceil": { + "prefix": "ceil", + "body": "ceil($1)$0", + "description": "ceil" + }, + "assetso": { + "prefix": "assetso", + "body": + "{% set assets = craft.assets({\n\tsourceId: \"${1:1}\",\n\tkind: \"${2:image}\",\n\tlimit: ${3:10}\n}).all() %}\n\n{% for image in assets %}\n\t\"{{\n{% endfor %}\n$0", + "description": "craft.assets - object syntax" + }, + "categorieso": { + "prefix": "categorieso", + "body": + "{% set categories = craft.categories({\n\tgroup: \"${1:categoryGroupHandle}\",\n\tlimit: \"${2:11}\"\n}).all() %}\n\n
    \n\t{% nav category in categories %}\n\t\t
  • \n\t\t\t{{ category.title }}\n\t\t\t{% ifchildren %}\n\t\t\t\t
      \n\t\t\t\t\t{% children %}\n\t\t\t\t
    \n\t\t\t{% endifchildren %}\n\t\t
  • \n\t{% endnav %}\n
", + "description": "craft.categories - object syntax" + }, + "categories": { + "prefix": "categories", + "body": + "
    \n\t{% nav category in craft.categories\n\t\t.group(\"${1:categoryGroupHandle}\")\n\t\t.limit(${2:11})\n\t\t.all()\n\t%}\n\t\t
  • \n\t\t\t{{ category.title }}\n\t\t\t{% ifchildren %}\n\t\t\t\t
      \n\t\t\t\t\t{% children %}\n\t\t\t\t
    \n\t\t\t{% endifchildren %}\n\t\t
  • \n\t{% endnav %}\n
", + "description": "craft.categories" + }, + "entrieso": { + "prefix": "entrieso", + "body": + "{% set entries = craft.entries({\n\tsection: \"${1:sectionName}\",\n\tlimit: \"${2:10}\"\n}).all() %}\n\n{% for entry in entries %}\n\t{{ entry.title }}\n{% endfor %}\n$0", + "description": "craft.entries - object syntax" + }, + "entries": { + "prefix": "entries", + "body": + "{% for entry in craft.entries\n\t.section(\"${1:sectionName}\")\n\t.limit(${2:10})\n\t.all()\n%}\n\t{{ entry.title }}\n{% endfor %}\n$0", + "description": "craft.entries" + }, + "t": { + "prefix": "t", + "body": "{{ $1 | t }}$0", + "description": "translate with | t" + }, + "replace": { + "prefix": "replace", + "body": "{{ ${1:$TM_SELECTED_TEXT} | replace(\"search\", \"replace\") }}$0", + "description": "replace with | replace(\"search\", \"replace\")" + }, + "replacex": { + "prefix": "replacex", + "body": + "{{ ${1:$TM_SELECTED_TEXT} | replace(\"/(search)/i\", \"replace\") }}$0", + "description": "replace regex with | replace(\"/(search)/i\", \"replace\")" + }, + "split": { + "prefix": "split", + "body": "{{ ${1:$TM_SELECTED_TEXT} | split(\"\\n\") }}$0", + "description": "split on | split (\"\\n\")" + }, + "tagso": { + "prefix": "tagso", + "body": + "{% set tags = craft.tags({\n\tgroup: \"${1:tagGroupHandle}\"\n}).all() %}\n\n
    \n\t{% for tag in tags %}\n\t\t
  • {{ tag }}
  • \n\t{% endfor %}\n
\n$0", + "description": "craft.tags - object syntax" + }, + "tags": { + "prefix": "tags", + "body": + "
    \n\t{% for tag in craft.tags.group(\"${1:tagGroupHandle}\").all() %}\n\t\t
  • {{ tag }}
  • \n\t{% endfor %}\n
\n$0", + "description": "craft.tags" + }, + "userso": { + "prefix": "userso", + "body": + "{% set users = craft.users({\n\tgroup: \"${1:userGroupHandle}\"\n}).all() %}\n\n{% for user in users %}\n\t{{ user.firstName }} {{ user.lastName }}\n{% endfor %}\n$0", + "description": "craft.users - object syntax" + }, + "users": { + "prefix": "users", + "body": + "{% for user in craft.users.group(\"${1:userGroupHandle}\").all() %}\n\t{{ user.firstName }} {{ user.lastName }}\n{% endfor %}\n$0", + "description": "craft.users" + }, + "csrf": { + "prefix": "csrf", + "body": "{{ csrfInput() }}\n$0", + "description": "csrf" + }, + "dd": { + "prefix": "dd", + "body": "
\n\t{{ dump($1) }}\n
\n{% exit %}$0", + "description": "dump and die" + }, + "do": { + "prefix": "do", + "body": "{% do $1 %}$0", + "description": "do" + }, + "dojs": { + "prefix": "dojs", + "body": "{% do view.registerJsFile \"${1:url}\" %}$0", + "description": "do js" + }, + "docss": { + "prefix": "docss", + "body": "{% do view.registerCssFile \"${1:url}\" %}$0", + "description": "do css" + }, + "dump": { + "prefix": "dump", + "body": "
\n\t{{ dump($1) }}\n
", + "description": "dump" + }, + "else": { + "prefix": "else", + "body": "{% else %}\n\t$0", + "description": "else" + }, + "embed": { + "prefix": "embed", + "body": "{% embed \"${1:template}\" %}\n\t$0\n{% endembed %}", + "description": "embed" + }, + "endautoescape": { + "prefix": "endautoescape", + "body": "{% endautoescape %}$0", + "description": "endautoescape" + }, + "endblock": { + "prefix": "endblock", + "body": "{% endblock %}$0", + "description": "endblock" + }, + "endcache": { + "prefix": "endcache", + "body": "{% endcache %}$0", + "description": "endcache" + }, + "endembed": { + "prefix": "endembed", + "body": "{% endembed %}$0", + "description": "endembed" + }, + "endfilter": { + "prefix": "endfilter", + "body": "{% endfilter %}$0", + "description": "endfilter" + }, + "endfor": { + "prefix": "endfor", + "body": "{% endfor %}$0", + "description": "endfor" + }, + "endif": { + "prefix": "endif", + "body": "{% endif %}$0", + "description": "endif" + }, + "endifchildren": { + "prefix": "endifchildren", + "body": "{% endifchildren %}$0", + "description": "endifchildren" + }, + "endcss": { + "prefix": "endcss", + "body": "{% endcss %}$0", + "description": "endcss" + }, + "endjs": { + "prefix": "endjs", + "body": "{% endjs %}$0", + "description": "endjs" + }, + "endmacro": { + "prefix": "endmacro", + "body": "{% endmacro %}$0", + "description": "endmacro" + }, + "endnav": { + "prefix": "endnav", + "body": "{% endnav %}$0", + "description": "endnav" + }, + "endset": { + "prefix": "endset", + "body": "{% endset %}$0", + "description": "endset" + }, + "endspaceless": { + "prefix": "endspaceless", + "body": "{% endspaceless %}$0", + "description": "endspaceless" + }, + "endswitch": { + "prefix": "endswitch", + "body": "{% endswitch %}$0", + "description": "endswitch" + }, + "endtrans": { + "prefix": "endtrans", + "body": "{% endtrans %}$0", + "description": "endtrans" + }, + "endverbatim": { + "prefix": "endverbatim", + "body": "{% endverbatim %}$0", + "description": "endverbatim" + }, + "exit": { + "prefix": "exit", + "body": "{% exit ${1:404} %}", + "description": "exit" + }, + "extends": { + "prefix": "extends", + "body": "{% extends \"${1:template}\" %}$0", + "description": "extends" + }, + "filterb": { + "prefix": "filterb", + "body": "{% filter ${1:name} %}\n\t$0\n{% endfilter %}", + "description": "filter (block)" + }, + "filter": { + "prefix": "filter", + "body": "{% filter ${1:name} %}$0{% endfilter %}", + "description": "filter" + }, + "floor": { + "prefix": "floor", + "body": "floor($1)$0", + "description": "floor" + }, + "fore": { + "prefix": "fore", + "body": + "{% for ${1:item} in ${2:items} %}\n\t$3\n{% else %}\n\t$0\n{% endfor %}", + "description": "for ... else" + }, + "for": { + "prefix": "for", + "body": "{% for ${1:item} in ${2:items} %}\n\t$0\n{% endfor %}", + "description": "for" + }, + "from": { + "prefix": "from", + "body": "{% from \"${1:template}\" import \"${2:macro}\" %}$0", + "description": "from" + }, + "endbody": { + "prefix": "endbody", + "body": "{{ endBody() }}\n$0", + "description": "endBody" + }, + "head": { + "prefix": "head", + "body": "{{ head() }}\n$0", + "description": "head" + }, + "if": { + "prefix": "if", + "body": "{% if ${1:condition} %}$2{% endif %}\n$0", + "description": "if" + }, + "ifb": { + "prefix": "ifb", + "body": "{% if ${1:condition} %}\n\t$0\n{% endif %}", + "description": "if (block)" + }, + "ife": { + "prefix": "ife", + "body": "{% if ${1:condition} %}\n\t$2\n{% else %}\n\t$0\n{% endif %}", + "description": "if ... else" + }, + "if1": { + "prefix": "if", + "body": "{% if ${1:condition} %}$0{% endif %}", + "description": "if" + }, + "ifchildren": { + "prefix": "ifchildren", + "body": "{% ifchildren %}\n\t$1\n{% endifchildren %}\n$0", + "description": "ifchildren" + }, + "import": { + "prefix": "import", + "body": "{% import \"${1:template}\" as ${2:name} %}$0", + "description": "import" + }, + "importself": { + "prefix": "importself", + "body": "{% import _self as ${1:name} %}$0", + "description": "importself" + }, + "inckv": { + "prefix": "inckv", + "body": + "{% include \"${1:template}\" with {\n\t${2:key}: ${3:\"${4:value}\"}\n} %}\n$0", + "description": "include w/ key/value" + }, + "include": { + "prefix": "include", + "body": "{% include \"${1:template}\" %}$0", + "description": "include" + }, + "inc": { + "prefix": "inc", + "body": "{% include \"${1:template}\" %}$0", + "description": "inc" + }, + "incp": { + "prefix": "incp", + "body": "{% include \"${1:template}\"${2: with ${3:params} }%}$0", + "description": "include w/ params" + }, + "css1": { + "prefix": "css", + "body": "{% do view.registerCssFile(\"${1:/resources/css/global.css}\") %}\n$0", + "description": "registerCssFile" + }, + "js": { + "prefix": "js", + "body": "{% js %}\n\t$1\n{% endjs %}\n$0", + "description": "js" + }, + "js1": { + "prefix": "js", + "body": "{% do view.registerJsFile(\"${1:/resources/js/global.js}\") %}\n$0", + "description": "registerJsFile" + }, + "css": { + "prefix": "css", + "body": "{% css %}\n\t$1\n{% endcss %}\n$0", + "description": "css" + }, + "macro": { + "prefix": "macro", + "body": "{% macro ${1:name}(${2:params}) %}\n\t$0\n{% endmacro %}", + "description": "macro" + }, + "matrix": { + "prefix": "matrix", + "body": + "{% for block in ${1:entry.matrixFieldHandle}.all() %}\n\n\t{% if block.type == \"${2:blockHandle}\" %}\n\t\t{{ block.${3:fieldHandle} }}\n\t{% endif %}\n\n\t{% if block.type == \"${4:blockHandle}\" %}\n\t\t{{ block.${5:fieldHandle} }}\n\t{% endif %}\n\n{% endfor %}\n$0", + "description": "matrix" + }, + "matrixif": { + "prefix": "matrixif", + "body": + "{% for block in ${1:entry.matrixFieldHandle}.all() %}\n\n\t{% if block.type == \"${2:blockHandle}\" %}\n\t\t{{ block.${3:fieldHandle} }}\n\t{% endif %}\n\n\t{% if block.type == \"${4:blockHandle}\" %}\n\t\t{{ block.${5:fieldHandle} }}\n\t{% endif %}\n\n{% endfor %}\n$0", + "description": "matrixif" + }, + "matrixifelse": { + "prefix": "matrixifelse", + "body": + "{% for block in ${1:entry.matrixFieldHandle}.all() %}\n\n\t{% if block.type == \"${2:blockHandle}\" %}\n\n\t\t{{ block.${3:fieldHandle} }}\n\n\t{% elseif block.type == \"${4:blockHandle}\" %}\n\n\t\t$0\n\t\n\t{% endif %}\n\n{% endfor %}", + "description": "matrixifelse" + }, + "matrixswitch": { + "prefix": "matrixswitch", + "body": + "{% for block in ${1:entry.matrixFieldHandle}.all() %}\n\n\t{% switch block.type %}\n\n\t\t{% case \"${2:blockHandle}\" %}\n\n\t\t\t{{ block.${3:fieldHandle} }}\n\n\t\t{% case \"${4:blockHandle}\" %}\n\n\t\t\t$0\n\n\t{% endswitch %}\n\n{% endfor %}", + "description": "matrixswitch" + }, + "max": { + "prefix": "max", + "body": "max(${1:$2, $3})$0", + "description": "max" + }, + "min": { + "prefix": "min", + "body": "min(${1:$2, $3})$0", + "description": "min" + }, + "nav": { + "prefix": "nav", + "body": "{% nav ${1:item} in ${2:items} %}\n\t$3\n{% endnav %}\n$0", + "description": "nav" + }, + "paginate": { + "prefix": "paginate", + "body": + "{% paginate ${1:elements} as ${2:pageInfo}, ${3:pageEntries} %}\n\n{% for item in ${3:pageEntries} %}\n\t$0\n{% endfor %}\n\n{% if ${2:pageInfo}.prevUrl %}Previous Page{% endif %}\n{% if ${2:pageInfo}.nextUrl %}Next Page{% endif %}", + "description": "paginate simple" + }, + "paginate1": { + "prefix": "paginate", + "body": + "{# PAGINATION\n\t\t\nFor this pagination to work properly, we need to be sure to set\nthe paginateBase variable in the template we are including the \npagination in.\n\n{% set paginateBase = \"/blog/p\" %}\n#}\n\n{% if pageInfo.totalPages > 1 %}\n
    \n\t{% if pageInfo.currentPage != \"1\" %}\n\t\t
  • First Page
  • \n\t{% endif %}\n\n\t{% if pageInfo.prevUrl %}\n\t\t
  • Previous Page
  • \n\t{% endif %}\n\n\t{% for pageNumber in 1..pageInfo.totalPages %}\n\t\t
  • \n\t\t\t{{ pageNumber }}\n\t\t
  • \n\t{% endfor %}\n\n\t{% if pageInfo.nextUrl %}\n\t\t
  • Next Page
  • \n\t{% endif %}\n\n\t{% if pageInfo.currentPage != pageInfo.total %}\n\t\t
  • Last Page
  • \n\t{% endif %}\n
\n{% endif %}\n$0", + "description": "paginate advanced" + }, + "redirect": { + "prefix": "redirect", + "body": + "{% redirect \"${1:template/path or http://straightupcraft.com}\" %}\n$0", + "description": "redirect" + }, + "getparam": { + "prefix": "getparam", + "body": + "craft.app.request.getParam(${1:\"Query String or Post Variable Name\"})\n$0", + "description": "request getParam" + }, + "getbodyparam": { + "prefix": "getbodyparam", + "body": "craft.app.request.getBodyParam(${1:\"postVariableName\"})\n$0", + "description": "request getBodyParam" + }, + "getqueryparam": { + "prefix": "getqueryparam", + "body": "craft.app.request.getQueryParam(${1:\"queryStringName\"})\n$0", + "description": "request getQueryParam" + }, + "getsegment": { + "prefix": "getsegment", + "body": "craft.app.request.getSegment(${1:2})\n$0", + "description": "request getSegment" + }, + "requirelogin": { + "prefix": "requirelogin", + "body": "{% requireLogin %}\n$0", + "description": "requireLogin" + }, + "requirepermission": { + "prefix": "requirepermission", + "body": "{% requirePermission \"${1:spendTheNight}\" %}\n$0", + "description": "requirePermission" + }, + "round": { + "prefix": "round", + "body": "{{ $1 | round(1, 'floor') }}$0", + "description": "round" + }, + "setb": { + "prefix": "setb", + "body": "{% set ${1:var} %}\n\t$0\n{% endset %}", + "description": "set (block)" + }, + "set": { + "prefix": "set", + "body": "{% set ${1:var} = ${2:value} %}$0", + "description": "set" + }, + "shuffle": { + "prefix": "shuffle", + "body": "shuffle($1)$0", + "description": "shuffle" + }, + "random": { + "prefix": "random", + "body": "random($1)$0", + "description": "random" + }, + "spaceless": { + "prefix": "spaceless", + "body": "{% spaceless %}\n\t$0\n{% endspaceless %}", + "description": "spaceless" + }, + "switch": { + "prefix": "switch", + "body": + "{% switch ${1:variable} %}\n\n\t{% case \"${2:value1}\" %}\n\t\n\n\t{% case \"${3:value2}\" %}\n\t\n\n\t{% default %}\n\t\n\n{% endswitch %}\n$0", + "description": "switch" + }, + "trans": { + "prefix": "trans", + "body": "{% trans %}$0{% endtrans %}", + "description": "trans" + }, + "urla": { + "prefix": "urla", + "body": + "url(\"${1:path}\", ${2:{foo:\"1\", bar:\"2\"\\}}, ${3:\"http\"}, ${4:false})$0", + "description": "url w/ arguments" + }, + "url": { + "prefix": "url", + "body": "url(\"${1:path}\")$0", + "description": "url" + }, + "use": { + "prefix": "use", + "body": "{% use \"${1:template}\" %}$0", + "description": "use" + }, + "verbatim": { + "prefix": "verbatim", + "body": "{% verbatim %}\n\t$0\n{% endverbatim %}", + "description": "verbatim" + } +} diff --git a/snippets/frameworks/vue/html.json b/snippets/frameworks/vue/html.json new file mode 100644 index 0000000..9cb50ff --- /dev/null +++ b/snippets/frameworks/vue/html.json @@ -0,0 +1,397 @@ +{ + "template": { + "prefix": "template", + "body": [ + "" + ], + "description": "template element" + }, + "v-text": { + "prefix": "vText", + "body": [ + "v-text=\"${1:msg}\"" + ], + "description": "Expects: string. Updates the elementโ€™s textContent." + }, + "v-html": { + "prefix": "vHtml", + "body": [ + "v-html=\"${1:html}\"" + ], + "description": "Expects: string. Updates the elementโ€™s innerHTML." + }, + "v-show": { + "prefix": "vShow", + "body": [ + "v-show=\"${1:condition}\"" + ], + "description": "Expects: any" + }, + "v-if": { + "prefix": "vIf", + "body": [ + "v-if=\"${1:condition}\"" + ], + "description": "Expects: any" + }, + "v-else": { + "prefix": "vElse", + "body": [ + "v-else" + ], + "description": "Does not expect expression. previous sibling element must have v-if or v-else-if." + }, + "v-else-if": { + "prefix": "vElseIf", + "body": [ + "v-else-if=\"${1:condition}\"" + ], + "description": "Expects: any. previous sibling element must have v-if or v-else-if." + }, + "v-for-without-key": { + "prefix": "vForWithoutKey", + "body": [ + "v-for=\"${1:item} in ${2:items}\"" + ], + "description": "Expects: Array | Object | number | string" + }, + "v-for": { + "prefix": "vFor", + "body": [ + "v-for=\"(${1:item}, ${2:index}) in ${3:items}\" :key=\"${4:index}\"" + ], + "description": "Expects: Array | Object | number | string" + }, + "v-on": { + "prefix": "vOn", + "body": [ + "v-on:${1:event}=\"${2:handle}\"" + ], + "description": "Expects: Function | Inline Statement" + }, + "v-bind": { + "prefix": "vBind", + "body": [ + "v-bind$1=\"${2}\"" + ], + "description": "Expects: any (with argument) | Object (without argument)" + }, + "v-model": { + "prefix": "vModel", + "body": [ + "v-model=\"${1:something}\"" + ], + "description": "Expects: varies based on value of form inputs element or output of components" + }, + "v-slot": { + "prefix": "vSlot", + "body": [ + "v-slot$1=\"${2}\"" + ], + "description": "Expects: JavaScript expression that is valid in a function argument position (supports destructuring in supported environments). Optional - only needed if expecting props to be passed to the slot." + }, + "v-pre": { + "prefix": "vPre", + "body": [ + "v-pre" + ], + "description": "Does not expect expression" + }, + "v-cloak": { + "prefix": "vCloak", + "body": [ + "v-cloak" + ], + "description": "Does not expect expression" + }, + "v-once": { + "prefix": "vOnce", + "body": [ + "v-once" + ], + "description": "Does not expect expression" + }, + "key": { + "prefix": "key", + "body": [ + ":key=\"${1:key}\"" + ], + "description": "Expects: string. Children of the same common parent must have unique keys. Duplicate keys will cause render errors." + }, + "ref": { + "prefix": "ref", + "body": [ + "ref=\"${1:reference}\"$0" + ], + "description": "Expects: string. ref is used to register a reference to an element or a child component. The reference will be registered under the parent componentโ€™s $refs object. If used on a plain DOM element, the reference will be that element; if used on a child component, the reference will be component instance." + }, + "slotA": { + "prefix": "slotA", + "body": [ + "slot=\"$1\"$0" + ], + "description": "slot=''. Expects: string. Used on content inserted into child components to indicate which named slot the content belongs to." + }, + "slotE": { + "prefix": "slotE", + "body": [ + "$2$0" + ], + "description": ". Expects: string. Used on content inserted into child components to indicate which named slot the content belongs to." + }, + "slotScope": { + "prefix": "slotScope", + "body": [ + "slot-scope=\"$1\"$0" + ], + "description": "Used to denote an element or component as a scoped slot. The attributeโ€™s value should be a valid JavaScript expression that can appear in the argument position of a function signature. This means in supported environments you can also use ES2015 destructuring in the expression. Serves as a replacement for scope in 2.5.0+." + }, + "scope": { + "prefix": "scope", + "body": [ + "scope=\"${1:this api replaced by slot-scope in 2.5.0+}\"$0" + ], + "description": "Used to denote a