diff --git a/nvim/lazynvim/after/ftplugin/markdown.lua b/nvim/lazynvim/after/ftplugin/markdown.lua new file mode 100644 index 0000000..92290ab --- /dev/null +++ b/nvim/lazynvim/after/ftplugin/markdown.lua @@ -0,0 +1,20 @@ +-- Markdown specific key maps. +-- +local todos = require("todo-comments") +local keywords = { "WARN", "WARNING", "IMPORTANT" } + +-- Show all the warnings in the quick fix list. +vim.keymap.set( + "n", + "tw", + "Trouble todo toggle filter = {tag = {WARN, IMPORTANT}}", + { desc = "[T]odo [W]arnings" } +) + +vim.keymap.set("n", "]w", function() + todos.jump_next({ keywords = keywords }) +end, { desc = "Next [W]arning" }) + +vim.keymap.set("n", "[w", function() + todos.jump_prev({ keywords = keywords }) +end, { desc = "Previous [W]arning" }) diff --git a/nvim/lazynvim/after/ftplugin/swift.lua b/nvim/lazynvim/after/ftplugin/swift.lua new file mode 100644 index 0000000..ebe4aff --- /dev/null +++ b/nvim/lazynvim/after/ftplugin/swift.lua @@ -0,0 +1,2 @@ +vim.opt.tabstop = 2 +vim.opt.shiftwidth = 2 diff --git a/nvim/lazynvim/lua/config/autocmds.lua b/nvim/lazynvim/lua/config/autocmds.lua index 4221e75..330473d 100644 --- a/nvim/lazynvim/lua/config/autocmds.lua +++ b/nvim/lazynvim/lua/config/autocmds.lua @@ -1,8 +1,50 @@ --- Autocmds are automatically loaded on the VeryLazy event --- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua --- --- Add any additional autocmds here --- with `vim.api.nvim_create_autocmd` --- --- Or remove existing autocmds by their group name (which is prefixed with `lazyvim_` for the defaults) --- e.g. vim.api.nvim_del_augroup_by_name("lazyvim_wrap_spell") +local defaultGroupOptions = { clear = true } +local markdownGroup = vim.api.nvim_create_augroup("MyMarkdownGroup", defaultGroupOptions) +local spellGroup = vim.api.nvim_create_augroup("SpellGroup", defaultGroupOptions) +local createCmd = vim.api.nvim_create_autocmd + +-- Spell check +createCmd("BufEnter", { + pattern = { "*.md", "*.markdown", "*.txt", "*.tex" }, + group = spellGroup, + callback = function(_) + vim.cmd.setlocal("textwidth=80") + vim.cmd.setlocal("spell spelllang=en_us") + end, +}) + +-- Markdown +createCmd("BufWritePost", { + pattern = { "*.md", "*.markdown" }, + group = markdownGroup, + callback = function(_) + local cursor = vim.fn.getpos(".") + vim.cmd("FormatWrite") + vim.fn.setpos(".", cursor) + end, +}) + +-- Go +createCmd("BufWritePre", { + pattern = "*.go", + callback = function() + require("go.format").goimport() + end, + group = vim.api.nvim_create_augroup("GoFormat", defaultGroupOptions), +}) + +vim.api.nvim_exec2( + [[ + autocmd BufNewFile,BufRead /private/**/gopass** setlocal noswapfile nobackup noundofile shada="" + ]], + {} +) + +-- Highlight when yanking. +createCmd("TextYankPost", { + desc = "Highlight when yanking text.", + group = vim.api.nvim_create_augroup("highlight-yank", { clear = true }), + callback = function() + vim.highlight.on_yank() + end, +}) diff --git a/nvim/lazynvim/lua/config/options.lua b/nvim/lazynvim/lua/config/options.lua index fd90ad3..06f384c 100644 --- a/nvim/lazynvim/lua/config/options.lua +++ b/nvim/lazynvim/lua/config/options.lua @@ -8,41 +8,41 @@ local fn = vim.fn vim.cmd.set("inccommand=split") o.filetype = "on" -o.updatetime = 500 -- faster completion -o.timeoutlen = 800 -- time to wait for a mapped sequence to complete (in milliseconds) -o.ttimeoutlen = 300 -- Time in milliseconds to wait for a key code sequence to complete -o.backup = false -- creates a backup file -o.swapfile = false -- enable/disable swap file creation -o.dir = fn.stdpath("data") .. "/swp" -- swap file directory -o.undofile = false -- enable/disable undo file creation +o.updatetime = 500 -- faster completion +o.timeoutlen = 800 -- time to wait for a mapped sequence to complete (in milliseconds) +o.ttimeoutlen = 300 -- Time in milliseconds to wait for a key code sequence to complete +o.backup = false -- creates a backup file +o.swapfile = false -- enable/disable swap file creation +o.dir = fn.stdpath("data") .. "/swp" -- swap file directory +o.undofile = false -- enable/disable undo file creation o.undodir = fn.stdpath("data") .. "/undodir" -- set undo directory -o.history = 500 -- Use the 'history' option to set the number of lines from command mode that are remembered. -o.hidden = true -- required to keep multiple buffers and open multiple buffers -o.clipboard = "unnamedplus" -- allows neovim to access the system clipboard -o.fileencoding = "utf-8" -- the encoding written to a file -o.conceallevel = 0 -- so that `` is visible in markdown files -o.number = true -- set numbered lines -o.relativenumber = true -- set relative numbered lines -o.cmdheight = 1 -- space for displaying messages/commands -o.showmode = false -- we don't need to see things like -- INSERT -- anymore -o.showtabline = 2 -- always show tabs -o.laststatus = 2 -- The value of this option influences when the last window will have a status line (2 always) -o.smartcase = true -- smart case -o.smartindent = true -- make indenting smarter again -o.splitbelow = true -- force all horizontal splits to go below current window -o.splitright = true -- force all vertical splits to go to the right of current window -o.autoindent = true -- turn on auto indent. -o.expandtab = true -- convert tabs to spaces -o.smarttab = true -- turn on smart tab -o.shiftwidth = 2 -- the number of spaces inserted for each indentation -o.tabstop = 2 -- how many columns a tab counts for -o.termguicolors = true -- set term gui colors (most terminals support this) -o.cursorline = true -- highlight the current line -o.scrolloff = 8 -- Minimal number of screen lines to keep above and below the cursor -o.sidescrolloff = 5 -- The minimal number of columns to scroll horizontally -o.hlsearch = false -- highlight all matches on previous search pattern -o.ignorecase = true -- ignore case in search patterns -o.foldenable = false -- disable folding; enable with zi +o.history = 500 -- Use the 'history' option to set the number of lines from command mode that are remembered. +o.hidden = true -- required to keep multiple buffers and open multiple buffers +o.clipboard = "unnamedplus" -- allows neovim to access the system clipboard +o.fileencoding = "utf-8" -- the encoding written to a file +o.conceallevel = 0 -- so that `` is visible in markdown files +o.number = true -- set numbered lines +o.relativenumber = true -- set relative numbered lines +o.cmdheight = 1 -- space for displaying messages/commands +o.showmode = false -- we don't need to see things like -- INSERT -- anymore +o.showtabline = 2 -- always show tabs +o.laststatus = 2 -- The value of this option influences when the last window will have a status line (2 always) +o.smartcase = true -- smart case +o.smartindent = true -- make indenting smarter again +o.splitbelow = true -- force all horizontal splits to go below current window +o.splitright = true -- force all vertical splits to go to the right of current window +o.autoindent = true -- turn on auto indent. +o.expandtab = true -- convert tabs to spaces +o.smarttab = true -- turn on smart tab +o.shiftwidth = 2 -- the number of spaces inserted for each indentation +o.tabstop = 2 -- how many columns a tab counts for +o.termguicolors = true -- set term gui colors (most terminals support this) +o.cursorline = true -- highlight the current line +o.scrolloff = 20 -- Minimal number of screen lines to keep above and below the cursor +o.sidescrolloff = 5 -- The minimal number of columns to scroll horizontally +o.hlsearch = false -- highlight all matches on previous search pattern +o.ignorecase = true -- ignore case in search patterns +o.foldenable = false -- disable folding; enable with zi o.foldmethod = "expr" o.foldexpr = "nvim_treesitter#foldexpr()" vim.cmd.set("nolist") -- don't show listchars. @@ -51,10 +51,10 @@ o.listchars = "eol:¬,tab:>·,trail:~,extends:>,precedes:<,space:␣" o.shortmess = o.shortmess + "c" -- prevent "pattern not found" messages wo.colorcolumn = "99999" o.wildmode = "full" -o.lazyredraw = false -- do not redraw screen while running macros +o.lazyredraw = false -- do not redraw screen while running macros o.grepprg = "rg --hidden --vimgrep --smart-case --" o.completeopt = { "menu", "menuone", "noselect", "noinsert" } -- A comma separated list of options for Insert mode completion -o.wildignorecase = true -- When set case is ignored when completing file names and directories +o.wildignorecase = true -- When set case is ignored when completing file names and directories o.wildignore = [[ .git,.hg,.svn *.aux,*.out,*.toc diff --git a/nvim/lazynvim/lua/plugins/example.lua b/nvim/lazynvim/lua/plugins/example.lua deleted file mode 100644 index 17f53d6..0000000 --- a/nvim/lazynvim/lua/plugins/example.lua +++ /dev/null @@ -1,197 +0,0 @@ --- since this is just an example spec, don't actually load anything here and return an empty spec --- stylua: ignore -if true then return {} end - --- every spec file under the "plugins" directory will be loaded automatically by lazy.nvim --- --- In your plugin files, you can: --- * add extra plugins --- * disable/enabled LazyVim plugins --- * override the configuration of LazyVim plugins -return { - -- add gruvbox - { "ellisonleao/gruvbox.nvim" }, - - -- Configure LazyVim to load gruvbox - { - "LazyVim/LazyVim", - opts = { - colorscheme = "gruvbox", - }, - }, - - -- change trouble config - { - "folke/trouble.nvim", - -- opts will be merged with the parent spec - opts = { use_diagnostic_signs = true }, - }, - - -- disable trouble - { "folke/trouble.nvim", enabled = false }, - - -- override nvim-cmp and add cmp-emoji - { - "hrsh7th/nvim-cmp", - dependencies = { "hrsh7th/cmp-emoji" }, - ---@param opts cmp.ConfigSchema - opts = function(_, opts) - table.insert(opts.sources, { name = "emoji" }) - end, - }, - - -- change some telescope options and a keymap to browse plugin files - { - "nvim-telescope/telescope.nvim", - keys = { - -- add a keymap to browse plugin files - -- stylua: ignore - { - "fp", - function() require("telescope.builtin").find_files({ cwd = require("lazy.core.config").options.root }) end, - desc = "Find Plugin File", - }, - }, - -- change some options - opts = { - defaults = { - layout_strategy = "horizontal", - layout_config = { prompt_position = "top" }, - sorting_strategy = "ascending", - winblend = 0, - }, - }, - }, - - -- add pyright to lspconfig - { - "neovim/nvim-lspconfig", - ---@class PluginLspOpts - opts = { - ---@type lspconfig.options - servers = { - -- pyright will be automatically installed with mason and loaded with lspconfig - pyright = {}, - }, - }, - }, - - -- add tsserver and setup with typescript.nvim instead of lspconfig - { - "neovim/nvim-lspconfig", - dependencies = { - "jose-elias-alvarez/typescript.nvim", - init = function() - require("lazyvim.util").lsp.on_attach(function(_, buffer) - -- stylua: ignore - vim.keymap.set( "n", "co", "TypescriptOrganizeImports", { buffer = buffer, desc = "Organize Imports" }) - vim.keymap.set("n", "cR", "TypescriptRenameFile", { desc = "Rename File", buffer = buffer }) - end) - end, - }, - ---@class PluginLspOpts - opts = { - ---@type lspconfig.options - servers = { - -- tsserver will be automatically installed with mason and loaded with lspconfig - tsserver = {}, - }, - -- you can do any additional lsp server setup here - -- return true if you don't want this server to be setup with lspconfig - ---@type table - setup = { - -- example to setup with typescript.nvim - tsserver = function(_, opts) - require("typescript").setup({ server = opts }) - return true - end, - -- Specify * to use this function as a fallback for any server - -- ["*"] = function(server, opts) end, - }, - }, - }, - - -- for typescript, LazyVim also includes extra specs to properly setup lspconfig, - -- treesitter, mason and typescript.nvim. So instead of the above, you can use: - { import = "lazyvim.plugins.extras.lang.typescript" }, - - -- add more treesitter parsers - { - "nvim-treesitter/nvim-treesitter", - opts = { - ensure_installed = { - "bash", - "html", - "javascript", - "json", - "lua", - "markdown", - "markdown_inline", - "python", - "query", - "regex", - "tsx", - "typescript", - "vim", - "yaml", - }, - }, - }, - - -- since `vim.tbl_deep_extend`, can only merge tables and not lists, the code above - -- would overwrite `ensure_installed` with the new value. - -- If you'd rather extend the default config, use the code below instead: - { - "nvim-treesitter/nvim-treesitter", - opts = function(_, opts) - -- add tsx and treesitter - vim.list_extend(opts.ensure_installed, { - "tsx", - "typescript", - }) - end, - }, - - -- the opts function can also be used to change the default opts: - { - "nvim-lualine/lualine.nvim", - event = "VeryLazy", - opts = function(_, opts) - table.insert(opts.sections.lualine_x, { - function() - return "😄" - end, - }) - end, - }, - - -- or you can return new options to override all the defaults - { - "nvim-lualine/lualine.nvim", - event = "VeryLazy", - opts = function() - return { - --[[add your custom lualine config here]] - } - end, - }, - - -- use mini.starter instead of alpha - { import = "lazyvim.plugins.extras.ui.mini-starter" }, - - -- add jsonls and schemastore packages, and setup treesitter for json, json5 and jsonc - { import = "lazyvim.plugins.extras.lang.json" }, - - -- add any tools you want to have installed below - { - "williamboman/mason.nvim", - opts = { - ensure_installed = { - "stylua", - "shellcheck", - "shfmt", - "flake8", - }, - }, - }, -} diff --git a/nvim/lazynvim/lua/plugins/formatter.lua b/nvim/lazynvim/lua/plugins/formatter.lua new file mode 100644 index 0000000..b0ee7ee --- /dev/null +++ b/nvim/lazynvim/lua/plugins/formatter.lua @@ -0,0 +1,23 @@ +return { + "stevearc/conform.nvim", + opts = { + formatters_by_ft = { + lua = { "stulua" }, + markdown = { + "prettier", + prepend_args = { + "--print-width", + "100", + "--prose-wrap", + "always", + "--parser", + "markdown", + }, + }, + swift = { "swiftformat" }, + -- ["*"] = { + -- require("formatter.filetypes.any").remove_trailing_whitespace, + -- }, + }, + }, +} diff --git a/nvim/lazynvim/lua/plugins/init.lua b/nvim/lazynvim/lua/plugins/init.lua index 91999f2..da6e4a5 100644 --- a/nvim/lazynvim/lua/plugins/init.lua +++ b/nvim/lazynvim/lua/plugins/init.lua @@ -7,6 +7,7 @@ return { { import = "lazyvim.plugins.extras.lang.json" }, { import = "lazyvim.plugins.extras.lang.markdown" }, { import = "lazyvim.plugins.extras.lang.yaml" }, + { import = "lazyvim.plugins.extras.coding.luasnip" }, { import = "lazyvim.plugins.extras.editor.mini-files", opts = { diff --git a/nvim/lazynvim/lua/plugins/lsp.lua b/nvim/lazynvim/lua/plugins/lsp.lua index feaf8af..8c7b69a 100644 --- a/nvim/lazynvim/lua/plugins/lsp.lua +++ b/nvim/lazynvim/lua/plugins/lsp.lua @@ -1,100 +1,147 @@ --- The language servers to setup. -local lsp_servers = { - "bashls", - "clangd", - "dockerls", - "gopls", - "jsonls", - "lua_ls", - "marksman", - "sourcekit", - "yamlls", -} - return { - "neovim/nvim-lspconfig", - event = { "BufReadPre", "BufNewFile" }, - dependencies = { - "hrsh7th/cmp-nvim-lsp", - { "antosha417/nvim-lsp-file-operations", config = true }, + { "williamboman/mason.nvim", - "williamboman/mason-lspconfig.nvim", - { - "folke/lazydev.nvim", - ft = "lua", - opts = { - library = { - { path = "${3rd}/luv/library", words = { "vim%.uv" } }, - }, + dependencies = { + "neovim/nvim-lspconfig", + }, + opts = { + ensure_installed = { + "clangd", + "marksman", + "shfmt", }, }, }, - config = function() - require("mason").setup() - require("mason-lspconfig").setup({ - opts = { - ensure_installed = lsp_servers, + { + "nvim-treesitter/nvim-treesitter", + opts = { + ensure_installed = { + "bash", + "cmake", + "dockerfile", + "editorconfig", + "ini", + "json", + "jq", + "latex", + "make", + "swift", }, - }) - local lspconfig = require("lspconfig") - local cmp_nvim_lsp = require("cmp_nvim_lsp") - local capabilities = cmp_nvim_lsp.default_capabilities() - local opts = { noremap = true, silent = true } - local on_attach = function(_, bufnr) - opts.buffer = bufnr - - opts.desc = "Show line diagnostics" - vim.keymap.set("n", "d", vim.diagnostic.open_float, opts) - - opts.desc = "Show diagnostics in Telescope" - vim.keymap.set("n", "d", "Telescope diagnostics bufnr=0", opts) - - opts.desc = "Show documentation for what is under cursor" - vim.keymap.set("n", "", vim.lsp.buf.hover, opts) - - opts.desc = "[G]oto [D]efinition" - vim.keymap.set("n", "gd", "Telescope lsp_definitions trim_text=true", opts) - - opts.desc = "[G]oto [D]eclaration" - vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) - - opts.desc = "LSP [C]ode [A]ction" - vim.keymap.set("n", "ca", vim.lsp.buf.code_action, opts) - - --opts.desc = "[R]e-[N]ame" - --vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) - - opts.desc = "[R]eload or start LSP" - vim.keymap.set("n", "rl", ":LspRestart | :LspStart", opts) - - opts.desc = "Goto previous diagnostic" - vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) - - opts.desc = "Goto next diagnostic" - vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts) - end - - for _, lsp in ipairs(lsp_servers) do - lspconfig[lsp].setup({ - capabilities = capabilities, - on_attach = on_attach, - on_init = function(client) - -- HACK: to fix some issues with LSP - -- more details: https://github.com/neovim/neovim/issues/19237#issuecomment-2237037154 - client.offset_encoding = "utf-8" + }, + }, + { + "neovim/nvim-lspconfig", + event = { "BufReadPre", "BufNewFile" }, + opts = { + servers = { + bashls = {}, + clangd = {}, + dockerls = {}, + gopls = {}, + jsonls = {}, + lua_ls = {}, + marksman = {}, + sourcekit = {}, + yamlls = {}, + }, + setup = { + clangd = function(_, opts) + opts.capabilities.offsetEncoding = { "utf-16" } end, - cmd = lsp == "sourcekit" and { vim.trim(vim.fn.system("xcrun -f sourcekit-lsp")) } or nil, - }) - end - - -- nice icons - local signs = { Error = " ", Warn = " ", Hint = "󰠠 ", Info = " " } - for type, icon in pairs(signs) do - local hl = "DiagnosticSign" .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) - end - - -- For some reason I was having trouble getting this to work inside the on-attach, so it's here. - vim.keymap.set("n", "rn", vim.lsp.buf.rename, { desc = "[R]e-[N]ame" }) - end, + sourcekit = function(_, opts) + opts.cmd = { + vim.trim(vim.fn.system("xcrun -f sourcekit-lsp")) or nil + } + end + }, + }, + }, } + +-- return { +-- "neovim/nvim-lspconfig", +-- event = { "BufReadPre", "BufNewFile" }, +-- dependencies = { +-- "hrsh7th/cmp-nvim-lsp", +-- { "antosha417/nvim-lsp-file-operations", config = true }, +-- "williamboman/mason.nvim", +-- "williamboman/mason-lspconfig.nvim", +-- { +-- "folke/lazydev.nvim", +-- ft = "lua", +-- opts = { +-- library = { +-- { path = "${3rd}/luv/library", words = { "vim%.uv" } }, +-- }, +-- }, +-- }, +-- }, +-- config = function() +-- require("mason").setup() +-- require("mason-lspconfig").setup({ +-- opts = { +-- ensure_installed = lsp_servers, +-- }, +-- }) +-- local lspconfig = require("lspconfig") +-- local cmp_nvim_lsp = require("cmp_nvim_lsp") +-- local capabilities = cmp_nvim_lsp.default_capabilities() +-- local opts = { noremap = true, silent = true } +-- local on_attach = function(_, bufnr) +-- opts.buffer = bufnr +-- +-- opts.desc = "Show line diagnostics" +-- vim.keymap.set("n", "d", vim.diagnostic.open_float, opts) +-- +-- opts.desc = "Show diagnostics in Telescope" +-- vim.keymap.set("n", "d", "Telescope diagnostics bufnr=0", opts) +-- +-- opts.desc = "Show documentation for what is under cursor" +-- vim.keymap.set("n", "", vim.lsp.buf.hover, opts) +-- +-- opts.desc = "[G]oto [D]efinition" +-- vim.keymap.set("n", "gd", "Telescope lsp_definitions trim_text=true", opts) +-- +-- opts.desc = "[G]oto [D]eclaration" +-- vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) +-- +-- opts.desc = "LSP [C]ode [A]ction" +-- vim.keymap.set("n", "ca", vim.lsp.buf.code_action, opts) +-- +-- --opts.desc = "[R]e-[N]ame" +-- --vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) +-- +-- opts.desc = "[R]eload or start LSP" +-- vim.keymap.set("n", "rl", ":LspRestart | :LspStart", opts) +-- +-- opts.desc = "Goto previous diagnostic" +-- vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) +-- +-- opts.desc = "Goto next diagnostic" +-- vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts) +-- end +-- +-- for _, lsp in ipairs(lsp_servers) do +-- lspconfig[lsp].setup({ +-- capabilities = capabilities, +-- on_attach = on_attach, +-- on_init = function(client) +-- -- HACK: to fix some issues with LSP +-- -- more details: https://github.com/neovim/neovim/issues/19237#issuecomment-2237037154 +-- client.offset_encoding = "utf-8" +-- end, +-- cmd = lsp == "sourcekit" and { vim.trim(vim.fn.system("xcrun -f sourcekit-lsp")) } or nil, +-- }) +-- end +-- +-- -- nice icons +-- local signs = { Error = " ", Warn = " ", Hint = "󰠠 ", Info = " " } +-- for type, icon in pairs(signs) do +-- local hl = "DiagnosticSign" .. type +-- vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) +-- end +-- +-- -- For some reason I was having trouble getting this to work inside the on-attach, so it's here. +-- vim.keymap.set("n", "rn", vim.lsp.buf.rename, { desc = "[R]e-[N]ame" }) +-- end, +-- } diff --git a/nvim/lazynvim/lua/plugins/luasnip.lua b/nvim/lazynvim/lua/plugins/luasnip.lua new file mode 100644 index 0000000..cf7ee9a --- /dev/null +++ b/nvim/lazynvim/lua/plugins/luasnip.lua @@ -0,0 +1,39 @@ +return { + { + "L3MON4D3/LuaSnip", + opts = function() + LazyVim.cmp.actions.snippet_forward = function() + if require("luasnip").jumpable(1) then + require("luasnip").jump(1) + return true + end + end + LazyVim.cmp.actions.snippet_stop = function() + if require("luasnip").expand_or_jumpable() then -- or just jumpable(1) is fine? + require("luasnip").unlink_current() + return true + end + end + end, + keys = { + { + "", + mode = { "i", "s" }, + function() + if ls.expand_or_jumpable() then + ls.expand_or_jump() + end + end + }, + { + "", + mode = { "i", "s" }, + function() + if ls.jumpable(-1) then + ls.jump(-1) + end + end + }, + }, + }, +} diff --git a/nvim/lazynvim/lua/plugins/oil.lua b/nvim/lazynvim/lua/plugins/oil.lua new file mode 100644 index 0000000..6584b62 --- /dev/null +++ b/nvim/lazynvim/lua/plugins/oil.lua @@ -0,0 +1,36 @@ +return { + "stevearc/oil.nvim", + event = "VeryLazy", + dependencies = { + "nvim-tree/nvim-web-devicons", + }, + opts = { + columns = { "icon" }, + keymaps = { + [""] = false, + [""] = "actions.select_split", + [""] = { + "actions.select", + opts = { vertical = true }, + desc = "Open the entry in a vertical split", + }, + view_options = { + is_hidden_file = function(name, _) -- second arg is bufnr, but not currently used. + -- Don't show .DS_Store in output. + local is_ds_store = name ~= ".DS_Store" + return not is_ds_store + end, + }, + } + }, + keys = { + -- Show the parent directory in current window. + { "-", "Oil", desc = "Open parent directory." }, + -- Open parent directory in floating window. + { + "-", + function() require("oil").toggle_float() end, + desc = "Open parent directory in floating window." + }, + }, +} diff --git a/nvim/lazynvim/lua/plugins/xcodebuild.lua b/nvim/lazynvim/lua/plugins/xcodebuild.lua index 2553511..9df4831 100644 --- a/nvim/lazynvim/lua/plugins/xcodebuild.lua +++ b/nvim/lazynvim/lua/plugins/xcodebuild.lua @@ -2,6 +2,7 @@ local progress_handle return { "wojciech-kulik/xcodebuild.nvim", + event = "VeryLazy", dependencies = { "nvim-telescope/telescope.nvim", "MunifTanjim/nui.nvim", @@ -50,23 +51,23 @@ return { }, }, keys = { - { "X", "XcodebuildPicker", desc = "Show Xcodebuild Actions" }, - { "xf", "XcodebuildProjectManager", desc = "Show Project Manager Actions" }, - { "xb", "XcodebuildBuild", desc = "Build Project" }, - { "xB", "XcodebuildBuildForTesting", desc = "Build For Testing" }, - { "xr", "XcodebuildBuildRun", desc = "Build & Run Project" }, - { "xt", "XcodebuildTest", desc = "Run Tests" }, - { "xt", "XcodebuildTestSelected", desc = "Run Selected Tests" }, - { "xT", "XcodebuildTestClass", desc = "Run This Test Class" }, - { "xl", "XcodebuildToggleLogs", desc = "Toggle Xcodebuild Logs" }, - { "xc", "XcodebuildToggleCodeCoverage", desc = "Toggle Code Coverage" }, + { "X", "XcodebuildPicker", desc = "Show Xcodebuild Actions" }, + { "xf", "XcodebuildProjectManager", desc = "Show Project Manager Actions" }, + { "xb", "XcodebuildBuild", desc = "Build Project" }, + { "xB", "XcodebuildBuildForTesting", desc = "Build For Testing" }, + { "xr", "XcodebuildBuildRun", desc = "Build & Run Project" }, + { "xt", "XcodebuildTest", desc = "Run Tests" }, + { "xt", "XcodebuildTestSelected", desc = "Run Selected Tests" }, + { "xT", "XcodebuildTestClass", desc = "Run This Test Class" }, + { "xl", "XcodebuildToggleLogs", desc = "Toggle Xcodebuild Logs" }, + { "xc", "XcodebuildToggleCodeCoverage", desc = "Toggle Code Coverage" }, { "xC", "XcodebuildShowCodeCoverageReport", desc = "Show Code Coverage Report" }, - { "xe", "XcodebuildTestExplorerToggle", desc = "Toggle Test Explorer" }, - { "xs", "XcodebuildFailingSnapshots", desc = "Show Failing Snapshots" }, - { "xd", "XcodebuildSelectDevice", desc = "Select Device" }, - { "xp", "XcodebuildSelectTestPlan", desc = "Select Test Plan" }, - { "xq", "Telescope quickfixxx", "XcodebuildQuickfixLine", desc = "Quickfix Line" }, - { "xa", "XcodebuildCodeActions", desc = "Show Code Actions" }, + { "xe", "XcodebuildTestExplorerToggle", desc = "Toggle Test Explorer" }, + { "xs", "XcodebuildFailingSnapshots", desc = "Show Failing Snapshots" }, + { "xd", "XcodebuildSelectDevice", desc = "Select Device" }, + { "xp", "XcodebuildSelectTestPlan", desc = "Select Test Plan" }, + { "xq", "Telescope quickfixxx", "XcodebuildQuickfixLine", desc = "Quickfix Line" }, + { "xa", "XcodebuildCodeActions", desc = "Show Code Actions" }, }, } diff --git a/nvim/m-housh/lua/user/snippets/init.lua b/nvim/lazynvim/snippets/init.lua similarity index 100% rename from nvim/m-housh/lua/user/snippets/init.lua rename to nvim/lazynvim/snippets/init.lua diff --git a/nvim/m-housh/lua/user/snippets/lua.lua b/nvim/lazynvim/snippets/lua.lua similarity index 100% rename from nvim/m-housh/lua/user/snippets/lua.lua rename to nvim/lazynvim/snippets/lua.lua diff --git a/nvim/m-housh/lua/user/snippets/swift.lua b/nvim/lazynvim/snippets/swift.lua similarity index 100% rename from nvim/m-housh/lua/user/snippets/swift.lua rename to nvim/lazynvim/snippets/swift.lua diff --git a/nvim/lazynvim/spell/en.utf-8.add b/nvim/lazynvim/spell/en.utf-8.add new file mode 100755 index 0000000..096d029 --- /dev/null +++ b/nvim/lazynvim/spell/en.utf-8.add @@ -0,0 +1,16 @@ +MeasureQuick +Housh +sealtite +Subcool +OEM +NEC +AHJ +CFM +Hydronic +subpar +quo +IAQ +wc +HVAC +dehumidification +ansible diff --git a/nvim/lazynvim/spell/en.utf-8.add.spl b/nvim/lazynvim/spell/en.utf-8.add.spl new file mode 100755 index 0000000..c805b67 Binary files /dev/null and b/nvim/lazynvim/spell/en.utf-8.add.spl differ diff --git a/nvim/m-housh/lua/user/plugin/blink.lua b/nvim/m-housh/lua/user/plugin/blink.lua index cb1ca0b..1957457 100644 --- a/nvim/m-housh/lua/user/plugin/blink.lua +++ b/nvim/m-housh/lua/user/plugin/blink.lua @@ -1,57 +1,58 @@ return { - { - "saghen/blink.cmp", - dependencies = { - "rafamadriz/friendly-snippets", - --"L3MON4D3/LuaSnip", - }, - version = "v0.*", - opts = { - appearance = { - use_nvim_cmp_as_default = true, - nerd_font_variant = "mono", - }, - signature = { enabled = true }, - keymap = { - preset = "default", - [""] = { "accept", "fallback" }, - [""] = { - function(cmp) - cmp.show({ providers = { "snippets" } }) - end, - }, - --[""] = { "select_prev", "fallback" }, - --[""] = { "select_next", "fallback" }, - [""] = { - function(cmp) - if cmp.snippet_active() then - return cmp.accept() - else - return cmp.select_and_accept() - end - end, - "snippet_forward", - "fallback", - }, - }, - -- snippets = { - -- expand = function(snippet) - -- require("luasnip").lsp_expand(snippet) - -- end, - -- active = function(filter) - -- if filter and filter.direction then - -- return require("luasnip").jumpable(filter.direction) - -- end - -- return require("luasnip").in_snippet() - -- end, - -- jump = function(direction) - -- require("luasnip").jump(direction) - -- end, - -- }, - sources = { - default = { "lsp", "path", "snippets", "buffer" }, - }, - }, - opts_extend = { "sources.default" }, - }, + { + "saghen/blink.cmp", + enabeld = false, + dependencies = { + "rafamadriz/friendly-snippets", + --"L3MON4D3/LuaSnip", + }, + version = "v0.*", + opts = { + appearance = { + use_nvim_cmp_as_default = true, + nerd_font_variant = "mono", + }, + signature = { enabled = true }, + keymap = { + preset = "default", + [""] = { "accept", "fallback" }, + [""] = { + function(cmp) + cmp.show({ providers = { "snippets" } }) + end, + }, + --[""] = { "select_prev", "fallback" }, + --[""] = { "select_next", "fallback" }, + [""] = { + function(cmp) + if cmp.snippet_active() then + return cmp.accept() + else + return cmp.select_and_accept() + end + end, + "snippet_forward", + "fallback", + }, + }, + -- snippets = { + -- expand = function(snippet) + -- require("luasnip").lsp_expand(snippet) + -- end, + -- active = function(filter) + -- if filter and filter.direction then + -- return require("luasnip").jumpable(filter.direction) + -- end + -- return require("luasnip").in_snippet() + -- end, + -- jump = function(direction) + -- require("luasnip").jump(direction) + -- end, + -- }, + sources = { + default = { "lsp", "path", "snippets", "buffer" }, + }, + }, + opts_extend = { "sources.default" }, + }, } diff --git a/nvim/m-housh/lua/user/plugin/cmp.lua b/nvim/m-housh/lua/user/plugin/cmp.lua index a2632a1..1cdbfdb 100755 --- a/nvim/m-housh/lua/user/plugin/cmp.lua +++ b/nvim/m-housh/lua/user/plugin/cmp.lua @@ -1,7 +1,7 @@ return { "hrsh7th/nvim-cmp", - enabled = false, - event = "InsertEnter", + enabled = true, + event = "VeryLazy", dependencies = { "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-buffer", -- source for text in buffer diff --git a/nvim/m-housh/lua/user/plugin/go.lua b/nvim/m-housh/lua/user/plugin/go.lua index 95e2d4a..6b7dabe 100755 --- a/nvim/m-housh/lua/user/plugin/go.lua +++ b/nvim/m-housh/lua/user/plugin/go.lua @@ -1,5 +1,6 @@ return { "ray-x/go.nvim", + enabled = false, lazy = true, dependencies = { -- optional packages "ray-x/guihua.lua", diff --git a/nvim/m-housh/lua/user/plugin/harpoon.lua b/nvim/m-housh/lua/user/plugin/harpoon.lua index 740057e..3112ddb 100644 --- a/nvim/m-housh/lua/user/plugin/harpoon.lua +++ b/nvim/m-housh/lua/user/plugin/harpoon.lua @@ -1,85 +1,86 @@ return { - "ThePrimeagen/harpoon", - branch = "harpoon2", - dependencies = { - "nvim-lua/plenary.nvim", - }, - config = function() - local harpoon = require("harpoon") - harpoon:setup({ - settings = { - save_on_toggle = true, - sync_on_ui_close = true, - key = function() - return vim.loop.cwd() - end, - }, - }) + "ThePrimeagen/harpoon", + branch = "harpoon2", + event = "VeryLazy", + dependencies = { + "nvim-lua/plenary.nvim", + }, + config = function() + local harpoon = require("harpoon") + harpoon:setup({ + settings = { + save_on_toggle = true, + sync_on_ui_close = true, + key = function() + return vim.loop.cwd() + end, + }, + }) - 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 + 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 + 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 - -- Keymaps - vim.keymap.set("n", "", function() - toggle_telescope(harpoon:list()) - end, { desc = "Open Harpoon window" }) + -- Keymaps + vim.keymap.set("n", "", function() + toggle_telescope(harpoon:list()) + end, { desc = "Open Harpoon window" }) - vim.keymap.set("n", "a", function() - harpoon:list():add() - end, { desc = "[A]dd to harpoon list." }) - vim.keymap.set("n", "", function() - harpoon.ui:toggle_quick_menu(harpoon:list()) - end, { desc = "Toggle quick menu." }) + vim.keymap.set("n", "a", function() + harpoon:list():add() + end, { desc = "[A]dd to harpoon list." }) + vim.keymap.set("n", "", function() + harpoon.ui:toggle_quick_menu(harpoon:list()) + end, { desc = "Toggle quick menu." }) - -- Buffer key maps. Currently keeping all buffer movements - -- isolated to top left row of keys on keyboard and all begin - -- with the key. + -- Buffer key maps. Currently keeping all buffer movements + -- isolated to top left row of keys on keyboard and all begin + -- with the key. - -- Select buffer numbers. - vim.keymap.set("n", "", function() - harpoon:list():select(1) - end, { desc = "Select first harpoon buffer." }) - vim.keymap.set("n", "", function() - harpoon:list():select(2) - end, { desc = "Select second harpoon buffer." }) - vim.keymap.set("n", "", function() - harpoon:list():select(3) - end, { desc = "Select third harpoon buffer." }) - vim.keymap.set("n", "", function() - harpoon:list():select(4) - end, { desc = "Select fourth harpoon buffer." }) + -- Select buffer numbers. + vim.keymap.set("n", "", function() + harpoon:list():select(1) + end, { desc = "Select first harpoon buffer." }) + vim.keymap.set("n", "", function() + harpoon:list():select(2) + end, { desc = "Select second harpoon buffer." }) + vim.keymap.set("n", "", function() + harpoon:list():select(3) + end, { desc = "Select third harpoon buffer." }) + vim.keymap.set("n", "", function() + harpoon:list():select(4) + end, { desc = "Select fourth harpoon buffer." }) - -- Toggle previous and next buffers. - vim.keymap.set("n", "", function() - harpoon:list():prev() - end, { desc = "[P]revious harpoon buffer." }) - vim.keymap.set("n", "", function() - harpoon:list():next() - end, { desc = "[N]ext harpoon buffer." }) + -- Toggle previous and next buffers. + vim.keymap.set("n", "", function() + harpoon:list():prev() + end, { desc = "[P]revious harpoon buffer." }) + vim.keymap.set("n", "", function() + harpoon:list():next() + end, { desc = "[N]ext harpoon buffer." }) - -- Extensions - harpoon:extend({ - UI_CREATE = function(cx) - vim.keymap.set("n", "", function() - harpoon.ui:select_menu_item({ vsplit = true }) - end, { buffer = cx.buffer, desc = "Open in [V]split" }) - end, - }) - end, + -- Extensions + harpoon:extend({ + UI_CREATE = function(cx) + vim.keymap.set("n", "", function() + harpoon.ui:select_menu_item({ vsplit = true }) + end, { buffer = cx.buffer, desc = "Open in [V]split" }) + end, + }) + end, } diff --git a/nvim/m-housh/lua/user/plugin/luasnip.lua b/nvim/m-housh/lua/user/plugin/luasnip.lua index 9ee53a8..d61635e 100644 --- a/nvim/m-housh/lua/user/plugin/luasnip.lua +++ b/nvim/m-housh/lua/user/plugin/luasnip.lua @@ -1,6 +1,7 @@ return { "L3MON4D3/LuaSnip", version = "v2.*", + event = "VeryLazy", config = function() local ls = require("luasnip") local types = require("luasnip.util.types") @@ -17,7 +18,7 @@ return { }, }) require("luasnip.loaders.from_vscode").lazy_load() - require("luasnip.loaders.from_lua").lazy_load({ paths = "~/.config/m-housh/lua/user/snippets/" }) + require("luasnip.loaders.from_lua").lazy_load({ paths = vim.fn.stdpath("config") .. "/snippets" }) -- Keymaps local opts = { silent = true } diff --git a/nvim/m-housh/lua/user/plugin/nvim-dap.lua b/nvim/m-housh/lua/user/plugin/nvim-dap.lua index 0aed3df..20ee777 100644 --- a/nvim/m-housh/lua/user/plugin/nvim-dap.lua +++ b/nvim/m-housh/lua/user/plugin/nvim-dap.lua @@ -31,6 +31,7 @@ end return { "mfussenegger/nvim-dap", + --event = "VeryLazy", dependencies = { "wojciech-kulik/xcodebuild.nvim", }, diff --git a/nvim/m-housh/lua/user/plugin/oil.lua b/nvim/m-housh/lua/user/plugin/oil.lua index b0c40e0..673b5ee 100644 --- a/nvim/m-housh/lua/user/plugin/oil.lua +++ b/nvim/m-housh/lua/user/plugin/oil.lua @@ -1,36 +1,68 @@ return { "stevearc/oil.nvim", + event = "VeryLazy", dependencies = { "nvim-tree/nvim-web-devicons", }, - config = function() - require("oil").setup({ - columns = { "icon" }, - keymaps = { - [""] = false, - [""] = "actions.select_split", - [""] = { - "actions.select", - opts = { vertical = true }, - desc = "Open the entry in a vertical split", - }, + opts = { + columns = { "icon" }, + keymaps = { + [""] = false, + [""] = "actions.select_split", + [""] = { + "actions.select", + opts = { vertical = true }, + desc = "Open the entry in a vertical split", }, - view_options = { - is_hidden_file = function(name, _) -- second arg is bufnr, but not currently used. - -- Don't show .DS_Store in output. - local is_ds_store = name ~= ".DS_Store" - return not is_ds_store - end, - }, - }) - + }, + view_options = { + is_hidden_file = function(name, _) -- second arg is bufnr, but not currently used. + -- Don't show .DS_Store in output. + local is_ds_store = name ~= ".DS_Store" + return not is_ds_store + end, + }, + }, + keys = { -- Show the parent directory in current window. - vim.keymap.set("n", "-", "Oil", { desc = "Open parent directory." }) - + { "-", "Oil", desc = "Open directory." }, -- Open parent directory in floating window. - vim.keymap.set("n", "-", require("oil").toggle_float) - - -- Old habits die hard, map what used to toggle neo-tree to just open a float. - vim.keymap.set("n", "", require("oil").toggle_float) - end, + { + "-", + function() + require("oil").toggle_float() + end, + desc = "Open directory in float.", + }, + }, + -- config = function() + -- require("oil").setup({ + -- columns = { "icon" }, + -- keymaps = { + -- [""] = false, + -- [""] = "actions.select_split", + -- [""] = { + -- "actions.select", + -- opts = { vertical = true }, + -- desc = "Open the entry in a vertical split", + -- }, + -- }, + -- view_options = { + -- is_hidden_file = function(name, _) -- second arg is bufnr, but not currently used. + -- -- Don't show .DS_Store in output. + -- local is_ds_store = name ~= ".DS_Store" + -- return not is_ds_store + -- end, + -- }, + -- }) + -- + -- -- Show the parent directory in current window. + -- vim.keymap.set("n", "-", "Oil", { desc = "Open parent directory." }) + -- + -- -- Open parent directory in floating window. + -- vim.keymap.set("n", "-", require("oil").toggle_float) + -- + -- -- Old habits die hard, map what used to toggle neo-tree to just open a float. + -- vim.keymap.set("n", "", require("oil").toggle_float) + -- end, } diff --git a/nvim/m-housh/lua/user/plugin/xcodebuild.lua b/nvim/m-housh/lua/user/plugin/xcodebuild.lua index 4b77bd0..f723a7f 100644 --- a/nvim/m-housh/lua/user/plugin/xcodebuild.lua +++ b/nvim/m-housh/lua/user/plugin/xcodebuild.lua @@ -1,56 +1,57 @@ local progress_handle return { - "wojciech-kulik/xcodebuild.nvim", - --branch = "fix/issue-249", - dependencies = { - "nvim-telescope/telescope.nvim", - "MunifTanjim/nui.nvim", - }, - config = function() - require("xcodebuild").setup({ - show_build_progress_bar = false, - logs = { - auto_open_on_success_tests = false, - auto_open_on_failed_tests = false, - auto_open_on_success_build = false, - auto_open_on_failed_build = false, - auto_focus = false, - auto_close_on_app_launch = true, - only_summary = true, - notify = function(message, severity) - local fidget = require("fidget") - if progress_handle then - progress_handle.message = message - if not message:find("Loading") then - progress_handle:finish() - progress_handle = nil - if vim.trim(message) ~= "" then - fidget.notify(message, severity) - end - end - else - fidget.notify(message, severity) - end - end, - notify_progress = function(message) - local progress = require("fidget.progress") + "wojciech-kulik/xcodebuild.nvim", + event = "VeryLazy", + --branch = "fix/issue-249", + dependencies = { + "nvim-telescope/telescope.nvim", + "MunifTanjim/nui.nvim", + }, + config = function() + require("xcodebuild").setup({ + show_build_progress_bar = false, + logs = { + auto_open_on_success_tests = false, + auto_open_on_failed_tests = false, + auto_open_on_success_build = false, + auto_open_on_failed_build = false, + auto_focus = false, + auto_close_on_app_launch = true, + only_summary = true, + notify = function(message, severity) + local fidget = require("fidget") + if progress_handle then + progress_handle.message = message + if not message:find("Loading") then + progress_handle:finish() + progress_handle = nil + if vim.trim(message) ~= "" then + fidget.notify(message, severity) + end + end + else + fidget.notify(message, severity) + end + end, + notify_progress = function(message) + local progress = require("fidget.progress") - if progress_handle then - progress_handle.title = "" - progress_handle.message = message - else - progress_handle = progress.handle.create({ - message = message, - lsp_client = { name = "xcodebuild.nvim" }, - }) - end - end, - }, - code_coverage = { - enabled = true, - }, - }) + if progress_handle then + progress_handle.title = "" + progress_handle.message = message + else + progress_handle = progress.handle.create({ + message = message, + lsp_client = { name = "xcodebuild.nvim" }, + }) + end + end, + }, + code_coverage = { + enabled = true, + }, + }) -- stylua: ignore start vim.keymap.set("n", "X", "XcodebuildPicker", { desc = "Show Xcodebuild Actions" }) @@ -76,5 +77,5 @@ return { vim.keymap.set("n", "xx", "XcodebuildQuickfixLine", { desc = "Quickfix Line" }) vim.keymap.set("n", "xa", "XcodebuildCodeActions", { desc = "Show Code Actions" }) - end, + end, } diff --git a/nvim/m-housh/lua/user/plugins.lua b/nvim/m-housh/lua/user/plugins.lua index b2cfc8d..6c4bfeb 100755 --- a/nvim/m-housh/lua/user/plugins.lua +++ b/nvim/m-housh/lua/user/plugins.lua @@ -28,21 +28,12 @@ require("lazy").setup({ "christoomey/vim-tmux-navigator", lazy = false, }, - -- { - -- "NMAC427/guess-indent.nvim", - -- opts = { } - -- }, { "NoahTheDuke/vim-just", ft = { "just" } }, { "chipsenkbeil/distant.nvim", - branch = "v0.3", - config = function() - require("distant"):setup() - end, + version = "v0.*", + event = "VeryLazy", }, - - -- LSP, formatting, etc. -- - --{ "folke/neodev.nvim", opts = {} }, }, { checker = { enabled = true, diff --git a/nvim/m-housh/snippets/init.lua b/nvim/m-housh/snippets/init.lua new file mode 100644 index 0000000..9028086 --- /dev/null +++ b/nvim/m-housh/snippets/init.lua @@ -0,0 +1,17 @@ +-- Setup snippets here. +local ls = require("luasnip") +local s = ls.snippet +local sn = ls.snippet_node +local ms = ls.multi_snippet +local i = ls.insert_node +local f = ls.function_node +local c = ls.choice_node +local t = ls.text_node + +ls.add_snippets("lua", { + s("hello", { + t('print("hello '), + i(1), + t(' world")'), + }), +}) diff --git a/nvim/m-housh/snippets/lua.lua b/nvim/m-housh/snippets/lua.lua new file mode 100644 index 0000000..f0db2c0 --- /dev/null +++ b/nvim/m-housh/snippets/lua.lua @@ -0,0 +1,34 @@ +-- Setup snippets here. +local ls = require("luasnip") +local s = ls.snippet +local sn = ls.snippet_node +local ms = ls.multi_snippet +local i = ls.insert_node +local f = ls.function_node +local c = ls.choice_node +local t = ls.text_node + +ls.add_snippets("lua", { + -- Setup a new snippet file. + s("sf", { + t({ + "-- Setup snippets.", + 'local ls = require("luasnip")', + "local s = ls.snippet", + "local sn = ls.snippet_node", + "local ms = ls.multi_snippet", + "local i = ls.insert_node", + "local f = ls.function_node", + "local c = ls.choice_node", + "local t = ls.text_node", + "-- Add snippets", + }), + t('ls.add_snippets("'), + i(1, ""), + t({ + '", {', + "\t-- Define snippets here.", + "})", + }), + }), +}) diff --git a/nvim/m-housh/snippets/swift.lua b/nvim/m-housh/snippets/swift.lua new file mode 100644 index 0000000..b073696 --- /dev/null +++ b/nvim/m-housh/snippets/swift.lua @@ -0,0 +1,131 @@ +-- Setup snippets. +local ls = require("luasnip") +local s = ls.snippet +local sn = ls.snippet_node +local ms = ls.multi_snippet +local i = ls.insert_node +local f = ls.function_node +local c = ls.choice_node +local t = ls.text_node +local fmt = require("luasnip.extras.fmt").fmt +local rep = require("luasnip.extras").rep +-- Add snippets +ls.add_snippets("swift", { + -- Add a dependency snippet. + s({ trig = "@d", desc = "Add a dependency." }, fmt("@Dependency(\\.{}) var {}", { i(1), rep(1) })), + + -- Add a dependency client. + s( + { + trig = "@dc", + desc = "Add a dependency client.", + }, + fmt( + [[ + public extension DependencyValues {{ + var {}: {} {{ + get {{ self[{}.self] }} + set {{ self[{}.self] = newValue }} + }} + }} + + @DependencyClient + public struct {} {{ + + // Insert interface here. + {} + }} + + extension {}: TestDependencyKey {{ + public static let testValue: {} = Self() + }} + + ]], + { + i(1, ""), + i(2, ""), + rep(2), + rep(2), + rep(2), + i(0), + rep(2), + rep(2), + } + ) + ), + + s( + { trig = "str", desc = "Add a struct" }, + fmt( + [[ + struct {}: {} {{ + {} + }} + ]], + { i(1, ""), i(2, ""), i(0) } + ) + ), + + -- Decorate a type or function with an @_spi(...) + s({ trig = "@_s", desc = "Add spi modifier." }, fmt("@_spi({})", { i(1, "name") })), + + -- Add an @_spi(...) import ... + s( + { trig = "@_si", desc = "Import with spi." }, + fmt( + [[ + @_spi({}) import {} + {} + ]], + { i(1, "name"), i(2, "module"), i(0) } + ) + ), + + -- Document a function + -- TODO: add dynamic number of prameters. + s( + { trig = "docf", desc = "Document a function." }, + fmt( + [[ + /// {} + /// + /// - Parameters: + /// - {}: {} + ]], + { i(1, "A short description."), i(2, ""), i(3, "Describe the parameter.") } + ) + ), + + -- Add a parameter to a documentation string. + s( + { trig = "param", desc = "Add a parameter to documentation" }, + fmt( + [[ + /// - {}: {} + ]], + { i(1, ""), i(2, "") } + ) + ), + + -- Add a withDependencies + s( + { trig = "wd", desc = "withDependencies" }, + fmt( + [[ + withDependencies {{ + $0.{} = {} + }} operation: {{ + @Dependency(\.{}) var {} + {} + }} + ]], + { + i(1, ""), + i(2, ""), + rep(1), + rep(1), + i(0), + } + ) + ), +})