From dbbf6c9dd856e6ef62feb75dbade30e28cf11025 Mon Sep 17 00:00:00 2001 From: Itsigo Date: Fri, 12 Apr 2024 16:19:46 +0200 Subject: [PATCH] custom vim to the git --- init.lua | 2 + lazy-lock.json | 27 ++++++ lua/itsigo/init.lua | 25 +++++ lua/itsigo/lazy.lua | 14 +++ lua/itsigo/plugins/blankline.lua | 26 ++++++ lua/itsigo/plugins/catppuccin.lua | 8 ++ lua/itsigo/plugins/harpoon.lua | 25 +++++ lua/itsigo/plugins/indentscope.lua | 29 ++++++ lua/itsigo/plugins/init.lua | 4 + lua/itsigo/plugins/lsp.lua | 130 ++++++++++++++++++++++++++ lua/itsigo/plugins/lualine.lua | 6 ++ lua/itsigo/plugins/luasnip.lua | 27 ++++++ lua/itsigo/plugins/oil.lua | 11 +++ lua/itsigo/plugins/telescope.lua | 13 +++ lua/itsigo/plugins/tmux-navigator.lua | 11 +++ lua/itsigo/plugins/treesitter.lua | 15 +++ lua/itsigo/remap.lua | 7 ++ lua/itsigo/set.lua | 26 ++++++ 18 files changed, 406 insertions(+) create mode 100644 init.lua create mode 100644 lazy-lock.json create mode 100644 lua/itsigo/init.lua create mode 100644 lua/itsigo/lazy.lua create mode 100644 lua/itsigo/plugins/blankline.lua create mode 100644 lua/itsigo/plugins/catppuccin.lua create mode 100644 lua/itsigo/plugins/harpoon.lua create mode 100644 lua/itsigo/plugins/indentscope.lua create mode 100644 lua/itsigo/plugins/init.lua create mode 100644 lua/itsigo/plugins/lsp.lua create mode 100644 lua/itsigo/plugins/lualine.lua create mode 100644 lua/itsigo/plugins/luasnip.lua create mode 100644 lua/itsigo/plugins/oil.lua create mode 100644 lua/itsigo/plugins/telescope.lua create mode 100644 lua/itsigo/plugins/tmux-navigator.lua create mode 100644 lua/itsigo/plugins/treesitter.lua create mode 100644 lua/itsigo/remap.lua create mode 100644 lua/itsigo/set.lua diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..5797483 --- /dev/null +++ b/init.lua @@ -0,0 +1,2 @@ +require("itsigo") + diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..e2c9330 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,27 @@ +{ + "LuaSnip": { "branch": "master", "commit": "825a61bad1d60d917a7962d73cf3c683f4e0407e" }, + "catppuccin": { "branch": "main", "commit": "aebe43db9cb26e1c70fc5b2fd4158169c405e720" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "fidget.nvim": { "branch": "main", "commit": "1ba38e4cbb24683973e00c2e36f53ae64da38ef5" }, + "friendly-snippets": { "branch": "main", "commit": "ea068f1becd91bcd4591fceb6420d4335e2e14d3" }, + "harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" }, + "indent-blankline.nvim": { "branch": "master", "commit": "3d08501caef2329aba5121b753e903904088f7e6" }, + "lazy.nvim": { "branch": "main", "commit": "bef521ac89c8d423f9d092e37b58e8af0c099309" }, + "lualine.nvim": { "branch": "master", "commit": "b5e8bb642138f787a2c1c5aedc2a78cb2cebbd67" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "9dfcf2036c223920826140f0151d929a43f9eceb" }, + "mason.nvim": { "branch": "main", "commit": "751b1fcbf3d3b783fcf8d48865264a9bcd8f9b10" }, + "mini.indentscope": { "branch": "main", "commit": "cf07f19e718ebb0bcc5b00999083ce11c37b8d40" }, + "none-ls.nvim": { "branch": "main", "commit": "dca7ddec321a102ec9e792b1b29193702aff5fbb" }, + "nvim-cmp": { "branch": "main", "commit": "ce16de5665c766f39c271705b17fff06f7bcb84f" }, + "nvim-lspconfig": { "branch": "master", "commit": "96e5711040df23583591391ce49e556b8cd248d8" }, + "nvim-treesitter": { "branch": "master", "commit": "1b050206e490a4146cdf25c7b38969c1711b5620" }, + "nvim-web-devicons": { "branch": "master", "commit": "3ee60deaa539360518eaab93a6c701fe9f4d82ef" }, + "oil.nvim": { "branch": "master", "commit": "e462a3446505185adf063566f5007771b69027a1" }, + "plenary": { "branch": "master", "commit": "8aad4396840be7fc42896e3011751b7609ca4119" }, + "plenary.nvim": { "branch": "master", "commit": "8aad4396840be7fc42896e3011751b7609ca4119" }, + "telescope.nvim": { "branch": "master", "commit": "d26b666b45e5dde23332e4bde1227677f2d92e31" } +} \ No newline at end of file diff --git a/lua/itsigo/init.lua b/lua/itsigo/init.lua new file mode 100644 index 0000000..cecc078 --- /dev/null +++ b/lua/itsigo/init.lua @@ -0,0 +1,25 @@ +require("itsigo.remap") +require("itsigo.set") +require("itsigo.lazy") + +local autocmd = vim.api.nvim_create_autocmd + +function R(name) + require("plenary.reload").reload_module(name) +end + +autocmd({"BufWritePre"}, { + pattern = "*", + command = [[%s/\s\+$//e]], +}) + +autocmd('LspAttach', { + callback = function (e) + local opts = { buffer = e.buf } + vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts) + vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts) + vim.keymap.set("n", "vca", function() vim.lsp.buf.code_action() end, opts) + vim.keymap.set("n", "vrr", function() vim.lsp.buf.references() end, opts) + vim.keymap.set("n", "vrn", function() vim.lsp.buf.rename() end, opts) + end +}) diff --git a/lua/itsigo/lazy.lua b/lua/itsigo/lazy.lua new file mode 100644 index 0000000..bd649e1 --- /dev/null +++ b/lua/itsigo/lazy.lua @@ -0,0 +1,14 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +require("lazy").setup("itsigo.plugins") diff --git a/lua/itsigo/plugins/blankline.lua b/lua/itsigo/plugins/blankline.lua new file mode 100644 index 0000000..fe9decf --- /dev/null +++ b/lua/itsigo/plugins/blankline.lua @@ -0,0 +1,26 @@ +return { + "lukas-reineke/indent-blankline.nvim", + opts = { + indent = { + char = "│", + tab_char = "│", + }, + scope = { enabled = false }, + exclude = { + filetypes = { + "help", + "alpha", + "dashboard", + -- "neo-tree", + "Trouble", + "trouble", + "lazy", + "mason", + "notify", + "toggleterm", + "lazyterm", + }, + }, + }, + main = "ibl", +} diff --git a/lua/itsigo/plugins/catppuccin.lua b/lua/itsigo/plugins/catppuccin.lua new file mode 100644 index 0000000..558c255 --- /dev/null +++ b/lua/itsigo/plugins/catppuccin.lua @@ -0,0 +1,8 @@ +return { + "catppuccin/nvim", + name = "catppuccin", + priority = 999, + config = function() + vim.cmd.colorscheme "catppuccin-macchiato" + end, +} diff --git a/lua/itsigo/plugins/harpoon.lua b/lua/itsigo/plugins/harpoon.lua new file mode 100644 index 0000000..b761f44 --- /dev/null +++ b/lua/itsigo/plugins/harpoon.lua @@ -0,0 +1,25 @@ +return { + "ThePrimeagen/harpoon", + branch = "harpoon2", + dependencies = { "nvim-lua/plenary.nvim" }, + + config = function() + + local harpoon = require("harpoon") + harpoon:setup() + + vim.keymap.set("n", "a", function() harpoon:list():add() end) + vim.keymap.set("n", "", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end) + + vim.keymap.set("n", "", function() harpoon:list():select(1) end) + vim.keymap.set("n", "", function() harpoon:list():select(2) end) + vim.keymap.set("n", "", function() harpoon:list():select(3) end) + vim.keymap.set("n", "", function() harpoon:list():select(4) end) + + vim.keymap.set("n", "", function() harpoon:list():replace_at(1) end) + vim.keymap.set("n", "", function() harpoon:list():replace_at(2) end) + vim.keymap.set("n", "", function() harpoon:list():replace_at(3) end) + vim.keymap.set("n", "", function() harpoon:list():replace_at(4) end) + end, + +} diff --git a/lua/itsigo/plugins/indentscope.lua b/lua/itsigo/plugins/indentscope.lua new file mode 100644 index 0000000..7327c78 --- /dev/null +++ b/lua/itsigo/plugins/indentscope.lua @@ -0,0 +1,29 @@ +return { + "echasnovski/mini.indentscope", + version = false, -- wait till new 0.7.0 release to put it back on semver + opts = { + -- symbol = "▏", + symbol = "│", + options = { try_as_border = true }, + }, + init = function() + vim.api.nvim_create_autocmd("FileType", { + pattern = { + "help", + "alpha", + "dashboard", + "neo-tree", + "Trouble", + "trouble", + "lazy", + "mason", + "notify", + "toggleterm", + "lazyterm", + }, + callback = function() + vim.b.miniindentscope_disable = true + end, + }) + end, +} diff --git a/lua/itsigo/plugins/init.lua b/lua/itsigo/plugins/init.lua new file mode 100644 index 0000000..5f40354 --- /dev/null +++ b/lua/itsigo/plugins/init.lua @@ -0,0 +1,4 @@ +return { + "nvim-lua/plenary.nvim", + name = "plenary" +} diff --git a/lua/itsigo/plugins/lsp.lua b/lua/itsigo/plugins/lsp.lua new file mode 100644 index 0000000..f3915ce --- /dev/null +++ b/lua/itsigo/plugins/lsp.lua @@ -0,0 +1,130 @@ +return { + "neovim/nvim-lspconfig", + dependencies = { + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + "hrsh7th/nvim-cmp", + "L3MON4D3/LuaSnip", + "saadparwaiz1/cmp_luasnip", + "j-hui/fidget.nvim", + "nvimtools/none-ls.nvim", + }, + + config = function() + local cmp = require('cmp') + local cmp_lsp = require("cmp_nvim_lsp") + local luasnip = require("luasnip") + local capabilities = vim.tbl_deep_extend( + "force", + {}, + vim.lsp.protocol.make_client_capabilities(), + cmp_lsp.default_capabilities()) + + require("fidget").setup({}) + require("mason").setup() + require("mason-lspconfig").setup({ + ensure_installed = { + "lua_ls", + -- "rust_analyzer", + "gopls", + }, + handlers = { + function(server_name) -- default handler (optional) + + require("lspconfig")[server_name].setup { + capabilities = capabilities + } + end, + + ["lua_ls"] = function() + local lspconfig = require("lspconfig") + lspconfig.lua_ls.setup { + capabilities = capabilities, + settings = { + Lua = { + runtime = { version = "Lua 5.1" }, + diagnostics = { + globals = { "vim", "it", "describe", "before_each", "after_each" }, + } + } + } + } + end, + } + }) + + local cmp_select = { behavior = cmp.SelectBehavior.Select } + + cmp.setup({ + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) -- For `luasnip` users. + end, + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.select_prev_item(cmp_select), + [''] = cmp.mapping.select_next_item(cmp_select), + [''] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping.complete(), + + [""] = cmp.mapping(function(fallback) + --if cmp.visible() then + -- cmp.select_next_item() + if luasnip.locally_jumpable(1) then + luasnip.jump(1) + else + fallback() + end + end, { "i", "s"}), + + }), + sources = cmp.config.sources({ + { name = 'luasnip' }, -- For luasnip users. + { name = 'nvim_lsp' }, + }, { + { name = 'buffer' }, + }) + }) + + vim.diagnostic.config({ + -- update_in_insert = true, + float = { + focusable = false, + style = "minimal", + border = "rounded", + source = "always", + header = "", + prefix = "", + }, + }) + + local null_ls = require("null-ls") + local autogroup = vim.api.nvim_create_augroup("LspFormatting", {}) + + null_ls.setup({ + sources = { + null_ls.builtins.formatting.gofumpt, + null_ls.builtins.formatting.goimports, + }, + on_attach = function (client, bufnr) + if client.supports_method("textDocument/formatting") then + vim.api.nvim_clear_autocmds({ + group = autogroup, + buffer = bufnr, + }) + vim.api.nvim_create_autocmd("BufWritePre", { + group = autogroup, + buffer = bufnr, + callback = function () + vim.lsp.buf.format({ bufnr = bufnr }) + end, + }) + end + end, + }) + end +} diff --git a/lua/itsigo/plugins/lualine.lua b/lua/itsigo/plugins/lualine.lua new file mode 100644 index 0000000..d101931 --- /dev/null +++ b/lua/itsigo/plugins/lualine.lua @@ -0,0 +1,6 @@ +return { + "nvim-lualine/lualine.nvim", + dependencies = { 'nvim-tree/nvim-web-devicons' }, + opts = { + }, +} diff --git a/lua/itsigo/plugins/luasnip.lua b/lua/itsigo/plugins/luasnip.lua new file mode 100644 index 0000000..e901c16 --- /dev/null +++ b/lua/itsigo/plugins/luasnip.lua @@ -0,0 +1,27 @@ +return { + "L3MON4D3/LuaSnip", + -- follow latest release. + version = "v2.*", -- Replace by the latest released major (first number of latest release) + -- install jsregexp (optional!). + build = "make install_jsregexp", + + dependencies = { "rafamadriz/friendly-snippets" }, + + config = function() + local ls = require("luasnip") + require("luasnip.loaders.from_vscode").lazy_load() + ls.filetype_extend("javascript", { "jsdoc" }) + + --- TODO: What is expand? + vim.keymap.set({"i"}, "e", 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}) + + vim.keymap.set({"i", "s"}, "", function() + if ls.choice_active() then + ls.change_choice(1) + end + end, {silent = true}) + end, +} diff --git a/lua/itsigo/plugins/oil.lua b/lua/itsigo/plugins/oil.lua new file mode 100644 index 0000000..65a8124 --- /dev/null +++ b/lua/itsigo/plugins/oil.lua @@ -0,0 +1,11 @@ +return { + 'stevearc/oil.nvim', + opts = {}, + -- Optional dependencies + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + require("oil").setup({ + default_file_explorer = true, + }) + end +} diff --git a/lua/itsigo/plugins/telescope.lua b/lua/itsigo/plugins/telescope.lua new file mode 100644 index 0000000..94cfa89 --- /dev/null +++ b/lua/itsigo/plugins/telescope.lua @@ -0,0 +1,13 @@ +return { + 'nvim-telescope/telescope.nvim', + dependencies = { 'nvim-lua/plenary.nvim' }, + + keys = { + { "pf", function() require("telescope.builtin").find_files() end, desc="Find: Files" }, + { "", function() require("telescope.builtin").git_files() end, desc="Find: Git Files" }, + { "ps", function() + require("telescope.builtin").grep_string({search = vim.fn.input("Grep > ")}) + end, desc="Find: Files" }, + }, + +} diff --git a/lua/itsigo/plugins/tmux-navigator.lua b/lua/itsigo/plugins/tmux-navigator.lua new file mode 100644 index 0000000..cd2b632 --- /dev/null +++ b/lua/itsigo/plugins/tmux-navigator.lua @@ -0,0 +1,11 @@ +return { + "christoomey/vim-tmux-navigator", + + keys = { + { "", "TmuxNavigatePrevious", desc = "Go to the previous pane" }, + { "", "TmuxNavigateLeft", desc = "Got to the left pane" }, + { "", "TmuxNavigateDown", desc = "Got to the down pane" }, + { "", "TmuxNavigateUp", desc = "Got to the up pane" }, + { "", "TmuxNavigateRight", desc = "Got to the right pane" }, + }, +} diff --git a/lua/itsigo/plugins/treesitter.lua b/lua/itsigo/plugins/treesitter.lua new file mode 100644 index 0000000..bf89623 --- /dev/null +++ b/lua/itsigo/plugins/treesitter.lua @@ -0,0 +1,15 @@ +return { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + config = function () + local configs = require("nvim-treesitter.configs") + + configs.setup({ + ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "elixir", "heex", "javascript", "html" }, + sync_install = false, + auto_install = true, + highlight = { enable = true }, + indent = { enable = true }, + }) + end +} diff --git a/lua/itsigo/remap.lua b/lua/itsigo/remap.lua new file mode 100644 index 0000000..e3e7c41 --- /dev/null +++ b/lua/itsigo/remap.lua @@ -0,0 +1,7 @@ +vim.g.mapleader = " " + +-- open file explorer +-- vim.keymap.set("n", "e", vim.cmd.Ex) + +-- oil +vim.keymap.set("n", "-", "Oil", { desc = "Open parent directory" }) diff --git a/lua/itsigo/set.lua b/lua/itsigo/set.lua new file mode 100644 index 0000000..8d9c847 --- /dev/null +++ b/lua/itsigo/set.lua @@ -0,0 +1,26 @@ +vim.opt.nu = true +vim.opt.relativenumber = true + +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true + +vim.opt.smartindent = true + +vim.opt.wrap = false + +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" +vim.opt.undofile = true + +vim.opt.hlsearch = false +vim.opt.incsearch = true + +vim.opt.termguicolors = true + +vim.opt.signcolumn = "yes" +vim.opt.isfname:append("@-@") + +vim.opt.updatetime = 50