mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-15 06:32:40 +00:00
feat: Updates to nvim config and snippets
This commit is contained in:
@@ -16,9 +16,3 @@ require("user.theme")
|
|||||||
|
|
||||||
-- Common settings
|
-- Common settings
|
||||||
require("user.settings")
|
require("user.settings")
|
||||||
|
|
||||||
-- Snippets are setup in the luasnip settings, they get loaded from the snippets directory
|
|
||||||
-- based on filetype.
|
|
||||||
--require("user.snippets")
|
|
||||||
|
|
||||||
vim.o.shiftwidth = 2
|
|
||||||
|
|||||||
@@ -1,85 +1,41 @@
|
|||||||
local defaultGroupOptions = { clear = true }
|
local defaultGroupOptions = { clear = true }
|
||||||
local markdownGroup = vim.api.nvim_create_augroup("MyMarkdownGroup", defaultGroupOptions)
|
local markdownGroup = vim.api.nvim_create_augroup("MyMarkdownGroup", defaultGroupOptions)
|
||||||
local spellGroup = vim.api.nvim_create_augroup('SpellGroup', defaultGroupOptions)
|
local spellGroup = vim.api.nvim_create_augroup("SpellGroup", defaultGroupOptions)
|
||||||
local createCmd = vim.api.nvim_create_autocmd
|
local createCmd = vim.api.nvim_create_autocmd
|
||||||
local swiftGroup = vim.api.nvim_create_augroup('swift_lsp', { clear = true })
|
|
||||||
|
|
||||||
-- Remove all trailing whitespace on save
|
|
||||||
vim.api.nvim_exec([[
|
|
||||||
augroup TrimWhiteSpace
|
|
||||||
au!
|
|
||||||
autocmd BufWritePre * :%s/\s\+$//e
|
|
||||||
augroup END
|
|
||||||
]], false)
|
|
||||||
|
|
||||||
-- Prevent new line to also start with a comment
|
|
||||||
vim.api.nvim_exec([[
|
|
||||||
augroup NewLineComment
|
|
||||||
au!
|
|
||||||
au FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
|
|
||||||
augroup END
|
|
||||||
]], false)
|
|
||||||
|
|
||||||
-- Spell check
|
-- Spell check
|
||||||
createCmd(
|
createCmd("BufEnter", {
|
||||||
"BufEnter",
|
pattern = { "*.md", "*.markdown", "*.txt", "*.tex" },
|
||||||
{
|
|
||||||
pattern = { '*.md', '*.markdown', '*.txt', '*.tex' },
|
|
||||||
group = spellGroup,
|
group = spellGroup,
|
||||||
callback = function(_)
|
callback = function(_)
|
||||||
vim.cmd.setlocal('textwidth=80')
|
vim.cmd.setlocal("textwidth=80")
|
||||||
vim.cmd.setlocal('spell spelllang=en_us')
|
vim.cmd.setlocal("spell spelllang=en_us")
|
||||||
end,
|
end,
|
||||||
}
|
})
|
||||||
)
|
|
||||||
|
|
||||||
-- Markdown
|
-- Markdown
|
||||||
createCmd(
|
createCmd("BufWritePost", {
|
||||||
"BufWritePost",
|
|
||||||
{
|
|
||||||
pattern = { "*.md", "*.markdown" },
|
pattern = { "*.md", "*.markdown" },
|
||||||
group = markdownGroup,
|
group = markdownGroup,
|
||||||
callback = function(_)
|
callback = function(_)
|
||||||
local cursor = vim.fn.getpos('.')
|
local cursor = vim.fn.getpos(".")
|
||||||
vim.cmd("FormatWrite")
|
vim.cmd("FormatWrite")
|
||||||
vim.fn.setpos('.', cursor)
|
vim.fn.setpos(".", cursor)
|
||||||
end,
|
end,
|
||||||
}
|
})
|
||||||
)
|
|
||||||
|
|
||||||
-- Go
|
-- Go
|
||||||
createCmd(
|
createCmd("BufWritePre", {
|
||||||
"BufWritePre",
|
|
||||||
{
|
|
||||||
pattern = "*.go",
|
pattern = "*.go",
|
||||||
callback = function()
|
callback = function()
|
||||||
require('go.format').goimport()
|
require("go.format").goimport()
|
||||||
end,
|
end,
|
||||||
group = vim.api.nvim_create_augroup("GoFormat", defaultGroupOptions)
|
group = vim.api.nvim_create_augroup("GoFormat", defaultGroupOptions),
|
||||||
}
|
})
|
||||||
)
|
|
||||||
|
|
||||||
vim.api.nvim_exec([[
|
vim.api.nvim_exec2(
|
||||||
|
[[
|
||||||
autocmd BufNewFile,BufRead /private/**/gopass** setlocal noswapfile nobackup noundofile shada=""
|
autocmd BufNewFile,BufRead /private/**/gopass** setlocal noswapfile nobackup noundofile shada=""
|
||||||
]], false)
|
]],
|
||||||
|
{}
|
||||||
-- Swift
|
)
|
||||||
-- createCmd(
|
|
||||||
-- "FileType",
|
|
||||||
-- {
|
|
||||||
-- pattern = { 'swift' },
|
|
||||||
-- callback = function()
|
|
||||||
-- local root_dir = vim.fs.dirname(vim.fs.find({
|
|
||||||
-- "Package.swift",
|
|
||||||
-- ".git",
|
|
||||||
-- }, { upward = true })[1])
|
|
||||||
-- local client = vim.lsp.start({
|
|
||||||
-- name = "sourcekit-lsp",
|
|
||||||
-- cmd = { "sourcekit-lsp" },
|
|
||||||
-- root_dir = root_dir
|
|
||||||
-- })
|
|
||||||
-- vim.lsp.buf_attach_client(0, client)
|
|
||||||
-- end,
|
|
||||||
-- group = swiftGroup
|
|
||||||
-- }
|
|
||||||
-- )
|
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ wk_add("n", {
|
|||||||
|
|
||||||
{ "<leader>n", "<CMD>:noh<CR>", desc = "[N]o highlighting" },
|
{ "<leader>n", "<CMD>:noh<CR>", desc = "[N]o highlighting" },
|
||||||
{ "<leader>s", "<CMD>:set spell!<CR>", desc = "[S]pell check toggle" },
|
{ "<leader>s", "<CMD>:set spell!<CR>", desc = "[S]pell check toggle" },
|
||||||
--{ "<C-n>", "<CMD>:Neotree toggle<CR>", desc = "Toggle Neotree" },
|
|
||||||
{ "<C-s>", "<CMD>:write<CR>", desc = "[S]ave" },
|
{ "<C-s>", "<CMD>:write<CR>", desc = "[S]ave" },
|
||||||
|
|
||||||
{ "J", ":move .+1<CR>==", desc = "Move line down" },
|
{ "J", ":move .+1<CR>==", desc = "Move line down" },
|
||||||
@@ -62,14 +61,7 @@ wk_add("n", {
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- Visual Mode
|
-- Visual Mode
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- wk_add("v", {
|
|
||||||
-- { "p", "\"_dP", desc = "[P]aste" },
|
|
||||||
-- })
|
|
||||||
|
|
||||||
-- wk_add("v", {
|
|
||||||
-- { "K", ":move '<-2<CR>", desc = "Move selected block up" },
|
|
||||||
-- { "J", ":move '>+1<CR>", desc = "Move selected block down" },
|
|
||||||
-- })
|
|
||||||
vim.keymap.set("v", "K", ":move '<-2<CR>gv=gv", { desc = "Move selected block up.", silent = true, noremap = true })
|
vim.keymap.set("v", "K", ":move '<-2<CR>gv=gv", { desc = "Move selected block up.", silent = true, noremap = true })
|
||||||
vim.keymap.set("v", "J", ":move '>+1<CR>gv=gv", { desc = "Move selected block up.", silent = true, noremap = true })
|
vim.keymap.set("v", "J", ":move '>+1<CR>gv=gv", { desc = "Move selected block up.", silent = true, noremap = true })
|
||||||
|
|
||||||
@@ -79,33 +71,3 @@ function _G.set_terminal_keymaps()
|
|||||||
keymap("t", "<esc>", [[<C-\><C-n>]], opts)
|
keymap("t", "<esc>", [[<C-\><C-n>]], opts)
|
||||||
end
|
end
|
||||||
vim.cmd("autocmd! TermOpen term://* lua set_terminal_keymaps()")
|
vim.cmd("autocmd! TermOpen term://* lua set_terminal_keymaps()")
|
||||||
|
|
||||||
-- LuaSnip Keymaps
|
|
||||||
--local ls = require('luasnip')
|
|
||||||
|
|
||||||
-- <c-k> to expand snippets.
|
|
||||||
-- This will expand the snippet or jump to the next item within the snippet.
|
|
||||||
-- vim.keymap.set({ "i", "s" }, "<c-k>", function()
|
|
||||||
-- if ls.expand_or_jumpable() then
|
|
||||||
-- ls.expand_or_jump()
|
|
||||||
-- end
|
|
||||||
-- end, { silent = true })
|
|
||||||
|
|
||||||
-- <c-j>
|
|
||||||
-- This will jump backwards in the snippet.
|
|
||||||
-- vim.keymap.set({ "i", "s" }, "<c-j>", function()
|
|
||||||
-- if ls.jumpable(-1) then
|
|
||||||
-- ls.jump(-1)
|
|
||||||
-- end
|
|
||||||
-- end, { silent = true })
|
|
||||||
|
|
||||||
-- <c-l>
|
|
||||||
-- This is for selecting withing a list of options.
|
|
||||||
-- vim.keymap.set("i", "<c-l>", function()
|
|
||||||
-- if ls.choice_active() then
|
|
||||||
-- ls.change_choice(1)
|
|
||||||
-- end
|
|
||||||
-- end, { silent = true })
|
|
||||||
|
|
||||||
-- Reload the snippets.
|
|
||||||
--vim.keymap.set("n", "<leader><leader>s", "<cmd>source ~/.config/m-housh/lua/snippets/init.lua<cr>")
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ return {
|
|||||||
local luasnip = require("luasnip")
|
local luasnip = require("luasnip")
|
||||||
local lspkind = require("lspkind")
|
local lspkind = require("lspkind")
|
||||||
|
|
||||||
|
-- TODO: This is implemented in LuaSnip config, does it need to be here?
|
||||||
|
|
||||||
-- loads vscode style snippets from installed plugins (e.g. friendly-snippets)
|
-- loads vscode style snippets from installed plugins (e.g. friendly-snippets)
|
||||||
require("luasnip.loaders.from_vscode").lazy_load()
|
require("luasnip.loaders.from_vscode").lazy_load()
|
||||||
|
|
||||||
@@ -32,6 +34,9 @@ return {
|
|||||||
["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions
|
["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions
|
||||||
["<C-e>"] = cmp.mapping.abort(), -- close completion window
|
["<C-e>"] = cmp.mapping.abort(), -- close completion window
|
||||||
["<CR>"] = cmp.mapping.confirm({ select = false, behavior = cmp.ConfirmBehavior.Replace }),
|
["<CR>"] = cmp.mapping.confirm({ select = false, behavior = cmp.ConfirmBehavior.Replace }),
|
||||||
|
-- TODO:
|
||||||
|
-- The next two mappings are also implemented in the LuaSnip configuration,
|
||||||
|
-- as <C-j> and <C-k> do they actually need to be here??
|
||||||
["<C-b>"] = cmp.mapping(function(fallback)
|
["<C-b>"] = cmp.mapping(function(fallback)
|
||||||
if luasnip.jumpable(-1) then
|
if luasnip.jumpable(-1) then
|
||||||
luasnip.jump(-1)
|
luasnip.jump(-1)
|
||||||
|
|||||||
@@ -1,31 +1,2 @@
|
|||||||
-- This file contains plugin's that don't require much configuration.
|
-- This file contains plugin's that don't require much configuration.
|
||||||
return {
|
return {}
|
||||||
-- {
|
|
||||||
-- "L3MON4D3/LuaSnip",
|
|
||||||
-- version = "2.*",
|
|
||||||
-- build = "make install_jsregexp",
|
|
||||||
-- event = { 'BufReadPre', 'BufNewFile' },
|
|
||||||
-- config = function()
|
|
||||||
-- local luasnip = require('luasnip')
|
|
||||||
-- local types = require('luasnip.util.types')
|
|
||||||
-- luasnip.config.set_config {
|
|
||||||
-- history = true,
|
|
||||||
-- updateevents = "TextChanged,TextChangedI",
|
|
||||||
-- enable_autosnippets = true,
|
|
||||||
-- ext_opts = {
|
|
||||||
-- [types.choiceNode] = {
|
|
||||||
-- active = {
|
|
||||||
-- virt_text = { { "<-", "Error" } },
|
|
||||||
-- },
|
|
||||||
-- },
|
|
||||||
-- },
|
|
||||||
-- }
|
|
||||||
-- end
|
|
||||||
-- },
|
|
||||||
{
|
|
||||||
"hrsh7th/vim-vsnip",
|
|
||||||
config = function()
|
|
||||||
vim.g.vsnip_snippet_dir = os.getenv('HOME') .. '/.config/m-housh/lua/snippets/'
|
|
||||||
end
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ return {
|
|||||||
-- more details: https://github.com/neovim/neovim/issues/19237#issuecomment-2237037154
|
-- more details: https://github.com/neovim/neovim/issues/19237#issuecomment-2237037154
|
||||||
client.offset_encoding = "utf-8"
|
client.offset_encoding = "utf-8"
|
||||||
end,
|
end,
|
||||||
|
cmd = lsp == "sourcekit" and { vim.trim(vim.fn.system("xcrun -f sourcekit-lsp")) } or nil,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -84,6 +85,7 @@ return {
|
|||||||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
|
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- For some reason I was having trouble getting this to work inside the on-attach, so it's here.
|
||||||
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, { desc = "[R]e-[N]ame" })
|
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, { desc = "[R]e-[N]ame" })
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,9 +11,8 @@ return {
|
|||||||
["<M-h>"] = "actions.select_split",
|
["<M-h>"] = "actions.select_split",
|
||||||
},
|
},
|
||||||
view_options = {
|
view_options = {
|
||||||
--show_hidden = true,
|
is_hidden_file = function(name, _) -- second arg is bufnr, but not currently used.
|
||||||
is_hidden_file = function(name, bufnr)
|
-- Don't show .DS_Store in output.
|
||||||
-- Don't show .DS_STORE in output.
|
|
||||||
local is_ds_store = name ~= ".DS_Store"
|
local is_ds_store = name ~= ".DS_Store"
|
||||||
return not is_ds_store
|
return not is_ds_store
|
||||||
end,
|
end,
|
||||||
@@ -25,5 +24,8 @@ return {
|
|||||||
|
|
||||||
-- Open parent directory in floating window.
|
-- Open parent directory in floating window.
|
||||||
vim.keymap.set("n", "<space>-", require("oil").toggle_float)
|
vim.keymap.set("n", "<space>-", require("oil").toggle_float)
|
||||||
|
|
||||||
|
-- Old habits die hard, map what used to toggle neo-tree to just open a float.
|
||||||
|
vim.keymap.set("n", "<C-n>", require("oil").toggle_float)
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,14 +27,18 @@ return {
|
|||||||
},
|
},
|
||||||
mappings = {
|
mappings = {
|
||||||
i = {
|
i = {
|
||||||
-- Close on first esc instead of gonig to normal mode
|
-- Close on first esc instead of going to normal mode
|
||||||
["<esc>"] = actions.close,
|
["<esc>"] = actions.close,
|
||||||
["<A-q>"] = actions.send_selected_to_qflist,
|
["<A-q>"] = actions.send_selected_to_qflist,
|
||||||
["<C-q>"] = actions.send_to_qflist,
|
["<C-q>"] = actions.send_to_qflist,
|
||||||
["<s-tab>"] = actions.toggle_selection + actions.move_selection_next,
|
["<s-tab>"] = actions.toggle_selection + actions.move_selection_next,
|
||||||
["<tab>"] = actions.toggle_selection + actions.move_selection_previous,
|
["<tab>"] = actions.toggle_selection + actions.move_selection_previous,
|
||||||
|
["<C-j>"] = actions.move_selection_next,
|
||||||
|
["<C-k>"] = actions.move_selection_previous,
|
||||||
},
|
},
|
||||||
n = {
|
n = {
|
||||||
|
["<C-j>"] = actions.move_selection_next,
|
||||||
|
["<C-k>"] = actions.move_selection_previous,
|
||||||
["<s-tab>"] = actions.toggle_selection + actions.move_selection_next,
|
["<s-tab>"] = actions.toggle_selection + actions.move_selection_next,
|
||||||
["<tab>"] = actions.toggle_selection + actions.move_selection_previous,
|
["<tab>"] = actions.toggle_selection + actions.move_selection_previous,
|
||||||
["<A-q>"] = actions.send_selected_to_qflist,
|
["<A-q>"] = actions.send_selected_to_qflist,
|
||||||
|
|||||||
@@ -77,46 +77,3 @@ return {
|
|||||||
vim.keymap.set("n", "<leader>xa", "<cmd>XcodebuildCodeActions<cr>", { desc = "Show Code Actions" })
|
vim.keymap.set("n", "<leader>xa", "<cmd>XcodebuildCodeActions<cr>", { desc = "Show Code Actions" })
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
-- return {
|
|
||||||
-- "wojciech-kulik/xcodebuild.nvim",
|
|
||||||
-- dependencies = {
|
|
||||||
-- "nvim-telescope/telescope.nvim",
|
|
||||||
-- "MunifTanjim/nui.nvim",
|
|
||||||
-- "nvim-neo-tree/neo-tree.nvim", -- (optional) to manage project files
|
|
||||||
-- "stevearc/oil.nvim", -- (optional) to manage project files
|
|
||||||
-- "nvim-treesitter/nvim-treesitter", -- (optional) for Quick tests support (required Swift parser)
|
|
||||||
-- },
|
|
||||||
-- config = function()
|
|
||||||
-- require("xcodebuild").setup({
|
|
||||||
-- -- put some options here or leave it empty to use default settings
|
|
||||||
-- code_coverage = {
|
|
||||||
-- enabled = true
|
|
||||||
-- }
|
|
||||||
-- })
|
|
||||||
--
|
|
||||||
-- vim.keymap.set("n", "<leader>X", "<cmd>XcodebuildPicker<cr>", { desc = "Show Xcodebuild Actions" })
|
|
||||||
-- vim.keymap.set("n", "<leader>xf", "<cmd>XcodebuildProjectManager<cr>", { desc = "Show Project Manager Actions" })
|
|
||||||
--
|
|
||||||
-- vim.keymap.set("n", "<leader>xb", "<cmd>XcodebuildBuild<cr>", { desc = "Build Project" })
|
|
||||||
-- vim.keymap.set("n", "<leader>xB", "<cmd>XcodebuildBuildForTesting<cr>", { desc = "Build For Testing" })
|
|
||||||
-- vim.keymap.set("n", "<leader>xr", "<cmd>XcodebuildBuildRun<cr>", { desc = "Build & Run Project" })
|
|
||||||
--
|
|
||||||
-- vim.keymap.set("n", "<leader>xt", "<cmd>XcodebuildTest<cr>", { desc = "Run Tests" })
|
|
||||||
-- vim.keymap.set("v", "<leader>xt", "<cmd>XcodebuildTestSelected<cr>", { desc = "Run Selected Tests" })
|
|
||||||
-- vim.keymap.set("n", "<leader>xT", "<cmd>XcodebuildTestClass<cr>", { desc = "Run Current Test Class" })
|
|
||||||
-- vim.keymap.set("n", "<leader>x.", "<cmd>XcodebuildTestRepeat<cr>", { desc = "Repeat Last Test Run" })
|
|
||||||
--
|
|
||||||
-- vim.keymap.set("n", "<leader>xl", "<cmd>XcodebuildToggleLogs<cr>", { desc = "Toggle Xcodebuild Logs" })
|
|
||||||
-- vim.keymap.set("n", "<leader>xc", "<cmd>XcodebuildToggleCodeCoverage<cr>", { desc = "Toggle Code Coverage" })
|
|
||||||
-- vim.keymap.set("n", "<leader>xC", "<cmd>XcodebuildShowCodeCoverageReport<cr>", { desc = "Show Code Coverage Report" })
|
|
||||||
-- vim.keymap.set("n", "<leader>xe", "<cmd>XcodebuildTestExplorerToggle<cr>", { desc = "Toggle Test Explorer" })
|
|
||||||
-- vim.keymap.set("n", "<leader>xs", "<cmd>XcodebuildFailingSnapshots<cr>", { desc = "Show Failing Snapshots" })
|
|
||||||
--
|
|
||||||
-- vim.keymap.set("n", "<leader>xd", "<cmd>XcodebuildSelectDevice<cr>", { desc = "Select Device" })
|
|
||||||
-- vim.keymap.set("n", "<leader>xp", "<cmd>XcodebuildSelectTestPlan<cr>", { desc = "Select Test Plan" })
|
|
||||||
-- vim.keymap.set("n", "<leader>xq", "<cmd>Telescope quickfix<cr>", { desc = "Show QuickFix List" })
|
|
||||||
--
|
|
||||||
-- vim.keymap.set("n", "<leader>xx", "<cmd>XcodebuildQuickfixLine<cr>", { desc = "Quickfix Line" })
|
|
||||||
-- vim.keymap.set("n", "<leader>xa", "<cmd>XcodebuildCodeActions<cr>", { desc = "Show Code Actions" })
|
|
||||||
-- end,
|
|
||||||
-- }
|
|
||||||
|
|||||||
@@ -14,44 +14,43 @@ vim.opt.rtp:prepend(lazypath)
|
|||||||
|
|
||||||
require("lazy").setup({
|
require("lazy").setup({
|
||||||
dev = {
|
dev = {
|
||||||
path = '~/LocalProjects/plugins',
|
path = "~/LocalProjects/plugins",
|
||||||
fallback = true
|
fallback = true,
|
||||||
},
|
},
|
||||||
-- Import all the plugin configs in the 'plugin' directory
|
-- Import all the plugin configs in the 'plugin' directory
|
||||||
{ import = 'user.plugin' },
|
{ import = "user.plugin" },
|
||||||
-- Plugins that don't have a configuration file.
|
-- Plugins that don't have a configuration file.
|
||||||
{
|
{
|
||||||
"folke/zen-mode.nvim",
|
"folke/zen-mode.nvim",
|
||||||
opts = { }
|
opts = {},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"christoomey/vim-tmux-navigator",
|
"christoomey/vim-tmux-navigator",
|
||||||
lazy = false,
|
lazy = false,
|
||||||
},
|
},
|
||||||
{
|
-- {
|
||||||
"NMAC427/guess-indent.nvim",
|
-- "NMAC427/guess-indent.nvim",
|
||||||
opts = { }
|
-- opts = { }
|
||||||
},
|
-- },
|
||||||
{ "NoahTheDuke/vim-just", ft = { "just" } },
|
{ "NoahTheDuke/vim-just", ft = { "just" } },
|
||||||
{
|
{
|
||||||
'chipsenkbeil/distant.nvim',
|
"chipsenkbeil/distant.nvim",
|
||||||
branch = 'v0.3',
|
branch = "v0.3",
|
||||||
config = function()
|
config = function()
|
||||||
require('distant'):setup()
|
require("distant"):setup()
|
||||||
end
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- LSP, formatting, etc. --
|
-- LSP, formatting, etc. --
|
||||||
{ 'folke/neodev.nvim', opts = {} },
|
{ "folke/neodev.nvim", opts = {} },
|
||||||
|
|
||||||
}, {
|
}, {
|
||||||
checker = {
|
checker = {
|
||||||
enabled = true,
|
enabled = true,
|
||||||
notify = false
|
notify = false,
|
||||||
},
|
},
|
||||||
change_detection = {
|
change_detection = {
|
||||||
notify = false
|
notify = false,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>ll", "<CMD>Lazy<CR>", { desc = "Open [L]azy" })
|
vim.keymap.set("n", "<leader>ll", "<CMD>Lazy<CR>", { desc = "Open [L]azy" })
|
||||||
|
|||||||
@@ -15,50 +15,110 @@ ls.add_snippets("swift", {
|
|||||||
s("@d", fmt("@Dependency(\\.{}) var {}", { i(1), rep(1) })),
|
s("@d", fmt("@Dependency(\\.{}) var {}", { i(1), rep(1) })),
|
||||||
|
|
||||||
-- Add a dependency client.
|
-- Add a dependency client.
|
||||||
s("@dc", fmt([[
|
s(
|
||||||
|
{
|
||||||
|
trig = "@dc",
|
||||||
|
desc = "Add a dependency client.",
|
||||||
|
},
|
||||||
|
fmt(
|
||||||
|
[[
|
||||||
public extension DependencyValues {{
|
public extension DependencyValues {{
|
||||||
var {}: {} {{
|
var {}: {} {{
|
||||||
get: {{ self[{}.self] }}
|
get {{ self[{}.self] }}
|
||||||
set: {{ self[{}.self] = newValue }}
|
set {{ self[{}.self] = newValue }}
|
||||||
}}
|
}}
|
||||||
}}
|
}}
|
||||||
|
|
||||||
@DependencyClient
|
@DependencyClient
|
||||||
struct {} {{
|
public struct {} {{
|
||||||
|
|
||||||
// Insert interface here.
|
// Insert interface here.
|
||||||
|
{}
|
||||||
}}
|
}}
|
||||||
|
|
||||||
extension {}: TestDependencyKey {{
|
extension {}: TestDependencyKey {{
|
||||||
static let testValue: {} = Self()
|
public static let testValue: {} = Self()
|
||||||
}}
|
}}
|
||||||
|
|
||||||
]], {
|
]],
|
||||||
i(1, "<var-name>"),
|
{
|
||||||
i(2, "<Type>"),
|
i(1, "<name>"),
|
||||||
|
i(2, "<Dependency>"),
|
||||||
rep(2),
|
rep(2),
|
||||||
rep(2),
|
rep(2),
|
||||||
rep(2),
|
rep(2),
|
||||||
|
i(0),
|
||||||
rep(2),
|
rep(2),
|
||||||
rep(2),
|
rep(2),
|
||||||
})
|
}
|
||||||
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
-- Add spi modifier snippet.
|
s(
|
||||||
s("spi", fmt("@_spi({})", { i(1, "name") })),
|
{ trig = "str", desc = "Add a struct" },
|
||||||
|
fmt(
|
||||||
|
[[
|
||||||
|
struct {}: {} {{
|
||||||
|
{}
|
||||||
|
}}
|
||||||
|
]],
|
||||||
|
{ i(1, "<Name>"), i(2, "<Protocols>"), i(0) }
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
-- Add spi import modifier snippet.
|
s({ trig = "spi", desc = "Add spi modifier." }, fmt("@_spi({})", { i(1, "name") })),
|
||||||
s("sii", fmt("@_spi({}) import {}", { i(1, "name"), i(2, "modlue") })),
|
|
||||||
|
|
||||||
-- Document a function.
|
s(
|
||||||
s("doc", fmt([[
|
{ trig = "sii", desc = "Import with spi." },
|
||||||
|
fmt(
|
||||||
|
[[
|
||||||
|
@_spi({}) import {}
|
||||||
|
{}
|
||||||
|
]],
|
||||||
|
{ i(1, "name"), i(2, "modlue"), i(0) }
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
|
s(
|
||||||
|
{ trig = "docf", desc = "Document a function." },
|
||||||
|
fmt(
|
||||||
|
[[
|
||||||
/// {}
|
/// {}
|
||||||
///
|
///
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - {}: {}
|
/// - {}: {}
|
||||||
]], { i(1, "A short description."), i(2, "<param>"), i(3, "<param-description>") }
|
]],
|
||||||
)),
|
{ i(1, "A short description."), i(2, "<param>"), i(3, "<param-description>") }
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
s("param", fmt([[
|
s(
|
||||||
|
{ trig = "param", desc = "Add a parameter to documentation" },
|
||||||
|
fmt(
|
||||||
|
[[
|
||||||
/// - {}: {}
|
/// - {}: {}
|
||||||
]], { i(1, "<param>"), i(2, "<description>") })),
|
]],
|
||||||
|
{ i(1, "<param>"), i(2, "<description>") }
|
||||||
|
)
|
||||||
|
),
|
||||||
|
s(
|
||||||
|
{ trig = "wd", desc = "withDependencies" },
|
||||||
|
fmt(
|
||||||
|
[[
|
||||||
|
withDependencies {{
|
||||||
|
$0.{} = {}
|
||||||
|
}} operation: {{
|
||||||
|
@Dependency(\.{}) var {}
|
||||||
|
{}
|
||||||
|
}}
|
||||||
|
]],
|
||||||
|
{
|
||||||
|
i(1, "<dependency>"),
|
||||||
|
i(2, "<override>"),
|
||||||
|
rep(1),
|
||||||
|
rep(1),
|
||||||
|
i(0),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
),
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user