From 0731db083306232e7e3376e0a59652a9fda4e281 Mon Sep 17 00:00:00 2001 From: erius Date: Mon, 21 Oct 2024 11:08:26 +0300 Subject: [PATCH] First commit --- .config/nvim/init.lua | 7 ++ .config/nvim/lazy-lock.json | 33 +++++++++ .config/nvim/lua/config/keymaps.lua | 9 +++ .config/nvim/lua/config/langmap.lua | 15 ++++ .config/nvim/lua/config/lazy.lua | 17 +++++ .config/nvim/lua/config/options.lua | 25 +++++++ .config/nvim/lua/plugins/autopairs.lua | 6 ++ .config/nvim/lua/plugins/bufferline.lua | 21 ++++++ .config/nvim/lua/plugins/conform.lua | 15 ++++ .config/nvim/lua/plugins/go.lua | 22 ++++++ .config/nvim/lua/plugins/init.lua | 8 ++ .config/nvim/lua/plugins/langmapper.lua | 8 ++ .config/nvim/lua/plugins/lsp.lua | 98 +++++++++++++++++++++++++ .config/nvim/lua/plugins/lualine.lua | 7 ++ .config/nvim/lua/plugins/mdpreview.lua | 9 +++ .config/nvim/lua/plugins/neoclip.lua | 11 +++ .config/nvim/lua/plugins/surround.lua | 6 ++ .config/nvim/lua/plugins/telescope.lua | 18 +++++ .config/nvim/lua/plugins/theme.lua | 17 +++++ .config/nvim/lua/plugins/tree.lua | 19 +++++ .config/nvim/lua/plugins/treesitter.lua | 14 ++++ .config/nvim/lua/plugins/trouble.lua | 37 ++++++++++ .config/nvim/snippets/package.json | 13 ++++ .config/nvim/snippets/rust.json | 34 +++++++++ 24 files changed, 469 insertions(+) create mode 100644 .config/nvim/init.lua create mode 100644 .config/nvim/lazy-lock.json create mode 100644 .config/nvim/lua/config/keymaps.lua create mode 100644 .config/nvim/lua/config/langmap.lua create mode 100644 .config/nvim/lua/config/lazy.lua create mode 100644 .config/nvim/lua/config/options.lua create mode 100644 .config/nvim/lua/plugins/autopairs.lua create mode 100644 .config/nvim/lua/plugins/bufferline.lua create mode 100644 .config/nvim/lua/plugins/conform.lua create mode 100644 .config/nvim/lua/plugins/go.lua create mode 100644 .config/nvim/lua/plugins/init.lua create mode 100644 .config/nvim/lua/plugins/langmapper.lua create mode 100644 .config/nvim/lua/plugins/lsp.lua create mode 100644 .config/nvim/lua/plugins/lualine.lua create mode 100644 .config/nvim/lua/plugins/mdpreview.lua create mode 100644 .config/nvim/lua/plugins/neoclip.lua create mode 100644 .config/nvim/lua/plugins/surround.lua create mode 100644 .config/nvim/lua/plugins/telescope.lua create mode 100644 .config/nvim/lua/plugins/theme.lua create mode 100644 .config/nvim/lua/plugins/tree.lua create mode 100644 .config/nvim/lua/plugins/treesitter.lua create mode 100644 .config/nvim/lua/plugins/trouble.lua create mode 100644 .config/nvim/snippets/package.json create mode 100644 .config/nvim/snippets/rust.json diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..b8782e1 --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1,7 @@ +require('config.options') +require('config.lazy') +require('config.keymaps') +require('config.langmap') + +require('langmapper').automapping({ global = true, buffer = true }) + diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json new file mode 100644 index 0000000..4dbb113 --- /dev/null +++ b/.config/nvim/lazy-lock.json @@ -0,0 +1,33 @@ +{ + "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, + "bufferline.nvim": { "branch": "main", "commit": "2e3c8cc5a57ddd32f1edd2ffd2ccb10c09421f6c" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "conform.nvim": { "branch": "master", "commit": "f5bd8419f8a29451e20bdb1061a54fe13d5c8de3" }, + "friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" }, + "go.nvim": { "branch": "master", "commit": "8389adb56ab124b75d858df5f87b741eaca7b8b3" }, + "guihua.lua": { "branch": "master", "commit": "225db770e36aae6a1e9e3a65578095c8eb4038d3" }, + "langmapper.nvim": { "branch": "main", "commit": "62cc28b4ebc5f47e6d4a6b5dd478c93b812f7187" }, + "lazy.nvim": { "branch": "main", "commit": "48b52b5cfcf8f88ed0aff8fde573a5cc20b1306d" }, + "lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" }, + "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "482350b050bd413931c2cdd4857443c3da7d57cb" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "nvim": { "branch": "main", "commit": "4fd72a9ab64b393c2c22b168508fd244877fec96" }, + "nvim-autopairs": { "branch": "master", "commit": "19606af7c039271d5aa96bceff101e7523af3136" }, + "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" }, + "nvim-lspconfig": { "branch": "master", "commit": "3ad562700d0615818bf358268ac8914f6ce2b079" }, + "nvim-neoclip.lua": { "branch": "main", "commit": "709c97fabec9da7d04f7d2f5e207423af8c02871" }, + "nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" }, + "nvim-tree.lua": { "branch": "master", "commit": "ea55ef12036897fdc4476b115a395d2a34965c82" }, + "nvim-treesitter": { "branch": "master", "commit": "2d8f0f37c4056022b6643cbe8671319881f8b369" }, + "nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" }, + "plenary.nvim": { "branch": "master", "commit": "ec289423a1693aeae6cd0d503bac2856af74edaa" }, + "sqlite.lua": { "branch": "master", "commit": "d0ffd703b56d090d213b497ed4eb840495f14a11" }, + "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, + "trouble.nvim": { "branch": "main", "commit": "6efc446226679fda0547c0fd6a7892fd5f5b15d8" }, + "vim-be-good": { "branch": "master", "commit": "4fa57b7957715c91326fcead58c1fa898b9b3625" } +} diff --git a/.config/nvim/lua/config/keymaps.lua b/.config/nvim/lua/config/keymaps.lua new file mode 100644 index 0000000..4e4feab --- /dev/null +++ b/.config/nvim/lua/config/keymaps.lua @@ -0,0 +1,9 @@ +vim.keymap.set('n', 'v', ':vnew') +vim.keymap.set('n', '', ':bn') +vim.keymap.set('n', '', ':bp') +vim.keymap.set('n', '', ':bd:bn') +vim.keymap.set('n', '', '') +vim.keymap.set('n', '', '') +vim.keymap.set('n', '', '') +vim.keymap.set('n', '', '') +vim.keymap.set('n', '', ':lua vim.lsp.buf.code_action()') diff --git a/.config/nvim/lua/config/langmap.lua b/.config/nvim/lua/config/langmap.lua new file mode 100644 index 0000000..58a3b3d --- /dev/null +++ b/.config/nvim/lua/config/langmap.lua @@ -0,0 +1,15 @@ +local function escape(str) + local escape_chars = [[;,."|\]] + return vim.fn.escape(str, escape_chars) +end + +local en = [[`qwertyuiop[]asdfghjkl;'zxcvbnm]] +local ru = [[ёйцукенгшщзхъфывапролджэячсмить]] +local en_shift = [[~QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>]] +local ru_shift = [[ËЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ]] + +vim.opt.langmap = vim.fn.join({ + escape(ru_shift) .. ';' .. escape(en_shift), + escape(ru) .. ';' .. escape(en), +}, ',') + diff --git a/.config/nvim/lua/config/lazy.lua b/.config/nvim/lua/config/lazy.lua new file mode 100644 index 0000000..9240dd3 --- /dev/null +++ b/.config/nvim/lua/config/lazy.lua @@ -0,0 +1,17 @@ +-- Bootstrap lazy.nvim +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) +end +vim.opt.rtp:prepend(lazypath) + +-- Make sure to setup `mapleader` and `maplocalleader` before +-- loading lazy.nvim so that mappings are correct. +-- s also a good place to setup other settings (vim.opt) +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" + +-- Setup lazy.nvim +require('lazy').setup('plugins') + diff --git a/.config/nvim/lua/config/options.lua b/.config/nvim/lua/config/options.lua new file mode 100644 index 0000000..99f6daa --- /dev/null +++ b/.config/nvim/lua/config/options.lua @@ -0,0 +1,25 @@ +vim.g.mapleader = ' ' + +vim.opt.termguicolors = true + +vim.opt.autoindent = true +vim.opt.clipboard = 'unnamedplus' +vim.opt.mouse = 'a' + +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true + +vim.opt.number = true +vim.opt.relativenumber = true +vim.opt.cursorline = true +vim.opt.splitbelow = true +vim.opt.splitright = true +vim.opt.showmode = false + +vim.opt.incsearch = true +vim.opt.hlsearch = false +vim.opt.ignorecase = true +vim.opt.smartcase = true + diff --git a/.config/nvim/lua/plugins/autopairs.lua b/.config/nvim/lua/plugins/autopairs.lua new file mode 100644 index 0000000..f8c1f6c --- /dev/null +++ b/.config/nvim/lua/plugins/autopairs.lua @@ -0,0 +1,6 @@ +return { + 'windwp/nvim-autopairs', + event = 'InsertEnter', + config = true, +} + diff --git a/.config/nvim/lua/plugins/bufferline.lua b/.config/nvim/lua/plugins/bufferline.lua new file mode 100644 index 0000000..cc0e857 --- /dev/null +++ b/.config/nvim/lua/plugins/bufferline.lua @@ -0,0 +1,21 @@ +return { + 'akinsho/bufferline.nvim', + version = '*', + dependencies = 'nvim-tree/nvim-web-devicons', + config = function () + require('bufferline').setup({ + options = { + diagnostics = 'nvim_lsp', + separator_style = 'slant', + offsets = { + { + filetype = "NvimTree", + text = "File Explorer", + highlight = "Directory", + separator = true + } + } + } + }) + end +} diff --git a/.config/nvim/lua/plugins/conform.lua b/.config/nvim/lua/plugins/conform.lua new file mode 100644 index 0000000..4fd6572 --- /dev/null +++ b/.config/nvim/lua/plugins/conform.lua @@ -0,0 +1,15 @@ +return { + 'stevearc/conform.nvim', + opts = {}, + config = function () + require('conform').setup({ + formatters_by_ft = { + cpp = { 'clang-format' } + }, + format_on_save = { + timeout_ms = 500, + lsp_format = 'fallback' + } + }) + end +} diff --git a/.config/nvim/lua/plugins/go.lua b/.config/nvim/lua/plugins/go.lua new file mode 100644 index 0000000..ef90de2 --- /dev/null +++ b/.config/nvim/lua/plugins/go.lua @@ -0,0 +1,22 @@ +return { + 'ray-x/go.nvim', + dependencies = { + 'ray-x/guihua.lua', + 'neovim/nvim-lspconfig', + 'nvim-treesitter/nvim-treesitter', + }, + config = function() + require('go').setup() + local format_sync_grp = vim.api.nvim_create_augroup("GoFormat", {}) + vim.api.nvim_create_autocmd("BufWritePre", { + pattern = "*.go", + callback = function() + require('go.format').goimports() + end, + group = format_sync_grp, + }) + end, + event = {'CmdlineEnter'}, + ft = {'go', 'gomod'}, + build = ':lua require("go.install").update_all_sync()' +} diff --git a/.config/nvim/lua/plugins/init.lua b/.config/nvim/lua/plugins/init.lua new file mode 100644 index 0000000..25835fe --- /dev/null +++ b/.config/nvim/lua/plugins/init.lua @@ -0,0 +1,8 @@ +return { + { + 'williamboman/mason.nvim', + config = true + }, + 'ThePrimeagen/vim-be-good', +} + diff --git a/.config/nvim/lua/plugins/langmapper.lua b/.config/nvim/lua/plugins/langmapper.lua new file mode 100644 index 0000000..f34a28b --- /dev/null +++ b/.config/nvim/lua/plugins/langmapper.lua @@ -0,0 +1,8 @@ +return { + 'Wansmer/langmapper.nvim', + lazy = false, + priority = 1, -- High priority is needed if you will use `autoremap()` + config = function() + require('langmapper').setup() + end, +} diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..95df1d1 --- /dev/null +++ b/.config/nvim/lua/plugins/lsp.lua @@ -0,0 +1,98 @@ +return { + { + 'williamboman/mason-lspconfig.nvim', + opts = { + ensure_installed = { 'lua_ls', 'gopls', 'rust_analyzer', 'pylsp' } + } + }, + { + 'L3MON4D3/LuaSnip', + version = 'v2.*', + build = 'make install_jsregexp', + dependencies = { + 'rafamadriz/friendly-snippets' + }, + config = function() + local vscode_loader = require('luasnip.loaders.from_vscode') + vscode_loader.lazy_load() + vscode_loader.lazy_load({ paths = { './snippets' } }) + local ls = require('luasnip') + vim.keymap.set({ "i" }, "", function() ls.expand() end, { silent = true }) + vim.keymap.set({ "i", "s" }, "", function() ls.jump(1) end, { silent = true }) + vim.keymap.set({ "i", "s" }, "", function() ls.jump(-1) end, { silent = true }) + end + }, + { + 'hrsh7th/nvim-cmp', + event = 'InsertEnter', + dependencies = { + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-path', + 'hrsh7th/cmp-cmdline', + 'hrsh7th/cmp-nvim-lsp', + 'saadparwaiz1/cmp_luasnip' + }, + config = function() + local has_words_before = function() + unpack = unpack or table.unpack + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and + vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil + end + + local cmp = require('cmp') + local luasnip = require('luasnip') + cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif has_words_before() then + cmp.complete() + 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" }), + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'buffer' }, + { name = 'path' }, + }) + }) + end + }, + { + 'neovim/nvim-lspconfig', + config = function() + local lspconfig = require('lspconfig') + local lsp_capabilities = require('cmp_nvim_lsp').default_capabilities() + lspconfig.lua_ls.setup({ capabilities = lsp_capabilities }) + lspconfig.rust_analyzer.setup({ capabilities = lsp_capabilities }) + lspconfig.gopls.setup({ capabilities = lsp_capabilities }) + lspconfig.typst_lsp.setup({ capabilities = lsp_capabilities }) + lspconfig.clangd.setup({ capabilities = lsp_capabilities }) + lspconfig.cmake.setup({ capabilities = lsp_capabilities }) + end + }, +} diff --git a/.config/nvim/lua/plugins/lualine.lua b/.config/nvim/lua/plugins/lualine.lua new file mode 100644 index 0000000..b9f5ad9 --- /dev/null +++ b/.config/nvim/lua/plugins/lualine.lua @@ -0,0 +1,7 @@ +return { + { + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + config = true + } +} diff --git a/.config/nvim/lua/plugins/mdpreview.lua b/.config/nvim/lua/plugins/mdpreview.lua new file mode 100644 index 0000000..00f8e94 --- /dev/null +++ b/.config/nvim/lua/plugins/mdpreview.lua @@ -0,0 +1,9 @@ +return { + 'iamcco/markdown-preview.nvim', + cmd = { 'MarkdownPreviewToggle', 'MarkdownPreview', 'MarkdownPreviewStop' }, + build = 'cd app && yarn install', + init = function () + vim.g.mkdp_filetypes = { 'markdown' } + end, + ft = { 'markdown' } +} diff --git a/.config/nvim/lua/plugins/neoclip.lua b/.config/nvim/lua/plugins/neoclip.lua new file mode 100644 index 0000000..f4a3cde --- /dev/null +++ b/.config/nvim/lua/plugins/neoclip.lua @@ -0,0 +1,11 @@ +return { + 'AckslD/nvim-neoclip.lua', + dependencies = { + { 'kkharji/sqlite.lua', module = 'sqlite' }, + { 'nvim-telescope/telescope.nvim' } + }, + config = function () + require('neoclip').setup() + vim.keymap.set('n', 'v', ':Telescope neoclip plus') + end +} diff --git a/.config/nvim/lua/plugins/surround.lua b/.config/nvim/lua/plugins/surround.lua new file mode 100644 index 0000000..7fff0d6 --- /dev/null +++ b/.config/nvim/lua/plugins/surround.lua @@ -0,0 +1,6 @@ +return { + "kylechui/nvim-surround", + version = "*", -- Use for stability; omit to use `main` branch for the latest features + event = "VeryLazy", + config = true +} diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..497a520 --- /dev/null +++ b/.config/nvim/lua/plugins/telescope.lua @@ -0,0 +1,18 @@ +return { + 'nvim-telescope/telescope.nvim', tag = '0.1.8', + dependencies = { 'nvim-lua/plenary.nvim' }, + config = function () + local builtin = require('telescope.builtin') + vim.keymap.set('n', 'ff', builtin.find_files, {}) + vim.keymap.set('n', 'fg', builtin.live_grep, {}) + vim.keymap.set('n', 'fb', builtin.buffers, {}) + vim.keymap.set('n', 'fh', builtin.help_tags, {}) + vim.keymap.set('n', 'lr', builtin.lsp_references, {}) + vim.keymap.set('n', 'ld', builtin.lsp_definitions, {}) + vim.keymap.set('n', 'li', builtin.lsp_implementations, {}) + vim.keymap.set('n', 'gc', builtin.git_commits, {}) + vim.keymap.set('n', 'gb', builtin.git_branches, {}) + vim.keymap.set('n', 'gs', builtin.git_status, {}) + vim.keymap.set('n', 'bb', builtin.builtin, {}) + end +} diff --git a/.config/nvim/lua/plugins/theme.lua b/.config/nvim/lua/plugins/theme.lua new file mode 100644 index 0000000..30bde0f --- /dev/null +++ b/.config/nvim/lua/plugins/theme.lua @@ -0,0 +1,17 @@ +return { + 'catppuccin/nvim', + lazy = false, + priority = 1000, + config = function() + require('catppuccin').setup({ + flavour = 'mocha', + integrations = { + cmp = true, + nvimtree = true, + treesitter = true + } + }) + vim.cmd[[colorscheme catppuccin]] + end +} + diff --git a/.config/nvim/lua/plugins/tree.lua b/.config/nvim/lua/plugins/tree.lua new file mode 100644 index 0000000..3d77aa7 --- /dev/null +++ b/.config/nvim/lua/plugins/tree.lua @@ -0,0 +1,19 @@ +return { + 'nvim-tree/nvim-tree.lua', + dependencies = { + 'nvim-tree/nvim-web-devicons' + }, + config = function () + vim.g.loaded_netrw = 1 + vim.g.loaded_netrwPlugin = 1 + vim.keymap.set('n', 'e', ':NvimTreeToggle') + require('nvim-tree').setup({ + filters = { + dotfiles = true + } + }) + vim.api.nvim_create_autocmd({"QuitPre"}, { + callback = function() vim.cmd("NvimTreeClose") end, + }) + end +} diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..1701323 --- /dev/null +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,14 @@ +return { + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', + config = function () + local configs = require('nvim-treesitter.configs') + configs.setup({ + ensure_installed = { 'c', 'lua', 'vim', 'vimdoc', 'query' }, + auto_install = true, + highlight = { enable = true }, + indent = { enable = true } + }) + end +} + diff --git a/.config/nvim/lua/plugins/trouble.lua b/.config/nvim/lua/plugins/trouble.lua new file mode 100644 index 0000000..04ebd87 --- /dev/null +++ b/.config/nvim/lua/plugins/trouble.lua @@ -0,0 +1,37 @@ +return { + "folke/trouble.nvim", + opts = {}, + cmd = "Trouble", + keys = { + { + "xx", + "Trouble diagnostics toggle", + desc = "Diagnostics (Trouble)", + }, + { + "xX", + "Trouble diagnostics toggle filter.buf=0", + desc = "Buffer Diagnostics (Trouble)", + }, + { + "cs", + "Trouble symbols toggle focus=false", + desc = "Symbols (Trouble)", + }, + { + "cl", + "Trouble lsp toggle focus=false win.position=right", + desc = "LSP Definitions / references / ... (Trouble)", + }, + { + "xL", + "Trouble loclist toggle", + desc = "Location List (Trouble)", + }, + { + "xQ", + "Trouble qflist toggle", + desc = "Quickfix List (Trouble)", + }, + }, +} diff --git a/.config/nvim/snippets/package.json b/.config/nvim/snippets/package.json new file mode 100644 index 0000000..412e999 --- /dev/null +++ b/.config/nvim/snippets/package.json @@ -0,0 +1,13 @@ +{ + "name": "my-snippets", + "contributes": { + "snippets": [ + { + "language": [ + "rust" + ], + "path": "./rust.json" + } + ] + } +} diff --git a/.config/nvim/snippets/rust.json b/.config/nvim/snippets/rust.json new file mode 100644 index 0000000..0d08c3f --- /dev/null +++ b/.config/nvim/snippets/rust.json @@ -0,0 +1,34 @@ +{ + "leetcode": { + "prefix": "leetcode", + "body": [ + "pub struct Solution;", + "impl Solution {", + " pub fn ${1:name}(${2:arg}: ${3:Type}) -> ${4:RetType} {", + " ${5:todo!();}", + " }", + "}", + "", + "#[cfg(test)]", + "mod tests {", + " use super::Solution;", + "", + " #[test]", + " fn test1() {", + " ${6:todo!();}", + " }", + "", + " #[test]", + " fn test2() {", + " ${7:todo!();}", + " }", + "", + " #[test]", + " fn test3() {", + " ${8:todo!();}", + " }", + "}" + ], + "description": "leetcode Solution snippet" + } +}