From 85d7d7c082bd84d3c701ceec3d477ee37db5c827 Mon Sep 17 00:00:00 2001 From: Christian Segundo Date: Sun, 18 Feb 2024 08:19:51 +0100 Subject: bootstrap --- lua/plugins/core/auto-session.lua | 6 +++++ lua/plugins/core/gitsigns.lua | 8 ++++++ lua/plugins/core/luasnip.lua | 50 +++++++++++++++++++++++++++++++++++ lua/plugins/core/nerdcommenter.lua | 18 +++++++++++++ lua/plugins/core/nvim-tree.lua | 36 +++++++++++++++++++++++++ lua/plugins/core/tabline.lua | 3 +++ lua/plugins/core/telescope.lua | 27 +++++++++++++++++++ lua/plugins/core/tmux.lua | 13 +++++++++ lua/plugins/core/treesitter.lua | 54 ++++++++++++++++++++++++++++++++++++++ lua/plugins/core/which-key.lua | 45 +++++++++++++++++++++++++++++++ 10 files changed, 260 insertions(+) create mode 100644 lua/plugins/core/auto-session.lua create mode 100644 lua/plugins/core/gitsigns.lua create mode 100644 lua/plugins/core/luasnip.lua create mode 100644 lua/plugins/core/nerdcommenter.lua create mode 100644 lua/plugins/core/nvim-tree.lua create mode 100644 lua/plugins/core/tabline.lua create mode 100644 lua/plugins/core/telescope.lua create mode 100644 lua/plugins/core/tmux.lua create mode 100644 lua/plugins/core/treesitter.lua create mode 100644 lua/plugins/core/which-key.lua (limited to 'lua/plugins/core') diff --git a/lua/plugins/core/auto-session.lua b/lua/plugins/core/auto-session.lua new file mode 100644 index 0000000..9bfcac0 --- /dev/null +++ b/lua/plugins/core/auto-session.lua @@ -0,0 +1,6 @@ +return { + "rmagatti/auto-session", + config = function() + require("auto-session").setup({ log_level = "info" }) + end, +} diff --git a/lua/plugins/core/gitsigns.lua b/lua/plugins/core/gitsigns.lua new file mode 100644 index 0000000..e856855 --- /dev/null +++ b/lua/plugins/core/gitsigns.lua @@ -0,0 +1,8 @@ +return { + "lewis6991/gitsigns.nvim", + event = { "BufRead" }, + config = function() + require("gitsigns").setup() + end, + dependencies = { "nvim-lua/plenary.nvim" }, +} diff --git a/lua/plugins/core/luasnip.lua b/lua/plugins/core/luasnip.lua new file mode 100644 index 0000000..622af58 --- /dev/null +++ b/lua/plugins/core/luasnip.lua @@ -0,0 +1,50 @@ +return { + { + "L3MON4D3/LuaSnip", + dependencies = { "rafamadriz/friendly-snippets" }, + build = "make install_jsregexp", + config = function() + local ls = require("luasnip") + local types = require("luasnip.util.types") + + ls.config.set_config({ + history = true, + updateevents = "TextChanged,TextChangedI", + enable_autosnippets = true, + ext_opts = { + [types.choiceNode] = { + active = { + virt_text = { { "<-", "Error" } }, + }, + }, + }, + }) + + -- luasnip keymaps are defined as cmp keymaps + + vim.keymap.set( + "n", + "s", + 'lua require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/lua/snippets" })' + ) + + require("luasnip.loaders.from_lua").lazy_load({ paths = "~/.config/nvim/lua/snippets" }) + end, + }, + + -- VSCode like (JSON) snippets + -- For the full list of supported languages see: + -- https://github.com/rafamadriz/friendly-snippets/blob/main/package.json + { + "rafamadriz/friendly-snippets", + opts = { include = {} }, + config = function(_, opts) + if #opts.include == 0 then + return + end + + opts.path = "~/.local/share/nvim/lazy/friendly-snippets" + require("luasnip.loaders.from_vscode").lazy_load(opts) + end, + }, +} diff --git a/lua/plugins/core/nerdcommenter.lua b/lua/plugins/core/nerdcommenter.lua new file mode 100644 index 0000000..720b3d2 --- /dev/null +++ b/lua/plugins/core/nerdcommenter.lua @@ -0,0 +1,18 @@ +return { + "preservim/nerdcommenter", + init = function() + vim.g.NERDCreateDefaultMappings = 0 + end, + config = function() + vim.api.nvim_set_keymap("v", "cc", "NERDCommenterComment", { silent = true }) + vim.api.nvim_set_keymap("v", "cu", "NERDCommenterUncomment", { silent = true }) + vim.api.nvim_set_keymap("n", "cc", "NERDCommenterComment", { noremap = false, silent = true }) + vim.api.nvim_set_keymap("n", "cu", "NERDCommenterUncomment", { noremap = false, silent = true }) + end, + keys = { + { "cc", mode = "v" }, + { "cc", mode = "n" }, + { "cu", mode = "v" }, + { "cu", mode = "n" }, + }, +} diff --git a/lua/plugins/core/nvim-tree.lua b/lua/plugins/core/nvim-tree.lua new file mode 100644 index 0000000..e8ca82f --- /dev/null +++ b/lua/plugins/core/nvim-tree.lua @@ -0,0 +1,36 @@ +return { + { + "nvim-tree/nvim-tree.lua", + config = function() + require("nvim-tree").setup({ + sync_root_with_cwd = false, + update_focused_file = { + enable = true, + update_root = false, + }, + renderer = { + indent_markers = { enable = true }, + highlight_git = true, + highlight_opened_files = "all", + }, + }) + end, + dependencies = { "nvim-tree/nvim-web-devicons" }, + }, + + -- Add nvim-tree which-key shortcuts + { + "folke/which-key.nvim", + opts = function(_, opts) + if type(opts) ~= "table" then + opts = {} + end + + if type(opts.f) ~= "table" then + opts["f"] = {} + end + + opts.f["e"] = { "NvimTreeToggle", "Explorer" } + end, + }, +} diff --git a/lua/plugins/core/tabline.lua b/lua/plugins/core/tabline.lua new file mode 100644 index 0000000..0a8305d --- /dev/null +++ b/lua/plugins/core/tabline.lua @@ -0,0 +1,3 @@ +return { + "mkitt/tabline.vim", +} diff --git a/lua/plugins/core/telescope.lua b/lua/plugins/core/telescope.lua new file mode 100644 index 0000000..367e20c --- /dev/null +++ b/lua/plugins/core/telescope.lua @@ -0,0 +1,27 @@ +return { + { + "nvim-telescope/telescope.nvim", + config = function() + require("telescope").load_extension("file_browser") + end, + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-telescope/telescope-file-browser.nvim", + }, + }, + + { + "folke/which-key.nvim", + opts = function(_, opts) + if type(opts) == "table" then + opts.b = opts.b or {} + opts.f = opts.f or {} + + opts.b["b"] = { "Telescope buffers", "All" } + opts.f["f"] = { "Telescope find_files", "Find" } + opts.f["g"] = { "Telescope live_grep", "Grep" } + opts.f["b"] = { "Telescope file_browser", "Browse" } + end + end, + }, +} diff --git a/lua/plugins/core/tmux.lua b/lua/plugins/core/tmux.lua new file mode 100644 index 0000000..0d63aa4 --- /dev/null +++ b/lua/plugins/core/tmux.lua @@ -0,0 +1,13 @@ +return { + "christoomey/vim-tmux-navigator", + config = function() + local nvim_set_keymap = vim.api.nvim_set_keymap + vim.g.tmux_navigator_no_mappings = 1 + for _, mode in pairs({ "n", "v", "i", "t" }) do + nvim_set_keymap(mode, "", ":TmuxNavigateDown", { noremap = true }) + nvim_set_keymap(mode, "", ":TmuxNavigateUp", { noremap = true }) + nvim_set_keymap(mode, "", ":TmuxNavigateLeft", { noremap = true }) + nvim_set_keymap(mode, "", ":TmuxNavigateRight", { noremap = true }) + end + end, +} diff --git a/lua/plugins/core/treesitter.lua b/lua/plugins/core/treesitter.lua new file mode 100644 index 0000000..3818555 --- /dev/null +++ b/lua/plugins/core/treesitter.lua @@ -0,0 +1,54 @@ +---@param tbl table +---@return table +local tbl_uniq = function(tbl) + ---@type table + local added = {} + local res = {} + res = vim.tbl_filter(function(k) + if added[k] then + return false + end + added[k] = true + return true + end, tbl) + + return res +end + +return { + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + cmd = { "TSUpdateSync" }, + event = { "BufReadPost", "BufNewFile" }, + init = function() + vim.o.foldmethod = "expr" + vim.o.foldexpr = "nvim_treesitter#foldexpr()" + end, + opts = { + ensure_installed = { "query" }, + ignore_install = {}, + highlight = { + enable = true, + }, + query_linter = { + enable = true, + use_virtual_text = true, + lint_events = { "BufWrite", "CursorHold" }, + }, + }, + config = function(_, opts) + if type(opts.ensure_installed) == "table" then + opts.ensure_installed = tbl_uniq(opts.ensure_installed) + end + require("nvim-treesitter.configs").setup(opts) + end, + }, + + { + "nvim-treesitter/playground", + build = ":TSInstall query", + dependencies = { "nvim-treesitter" }, + cmd = { "TSPlaygroundToggle" }, + }, +} diff --git a/lua/plugins/core/which-key.lua b/lua/plugins/core/which-key.lua new file mode 100644 index 0000000..6e046a3 --- /dev/null +++ b/lua/plugins/core/which-key.lua @@ -0,0 +1,45 @@ +return { + "folke/which-key.nvim", + event = "VeryLazy", + init = function() + vim.o.timeout = true + vim.o.timeoutlen = 300 + end, + + opts = { + f = { name = "File" }, + b = { + name = "Buffer", + n = { "BufferNext", "Next" }, + p = { "BufferPrevious", "Previous" }, + c = { "BufferClose", "Close" }, + ["1"] = { "BufferGoto 1", "1" }, + ["2"] = { "BufferGoto 2", "2" }, + ["3"] = { "BufferGoto 3", "3" }, + ["4"] = { "BufferGoto 4", "4" }, + ["5"] = { "BufferGoto 5", "5" }, + ["6"] = { "BufferGoto 6", "6" }, + ["7"] = { "BufferGoto 7", "7" }, + ["8"] = { "BufferGoto 8", "8" }, + ["9"] = { "BufferGoto 9", "9" }, + }, + l = { + name = "LSP", + a = { "lua vim.lsp.buf.code_action()", "Action" }, + f = { "lua vim.lsp.buf.format({ async = false, timeout_ms = 5000 })", "Format" }, + d = { "lua vim.diagnostic.open_float()", "Diagnostic" }, + h = { "lua vim.lsp.buf.hover()", "Help" }, + g = { + name = "Go to", + D = { "lua vim.lsp.buf.declaration()", "Go to declaration" }, + d = { "lua vim.lsp.buf.definition()", "Go to definition" }, + i = { "lua vim.lsp.buf.definition()", "Go to implementation" }, + }, + }, + }, + + config = function(_, opts) + local wk = require("which-key") + wk.register(opts, { prefix = "" }) + end, +} -- cgit v1.2.3