From dbb3fa6d8e99217f3e585db6027713b0ccd89701 Mon Sep 17 00:00:00 2001 From: Buddy Sandidge Date: Fri, 10 May 2024 11:34:35 -0700 Subject: [PATCH] Update neovim configs --- dot_config/nvim/init.lua | 6 +- dot_config/nvim/lua/core/config.lua | 46 ++++++++- .../nvim/lua/plugins/autocompletion.lua | 1 - dot_config/nvim/lua/plugins/base.lua | 1 + dot_config/nvim/lua/plugins/go.lua | 7 +- dot_config/nvim/lua/plugins/lsp.lua.tmpl | 94 +++++++++++-------- dot_config/nvim/lua/plugins/snippets.lua | 1 + dot_config/nvim/lua/plugins/telescope.lua | 55 ++++++----- dot_config/nvim/lua/plugins/theme.lua | 8 ++ dot_config/nvim/lua/plugins/which-key.lua | 25 ----- dot_config/nvim/snippets/all.snippets | 53 +++++++++++ dot_config/nvim/snippets/go.snippets.tmpl | 47 ++++++++++ dot_config/nvim/snippets/html.snippets | 18 ++++ dot_config/nvim/snippets/javascript.snippets | 54 +++++++++++ dot_config/nvim/snippets/php.snippets | 32 +++++++ dot_config/nvim/snippets/python.snippets | 9 ++ dot_config/nvim/snippets/scss.snippets | 7 ++ dot_config/nvim/snippets/typescript.snippets | 1 + 18 files changed, 370 insertions(+), 95 deletions(-) delete mode 100644 dot_config/nvim/lua/plugins/which-key.lua create mode 100644 dot_config/nvim/snippets/all.snippets create mode 100644 dot_config/nvim/snippets/go.snippets.tmpl create mode 100644 dot_config/nvim/snippets/html.snippets create mode 100644 dot_config/nvim/snippets/javascript.snippets create mode 100644 dot_config/nvim/snippets/php.snippets create mode 100644 dot_config/nvim/snippets/python.snippets create mode 100644 dot_config/nvim/snippets/scss.snippets create mode 100644 dot_config/nvim/snippets/typescript.snippets diff --git a/dot_config/nvim/init.lua b/dot_config/nvim/init.lua index 6f637a6..0ae3d93 100644 --- a/dot_config/nvim/init.lua +++ b/dot_config/nvim/init.lua @@ -1,5 +1,3 @@ -require 'core.config' -require 'core.commands' -require 'core.keymaps' +require('core.config') vim.opt.runtimepath:prepend(vim.fn.stdpath('data') .. '/lazy/lazy.nvim') -require 'lazy' .setup('plugins', {}) +require('lazy').setup('plugins', {}) diff --git a/dot_config/nvim/lua/core/config.lua b/dot_config/nvim/lua/core/config.lua index 3eff738..e0a6f4b 100644 --- a/dot_config/nvim/lua/core/config.lua +++ b/dot_config/nvim/lua/core/config.lua @@ -3,7 +3,20 @@ vim.g.maplocalleader = ',' vim.opt.fileformats = { 'unix', 'dos', 'mac' } -vim.opt.autochdir = true +vim.opt.mouse = 'a' +vim.opt.clipboard = 'unnamedplus' +vim.opt.breakindent = true +vim.opt.undofile = true +vim.opt.signcolumn = 'yes' + +vim.opt.updatetime = 250 +vim.opt.timeoutlen = 300 + +vim.opt.splitright = true +vim.opt.splitbelow = true +vim.opt.scrolloff = 8 + +-- vim.opt.autochdir = true -- Tabs vim.opt.shiftwidth = 4 @@ -18,6 +31,7 @@ vim.opt.relativenumber = true vim.opt.showmatch = true vim.opt.spelllang = 'en_us' vim.opt.wildmode = 'list:longest' +vim.opt.cursorline = true -- Indent vim.opt.copyindent = true @@ -28,6 +42,8 @@ vim.opt.shiftround = true -- Text Formatting/Layout vim.opt.ignorecase = true vim.opt.list = true +vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } +vim.opt.inccommand = 'split' vim.opt.smartcase = true vim.opt.wrap = false vim.opt.whichwrap:append { @@ -36,3 +52,31 @@ vim.opt.whichwrap:append { ['['] = true, [']'] = true, } + +vim.api.nvim_create_user_command('W', 'write', {}) +vim.api.nvim_create_user_command('Q', 'qall!', {}) + +vim.keymap.set('n', 'l', ':nohlsearch', { desc = 'clear highlighted search' }) +vim.keymap.set('n', 'ts', [[:%s/\s\s*$//g]], { desc = '[T]rim trailing [S]pace' }) +vim.keymap.set('n', 'ss', ':setlocal spell!', { desc = '[S]et [S]pell' }) +vim.keymap.set('n', 'p', ':set paste!', { desc = '[P]aste' }) +vim.keymap.set('n', 'nn', ':set nonumber norelativenumber', { desc = '[N]o [N]umber removed number and relative number' }) +vim.keymap.set('n', 'rn', ':set number relativenumber', { desc = '[R]elative [N]umber - set relative number and absolute number' }) + +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' }) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' }) +vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' }) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnopstic [Q]uickfix list' }) + +-- Use to move between windows, no need for first +vim.keymap.set('n', '', '', { desc = 'Move focus up window' }) +vim.keymap.set('n', '', '', { desc = 'Move focus down window' }) +vim.keymap.set('n', '', '', { desc = 'Move focus left window' }) +vim.keymap.set('n', '', '', { desc = 'Move focus right window' }) + +-- highlight text on copy +vim.api.nvim_create_autocmd('TextYankPost', { + desc = 'Highlight when yanking (copying) text', + group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), + callback = vim.highlight.on_yank, +}) diff --git a/dot_config/nvim/lua/plugins/autocompletion.lua b/dot_config/nvim/lua/plugins/autocompletion.lua index 41f622a..16e345d 100644 --- a/dot_config/nvim/lua/plugins/autocompletion.lua +++ b/dot_config/nvim/lua/plugins/autocompletion.lua @@ -59,5 +59,4 @@ return { 'saadparwaiz1/cmp_luasnip', 'hrsh7th/cmp-nvim-lsp', }, - } diff --git a/dot_config/nvim/lua/plugins/base.lua b/dot_config/nvim/lua/plugins/base.lua index 472ad01..f8f7cd5 100644 --- a/dot_config/nvim/lua/plugins/base.lua +++ b/dot_config/nvim/lua/plugins/base.lua @@ -3,5 +3,6 @@ return { tag = 'v2.2', dependencies = { { 'tpope/vim-sleuth', tag = 'v2.0' }, + { 'numToStr/Comment.nvim', opts = {}, lazy = false }, }, } diff --git a/dot_config/nvim/lua/plugins/go.lua b/dot_config/nvim/lua/plugins/go.lua index 5480c69..e01f4d4 100644 --- a/dot_config/nvim/lua/plugins/go.lua +++ b/dot_config/nvim/lua/plugins/go.lua @@ -1,14 +1,13 @@ local function config() - require('go').setup() + require("go").setup() end return { 'ray-x/go.nvim', name = 'go', - import = 'plugins.go', config = config, - event = {'CmdlineEnter'}, - ft = {'go', 'gomod'}, + event = { 'CmdlineEnter' }, + ft = { 'go', 'gomod' }, dependencies = { 'ray-x/guihua.lua', 'lspconfig', diff --git a/dot_config/nvim/lua/plugins/lsp.lua.tmpl b/dot_config/nvim/lua/plugins/lsp.lua.tmpl index 16a935f..4763843 100644 --- a/dot_config/nvim/lua/plugins/lsp.lua.tmpl +++ b/dot_config/nvim/lua/plugins/lsp.lua.tmpl @@ -1,42 +1,11 @@ # chezmoi:template:left-delimiter=--{{ --{{- /* vim: set filetype=lua: */ -}} -local function on_attach(_, buffer) - local function nmap(keys, func, desc) - if desc then - desc = 'LSP: ' .. desc - end - vim.keymap.set('n', keys, func, { buffer = buffer, desc = desc }) - end - - local function inspect_workspace_folders() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end +local function on_attach(_, buffer) local function format_buffer(_) vim.lsp.buf.format() end - nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') - nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') - - local builtin = require 'telescope.builtin' - nmap('gd', builtin.lsp_definitions, '[G]oto [D]efinition') - nmap('gr', builtin.lsp_references, '[G]oto [R]eferences') - nmap('gI', builtin.lsp_implementations, '[G]oto [I]mplementation') - nmap('D', builtin.lsp_type_definitions, 'Type [D]efinition') - nmap('ds', builtin.lsp_document_symbols, '[D]ocument [S]ymbols') - nmap('ws', builtin.lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') - - -- See `:help K` for why this keymap - nmap('K', vim.lsp.buf.hover, 'Hover Documentation') - nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') - - -- Lesser used LSP functionality - nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') - nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') - nmap('wl', inspect_workspace_folders, '[W]orkspace [L]ist Folders') - -- Create a command `:Format` local to the LSP buffer vim.api.nvim_buf_create_user_command(buffer, 'Format', format_buffer, { desc = 'Format current buffer with LSP', @@ -46,12 +15,60 @@ end local function config() local cmp_nvim_lsp = require 'cmp_nvim_lsp' local lspconfig = require 'lspconfig' - local mason = require 'mason' local mason_lspconfig = require 'mason-lspconfig' - local neodev = require 'neodev' + local builtin = require 'telescope.builtin' - mason.setup() - neodev.setup() + vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), + callback = function (event) + local function map(keys, func, desc) + vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc}) + end + + map('rn', vim.lsp.buf.rename, '[R]e[n]ame') + map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + + map('gd', builtin.lsp_definitions, '[G]oto [D]efinition') + map('gr', builtin.lsp_references, '[G]oto [R]eferences') + map('gI', builtin.lsp_implementations, '[G]oto [I]mplementation') + map('D', builtin.lsp_type_definitions, 'Type [D]efinition') + map('ds', builtin.lsp_document_symbols, '[D]ocument [S]ymbols') + map('ws', builtin.lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + + -- See `:help K` for why this keymap + map('K', vim.lsp.buf.hover, 'Hover Documentation') + map('', vim.lsp.buf.signature_help, 'Signature Documentation') + + local function inspect_workspace_folders() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end + + -- Lesser used LSP functionality + map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + map('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') + map('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') + map('wl', inspect_workspace_folders, '[W]orkspace [L]ist Folders') + + -- The following two autocommands are used to highlight references of the + -- word under your cursor when your cursor rests there for a little while. + -- See `:help CursorHold` for information about when this is executed + -- + -- When you move your cursor, the highlights will be cleared (the second autocommand). + local client = vim.lsp.get_client_by_id(event.data.client_id) + if client and client.server_capabilities.documentHighlightProvider then + vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { + buffer = event.buf, + callback = vim.lsp.buf.document_highlight, + }) + + vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { + buffer = event.buf, + callback = vim.lsp.buf.clear_references, + }) + end + + end + }) local servers = { bashls = {}, @@ -66,7 +83,6 @@ local function config() yamlls = {}, cmake = {}, cssls = {}, - rome = {}, --{{ if lookPath "node" -}} eslint = {}, tsserver = {}, @@ -108,10 +124,10 @@ return { name = 'lspconfig', config = config, dependencies = { - { 'williamboman/mason.nvim', tag = 'v1.*' }, + { 'williamboman/mason.nvim', tag = 'v1.*', opts = {} }, { 'williamboman/mason-lspconfig.nvim', tag = 'v1.*' }, { 'j-hui/fidget.nvim', tag = 'legacy', opts = {} }, - { 'folke/neodev.nvim', tag = 'v2.*' }, + { 'folke/neodev.nvim', tag = 'v2.*', opts = {} }, { 'folke/trouble.nvim', tag = 'v2.*' }, }, } diff --git a/dot_config/nvim/lua/plugins/snippets.lua b/dot_config/nvim/lua/plugins/snippets.lua index 42e1511..698dd5b 100644 --- a/dot_config/nvim/lua/plugins/snippets.lua +++ b/dot_config/nvim/lua/plugins/snippets.lua @@ -2,6 +2,7 @@ local function config() local luasnip = require 'luasnip' luasnip.setup() luasnip.config.setup({}) + require("luasnip.loaders.from_snipmate").lazy_load() end return { diff --git a/dot_config/nvim/lua/plugins/telescope.lua b/dot_config/nvim/lua/plugins/telescope.lua index 4769199..293ea54 100644 --- a/dot_config/nvim/lua/plugins/telescope.lua +++ b/dot_config/nvim/lua/plugins/telescope.lua @@ -34,30 +34,38 @@ end vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {}) -local telescope_setup = { - defaults = { - mappings = { - i = { - [''] = false, - [''] = false, - }, - }, - }, -} - local function config() -- See `:help telescope` and `:help telescope.setup()` local telescope = require('telescope') local builtin = require('telescope.builtin') local themes = require('telescope.themes') - telescope.setup(telescope_setup) + telescope.setup({ + -- pickers = {} + extensions = { + ['ui-select'] = { + themes.get_dropdown(), + }, + }, + + defaults = { + mappings = { + i = { + [''] = false, + [''] = false, + [''] = 'to_fuzzy_refine', + }, + }, + }, + }) -- Enable telescope fzf native, if installed pcall(telescope.load_extension, 'fzf') + pcall(telescope.load_extension, 'ui-select') - local fuzzy_find = function() - -- You can pass additional configuration to telescope to change theme, layout, etc. + local function fuzzy_find () + -- You can pass additional configuration to telescope to change theme, + -- layout, etc. builtin.current_buffer_fuzzy_find(themes.get_dropdown({ winblend = 10, previewer = false, @@ -65,20 +73,22 @@ local function config() end -- See `:help telescope.builtin` - vim.keymap.set('n', '?', builtin.oldfiles, { desc = '[?] Find recently opened files' }) - vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) - vim.keymap.set('n', '/', fuzzy_find, { desc = '[/] Fuzzily search in current buffer' }) - vim.keymap.set('n', 'gf', builtin.git_files, { desc = 'Search [G]it [F]iles' }) - vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) + vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) + vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) + vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) - vim.keymap.set('n', 'sG', live_grep_git_root, { desc = '[S]earch by [G]rep on Git Root' }) vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) + vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) + vim.keymap.set('n', 'sG', live_grep_git_root, { desc = '[S]earch by [G]rep on Git Root' }) + vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) + vim.keymap.set('n', '/', fuzzy_find, { desc = '[/] Fuzzily search in current buffer' }) + vim.keymap.set('n', 'gf', builtin.git_files, { desc = 'Search [G]it [F]iles' }) end -local is_make_installed = function() +local function is_make_installed() return vim.fn.executable('make') == 1 end @@ -86,6 +96,7 @@ return { 'nvim-telescope/telescope.nvim', branch = '0.1.x', config = config, + event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim', { @@ -93,5 +104,7 @@ return { cond = is_make_installed, build = 'make', }, + 'nvim-telescope/telescope-ui-select.nvim', + 'nvim-tree/nvim-web-devicons', }, } diff --git a/dot_config/nvim/lua/plugins/theme.lua b/dot_config/nvim/lua/plugins/theme.lua index d5a3f1b..4f16336 100644 --- a/dot_config/nvim/lua/plugins/theme.lua +++ b/dot_config/nvim/lua/plugins/theme.lua @@ -12,6 +12,14 @@ return { options = { theme = 'gruvbox', }, + sections = { + lualine_a = { 'mode' }, + lualine_b = { 'diagnostics' }, + lualine_c = { { 'filename', path = 3 } }, + lualine_x = { 'encoding', 'fileformat', 'filetype' }, + lualine_y = { 'progress' }, + lualine_z = { 'location' } + }, }, }, } diff --git a/dot_config/nvim/lua/plugins/which-key.lua b/dot_config/nvim/lua/plugins/which-key.lua deleted file mode 100644 index 4ba45cc..0000000 --- a/dot_config/nvim/lua/plugins/which-key.lua +++ /dev/null @@ -1,25 +0,0 @@ -local function init() - vim.o.timeout = true - vim.o.timeoutlen = 300 -end - -local function config() - local wk = require 'which-key' - wk.setup() - wk.register { - ['c'] = { name = '[C]ode', _ = 'which_key_ignore' }, - ['d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, - ['g'] = { name = '[G]it', _ = 'which_key_ignore' }, - ['h'] = { name = 'More git', _ = 'which_key_ignore' }, - ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, - ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, - ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, - } -end - -return { - 'folke/which-key.nvim', - init = init, - config = config, - event = "VeryLazy", -} diff --git a/dot_config/nvim/snippets/all.snippets b/dot_config/nvim/snippets/all.snippets new file mode 100644 index 0000000..2a9bb33 --- /dev/null +++ b/dot_config/nvim/snippets/all.snippets @@ -0,0 +1,53 @@ +snippet #! "Shebang" !b + #!/usr/bin/env ${1:bash} + +snippet - "bullet" + • + +snippet -> "right arrow" + → + +snippet :) "smile" + ☺ + +snippet :( "frown" + ☹ + +snippet <3 "heart" + ♥ + +snippet *<3 "sparkle heart" + 💖 + +snippet x "ballot x" + ✗ + +snippet v "check mark" + ✓ + +snippet !? "interrobang" + ‽ + +snippet ?! "interrobang" + ‽ + +snippet ... "ellipsis" + … + +snippet * "star" + ★ + +snippet -- "em dash" + — + +snippet != "not equal" + ≠ + +snippet <- "left arrow ←" + ← + +snippet \/ "down arrow ↓" + ↓ + +snippet 1/2 "half ½" + ½ diff --git a/dot_config/nvim/snippets/go.snippets.tmpl b/dot_config/nvim/snippets/go.snippets.tmpl new file mode 100644 index 0000000..61c3dfe --- /dev/null +++ b/dot_config/nvim/snippets/go.snippets.tmpl @@ -0,0 +1,47 @@ +# chezmoi:template:left-delimiter=#{{ +#{{- /* vim: set filetype=snippets: */ -}} +#{{- if lookPath "go" -}} +snippet ignore "ignore function" ! + func(...any) {}(${1}) + +snippet ctx "context" ! + ctx context.Context + +snippet e "error wrapper" ! + e := wrap(".${1}") + +snippet test "setup test case" ! + func Test${1}(t *testing.T) { + type testcase struct { + Name string + Setup func(tc *testcase) + } + tt := []testcase{} + for _, tc := range tt { + tc := tc + t.Run(tc.Name, func(t *testing.T) { + t.Parallel() + tc.Setup(&tc) + }) + } + } + +snippet htest "setup context test case" ! + func Test${1}(t *testing.T) { + type testcase struct { + Name string + Setup func(tc *testcase) + } + + tt := []testcase{} + + for _, tc := range tt { + tc := tc + t.Run(tc.Name, func(t *testing.T) { + ctx, a, ctrl := utils.Test(t) + t.Parallel() + tc.Setup(&tc) + }) + } + } +#{{- end }} diff --git a/dot_config/nvim/snippets/html.snippets b/dot_config/nvim/snippets/html.snippets new file mode 100644 index 0000000..144b85e --- /dev/null +++ b/dot_config/nvim/snippets/html.snippets @@ -0,0 +1,18 @@ +snippet doctype "html5 doctype" ! + + +snippet head "head tag based html5 boilerplate" ! + + + + + + + + + +snippet script "script tag" ! + + +snippet scriptsrc "script src" ! + diff --git a/dot_config/nvim/snippets/javascript.snippets b/dot_config/nvim/snippets/javascript.snippets new file mode 100644 index 0000000..2591952 --- /dev/null +++ b/dot_config/nvim/snippets/javascript.snippets @@ -0,0 +1,54 @@ +snippet f "function" ! + function ${1:func} (${2}) { + ${VISUAL}$0 + } + +snippet if "if" ! + if (${1:true}) { + ${VISUAL}$0 + } + +snippet scf "self calling function" ! + (function (${1:argument}) { + ${VISUAL}$0 + }(${2:$1})); + +snippet log "console.log" + console.log(${1:'${2:value}'}); + +snippet strict "use strict" + 'use strict'; + +snippet timeout "setTimeout" ! + setTimeout(function () { + ${1://code} + }, 0); + +snippet it "it test case" ! + it('→ $1', () => { + }); + +snippet desc "describe test case" ! + describe('→ $1', () => { + }); + +snippet exp "expect" b + expect($1).toBe($2); + +snippet umd "Universal Module Definition" b + (function (root, factory) { + if (typeof define === "function" && define.amd) { + define(["${1:dependency}"], factory); + } else if (typeof exports === "object") { + module.exports = factory(require("$1")); + } else { + root.${2:Export} = factory(root.$1); + } + }(this, function ($1) { + function $2($3) { + } + return $2; + })) + +snippet debug "debugger" ! + debugger$1; diff --git a/dot_config/nvim/snippets/php.snippets b/dot_config/nvim/snippets/php.snippets new file mode 100644 index 0000000..08aa198 --- /dev/null +++ b/dot_config/nvim/snippets/php.snippets @@ -0,0 +1,32 @@ +snippet php "Starting php tag" !b + + +snippet ec "echo" !b + echo "${1}"; + +snippet f "Anonymous function" + function () { + ${1} + } + +snippet fuse "Anonymous function with use" + function () use (${1}) { + ${2} + } + +snippet this "this helper" + $${1:this}->${2:prop} + +snippet [] "array literal" + array(${1}) + +snippet {} "Empty object" + new stdClass() + +snippet scf "self calling function" !b + call_user_func(function () { + ${1} + }); diff --git a/dot_config/nvim/snippets/python.snippets b/dot_config/nvim/snippets/python.snippets new file mode 100644 index 0000000..1b5b89b --- /dev/null +++ b/dot_config/nvim/snippets/python.snippets @@ -0,0 +1,9 @@ +snippet map "Map snippet" + map(${1:lambda x: x}, ${2:[]}) + +snippet #! "Python shebang" ! + #!/usr/bin/env python3 + +snippet #! "Python2 shebang" ! + #!/usr/bin/env python2 + # encoding: utf-8 diff --git a/dot_config/nvim/snippets/scss.snippets b/dot_config/nvim/snippets/scss.snippets new file mode 100644 index 0000000..d1ce805 --- /dev/null +++ b/dot_config/nvim/snippets/scss.snippets @@ -0,0 +1,7 @@ +snippet mixin "mixin definition" + @mixin ${1:name}(${2:$vars}) { + ${3:@content} + } + +snippet inc "call a mixin" + @include ${1:mixin-name}${2:($variables)} diff --git a/dot_config/nvim/snippets/typescript.snippets b/dot_config/nvim/snippets/typescript.snippets new file mode 100644 index 0000000..aa87242 --- /dev/null +++ b/dot_config/nvim/snippets/typescript.snippets @@ -0,0 +1 @@ +extends javascript