summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorBenjamin Chausse <benjamin@chausse.xyz>2023-09-24 03:23:52 -0400
committerBenjamin Chausse <benjamin@chausse.xyz>2023-09-24 03:23:52 -0400
commitadbe65a8bd41f17398a985d4c474ba7f907bb5d4 (patch)
treef4ef9f6bd5687edf35b71aaac31ad6604ba36806 /lua
Initial commit
Diffstat (limited to 'lua')
-rw-r--r--lua/ben/core/init.lua14
-rw-r--r--lua/ben/lazy.lua28
-rw-r--r--lua/ben/plugins/cmp.lua56
-rw-r--r--lua/ben/plugins/colorscheme.lua41
-rw-r--r--lua/ben/plugins/comments.lua5
-rw-r--r--lua/ben/plugins/copilot.lua3
-rw-r--r--lua/ben/plugins/fugitive.lua7
-rw-r--r--lua/ben/plugins/gitsigns.lua5
-rw-r--r--lua/ben/plugins/lsp/lspconfig.lua161
-rw-r--r--lua/ben/plugins/lsp/mason.lua57
-rw-r--r--lua/ben/plugins/lsp/null-ls.lua56
-rw-r--r--lua/ben/plugins/nvim-r.lua4
-rw-r--r--lua/ben/plugins/orgmode.lua26
-rw-r--r--lua/ben/plugins/startify.lua28
-rw-r--r--lua/ben/plugins/surround.lua4
-rw-r--r--lua/ben/plugins/telescope.lua25
-rw-r--r--lua/ben/plugins/treesitter-text-objects.lua53
-rw-r--r--lua/ben/plugins/treesitter.lua57
-rw-r--r--lua/ben/plugins/vimtex.lua4
19 files changed, 634 insertions, 0 deletions
diff --git a/lua/ben/core/init.lua b/lua/ben/core/init.lua
new file mode 100644
index 0000000..efdb794
--- /dev/null
+++ b/lua/ben/core/init.lua
@@ -0,0 +1,14 @@
+-- My Personal Configurations:
+
+-- Superior leader key
+vim.g.mapleader = ";"
+
+-- Space is quicker than Shift+Semicolon
+vim.keymap.set('n', '<space>', ":")
+
+-- fm -> File Manager
+vim.keymap.set('n', '<leader>fm', "<cmd>Exp<cr>")
+
+-- Tree View for the netrw File Manager
+vim.g.netrw_liststyle = 3
+vim.g.netrw_banner = 3
diff --git a/lua/ben/lazy.lua b/lua/ben/lazy.lua
new file mode 100644
index 0000000..a725823
--- /dev/null
+++ b/lua/ben/lazy.lua
@@ -0,0 +1,28 @@
+
+local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
+if not 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({
+ {import = "ben.plugins" },
+ {import = "ben.plugins.lsp" },
+}, {
+ install = {
+ colorscheme = { "friffle" },
+ },
+ checker = {
+ enabled = true,
+ notify = false,
+ },
+ change_detection = {
+ notify = false,
+ },
+})
diff --git a/lua/ben/plugins/cmp.lua b/lua/ben/plugins/cmp.lua
new file mode 100644
index 0000000..2038540
--- /dev/null
+++ b/lua/ben/plugins/cmp.lua
@@ -0,0 +1,56 @@
+return {
+ "hrsh7th/nvim-cmp",
+ event = "InsertEnter",
+ dependencies = {
+ "hrsh7th/cmp-buffer", -- source for text in buffer
+ "hrsh7th/cmp-path", -- source for file system paths
+ "L3MON4D3/LuaSnip", -- snippet engine
+ "saadparwaiz1/cmp_luasnip", -- for autocompletion
+ "rafamadriz/friendly-snippets", -- useful snippets
+ "onsails/lspkind.nvim", -- vs-code like pictograms
+ },
+ config = function()
+ local cmp = require("cmp")
+
+ local luasnip = require("luasnip")
+
+ local lspkind = require("lspkind")
+
+ -- loads vscode style snippets from installed plugins (e.g. friendly-snippets)
+ require("luasnip.loaders.from_vscode").lazy_load()
+
+ cmp.setup({
+ completion = {
+ completeopt = "menu,menuone,preview,noselect",
+ },
+ snippet = { -- configure how nvim-cmp interacts with snippet engine
+ expand = function(args)
+ luasnip.lsp_expand(args.body)
+ end,
+ },
+ mapping = cmp.mapping.preset.insert({
+ ["<C-k>"] = cmp.mapping.select_prev_item(), -- previous suggestion
+ ["<C-j>"] = cmp.mapping.select_next_item(), -- next suggestion
+ ["<C-b>"] = cmp.mapping.scroll_docs(-4),
+ ["<C-f>"] = cmp.mapping.scroll_docs(4),
+ ["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions
+ ["<C-e>"] = cmp.mapping.abort(), -- close completion window
+ ["<CR>"] = cmp.mapping.confirm({ select = false }),
+ }),
+ -- sources for autocompletion
+ sources = cmp.config.sources({
+ { name = "nvim_lsp" },
+ { name = "luasnip" }, -- snippets
+ { name = "buffer" }, -- text within current buffer
+ { name = "path" }, -- file system paths
+ }),
+ -- configure lspkind for vs-code like pictograms in completion menu
+ formatting = {
+ format = lspkind.cmp_format({
+ maxwidth = 50,
+ ellipsis_char = "...",
+ }),
+ },
+ })
+ end,
+}
diff --git a/lua/ben/plugins/colorscheme.lua b/lua/ben/plugins/colorscheme.lua
new file mode 100644
index 0000000..fce5735
--- /dev/null
+++ b/lua/ben/plugins/colorscheme.lua
@@ -0,0 +1,41 @@
+return {
+ -- My very own colorscheme
+ {
+ "ChausseBenjamin/friffle-vim",
+ priority = 1000,
+ config = function()
+ vim.cmd([[syntax on]]) -- Enable vim syntax
+ vim.cmd([[set tgc]]) -- Terminal GUI Colors
+ vim.cmd([[set lz]]) -- Lazy redraw
+ vim.cmd([[set t_Co=256]]) -- 256 Colors
+ vim.cmd([[colo friffle]]) -- Set the colorscheme
+ vim.cmd([[hi Normal guibg=NONE]])
+ vim.cmd([[hi CursorLineNr guibg=NONE]])
+ vim.cmd([[hi Constant guibg=NONE]])
+ vim.cmd([[hi Conceal guibg=NONE]])
+ vim.cmd([[hi Folded guibg=NONE]])
+ vim.cmd([[hi ColorColumn guibg='#738c9c']])
+ vim.cmd([[hi Todo guibg='#acb3b5' guifg='#340001']])
+ vim.cmd([[hi Search guifg='#810002' guibg='#738c9c']])
+ end,
+ },
+ -- Backup retro colorscheme
+ {
+ "djpohly/elly.vim",
+ lazy = true,
+ },
+ -- Treesitter optimized colorscheme
+ {
+ "neanias/everforest-nvim",
+ version = false,
+ lazy = true,
+ config = function()
+ require("everforest").setup({})
+ end,
+ },
+ -- Syntax for SXHKD
+ {
+ "kovetskiy/sxhkd-vim",
+ ft = "sxhkdrc",
+ },
+}
diff --git a/lua/ben/plugins/comments.lua b/lua/ben/plugins/comments.lua
new file mode 100644
index 0000000..b1267f6
--- /dev/null
+++ b/lua/ben/plugins/comments.lua
@@ -0,0 +1,5 @@
+return {
+ 'numToStr/Comment.nvim',
+ event = { 'BufReadPre', 'BufNewFile' },
+ config = true,
+}
diff --git a/lua/ben/plugins/copilot.lua b/lua/ben/plugins/copilot.lua
new file mode 100644
index 0000000..2347f29
--- /dev/null
+++ b/lua/ben/plugins/copilot.lua
@@ -0,0 +1,3 @@
+return {
+ "github/copilot.vim",
+}
diff --git a/lua/ben/plugins/fugitive.lua b/lua/ben/plugins/fugitive.lua
new file mode 100644
index 0000000..2ec2c88
--- /dev/null
+++ b/lua/ben/plugins/fugitive.lua
@@ -0,0 +1,7 @@
+return {
+ "tpope/vim-fugitive",
+ -- Only enable when in a git repo
+ cond = function()
+ return vim.fn.isdirectory(".git") == 1
+ end,
+}
diff --git a/lua/ben/plugins/gitsigns.lua b/lua/ben/plugins/gitsigns.lua
new file mode 100644
index 0000000..a3576c8
--- /dev/null
+++ b/lua/ben/plugins/gitsigns.lua
@@ -0,0 +1,5 @@
+return {
+ "lewis6991/gitsigns.nvim",
+ event = { "BufReadPre", "BufNewFile" },
+ config = true,
+}
diff --git a/lua/ben/plugins/lsp/lspconfig.lua b/lua/ben/plugins/lsp/lspconfig.lua
new file mode 100644
index 0000000..618a0ab
--- /dev/null
+++ b/lua/ben/plugins/lsp/lspconfig.lua
@@ -0,0 +1,161 @@
+return {
+ "neovim/nvim-lspconfig",
+ event = { "BufReadPre", "BufNewFile" },
+ dependencies = {
+ "hrsh7th/cmp-nvim-lsp",
+ { "antosha417/nvim-lsp-file-operations", config = true },
+ },
+ config = function()
+ -- import lspconfig plugin
+ local lspconfig = require("lspconfig")
+
+ -- import cmp-nvim-lsp plugin
+ local cmp_nvim_lsp = require("cmp_nvim_lsp")
+
+ local keymap = vim.keymap -- for conciseness
+
+ local opts = { noremap = true, silent = true }
+ local on_attach = function(client, bufnr)
+ opts.buffer = bufnr
+
+ -- set keybinds
+ opts.desc = "Show LSP references"
+ keymap.set("n", "gR", "<cmd>Telescope lsp_references<CR>", opts) -- show definition, references
+
+ opts.desc = "Go to declaration"
+ keymap.set("n", "gD", vim.lsp.buf.declaration, opts) -- go to declaration
+
+ opts.desc = "Show LSP definitions"
+ keymap.set("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts) -- show lsp definitions
+
+ opts.desc = "Show LSP implementations"
+ keymap.set("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts) -- show lsp implementations
+
+ opts.desc = "Show LSP type definitions"
+ keymap.set("n", "gt", "<cmd>Telescope lsp_type_definitions<CR>", opts) -- show lsp type definitions
+
+ opts.desc = "See available code actions"
+ keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection
+
+ opts.desc = "Smart rename"
+ keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts) -- smart rename
+
+ opts.desc = "Show buffer diagnostics"
+ keymap.set("n", "<leader>D", "<cmd>Telescope diagnostics bufnr=0<CR>", opts) -- show diagnostics for file
+
+ opts.desc = "Show line diagnostics"
+ keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts) -- show diagnostics for line
+
+ opts.desc = "Go to previous diagnostic"
+ keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) -- jump to previous diagnostic in buffer
+
+ opts.desc = "Go to next diagnostic"
+ keymap.set("n", "]d", vim.diagnostic.goto_next, opts) -- jump to next diagnostic in buffer
+
+ opts.desc = "Show documentation for what is under cursor"
+ keymap.set("n", "K", vim.lsp.buf.hover, opts) -- show documentation for what is under cursor
+
+ opts.desc = "Restart LSP"
+ keymap.set("n", "<leader>rs", ":LspRestart<CR>", opts) -- mapping to restart lsp if necessary
+ end
+
+ -- used to enable autocompletion (assign to every lsp server config)
+ local capabilities = cmp_nvim_lsp.default_capabilities()
+
+ -- Change the Diagnostic symbols in the sign column (gutter)
+ -- (not in youtube nvim video)
+ 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
+
+ -- configure html server
+ lspconfig["html"].setup({
+ capabilities = capabilities,
+ on_attach = on_attach,
+ })
+
+ -- configure typescript server with plugin
+ lspconfig["tsserver"].setup({
+ capabilities = capabilities,
+ on_attach = on_attach,
+ })
+
+ -- configure css server
+ lspconfig["cssls"].setup({
+ capabilities = capabilities,
+ on_attach = on_attach,
+ })
+
+ -- configure tailwindcss server
+ lspconfig["tailwindcss"].setup({
+ capabilities = capabilities,
+ on_attach = on_attach,
+ })
+
+ -- configure svelte server
+ lspconfig["svelte"].setup({
+ capabilities = capabilities,
+ on_attach = function(client, bufnr)
+ on_attach(client, bufnr)
+
+ vim.api.nvim_create_autocmd("BufWritePost", {
+ pattern = { "*.js", "*.ts" },
+ callback = function(ctx)
+ if client.name == "svelte" then
+ client.notify("$/onDidChangeTsOrJsFile", { uri = ctx.file })
+ end
+ end,
+ })
+ end,
+ })
+
+ -- configure prisma orm server
+ lspconfig["prismals"].setup({
+ capabilities = capabilities,
+ on_attach = on_attach,
+ })
+
+ -- configure graphql language server
+ lspconfig["graphql"].setup({
+ capabilities = capabilities,
+ on_attach = on_attach,
+ filetypes = { "graphql", "gql", "svelte", "typescriptreact", "javascriptreact" },
+ })
+
+ -- configure emmet language server
+ lspconfig["emmet_ls"].setup({
+ capabilities = capabilities,
+ on_attach = on_attach,
+ filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" },
+ })
+
+ -- configure python server
+ lspconfig["pyright"].setup({
+ capabilities = capabilities,
+ on_attach = on_attach,
+ })
+
+ -- configure lua server (with special settings)
+ lspconfig["lua_ls"].setup({
+ capabilities = capabilities,
+ on_attach = on_attach,
+ settings = { -- custom settings for lua
+ Lua = {
+ -- make the language server recognize "vim" global
+ diagnostics = {
+ globals = { "vim" },
+ },
+ workspace = {
+ -- make language server aware of runtime files
+ library = {
+ [vim.fn.expand("$VIMRUNTIME/lua")] = true,
+ [vim.fn.stdpath("config") .. "/lua"] = true,
+ },
+ },
+ },
+ },
+ })
+ end,
+}
diff --git a/lua/ben/plugins/lsp/mason.lua b/lua/ben/plugins/lsp/mason.lua
new file mode 100644
index 0000000..c1a3c10
--- /dev/null
+++ b/lua/ben/plugins/lsp/mason.lua
@@ -0,0 +1,57 @@
+return {
+ "williamboman/mason.nvim",
+ dependencies = {
+ "williamboman/mason-lspconfig.nvim",
+ "jayp0521/mason-null-ls.nvim",
+ },
+ config = function()
+ -- import mason
+ local mason = require("mason")
+
+ -- import mason-lspconfig
+ local mason_lspconfig = require("mason-lspconfig")
+
+ -- import mason-null-ls
+ local mason_null_ls = require("mason-null-ls")
+
+ -- enable mason and configure icons
+ mason.setup({
+ ui = {
+ icons = {
+ package_installed = "✓",
+ package_pending = "➜",
+ package_uninstalled = "✗"
+ }
+ }
+ })
+
+ mason_lspconfig.setup({
+ -- list of servers for mason to install
+ ensure_installed = {
+ "tsserver",
+ "html",
+ "cssls",
+ "tailwindcss",
+ "svelte",
+ "lua_ls",
+ "graphql",
+ "emmet_ls",
+ "prismals",
+ "pyright"
+ },
+ -- auto-install configured servers (with lspconfig)
+ automatic_installation = true, -- not the same as ensure_installed
+ })
+
+ mason_null_ls.setup({
+ -- list of formatters & linters for mason to install
+ ensure_installed = {
+ "prettier", -- ts/js formatter
+ "stylua", -- lua formatter
+ "eslint_d", -- ts/js linter
+ },
+ -- auto-install configured servers (with lspconfig)
+ automatic_installation = true,
+ })
+ end,
+}
diff --git a/lua/ben/plugins/lsp/null-ls.lua b/lua/ben/plugins/lsp/null-ls.lua
new file mode 100644
index 0000000..9db49cc
--- /dev/null
+++ b/lua/ben/plugins/lsp/null-ls.lua
@@ -0,0 +1,56 @@
+return {
+ "jose-elias-alvarez/null-ls.nvim", -- configure formatters & linters
+ event = { "BufReadPre", "BufNewFile" },
+ config = function()
+ -- import null-ls plugin
+ local null_ls = require("null-ls")
+
+ local null_ls_utils = require("null-ls.utils")
+
+ -- for conciseness
+ local formatting = null_ls.builtins.formatting -- to setup formatters
+ local diagnostics = null_ls.builtins.diagnostics -- to setup linters
+
+ -- to setup format on save
+ local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
+
+ -- configure null_ls
+ null_ls.setup({
+ -- add package.json as identifier for root (for typescript monorepos)
+ root_dir = null_ls_utils.root_pattern(".null-ls-root", "Makefile", ".git", "package.json"),
+ -- setup formatters & linters
+ sources = {
+ -- to disable file types use
+ -- "formatting.prettier.with({disabled_filetypes: {}})" (see null-ls docs)
+ formatting.prettier.with({
+ extra_filetypes = { "svelte" },
+ }), -- js/ts formatter
+ formatting.stylua, -- lua formatter
+ diagnostics.eslint_d.with({ -- js/ts linter
+ condition = function(utils)
+ return utils.root_has_file({ ".eslintrc.js", ".eslintrc.cjs" }) -- only enable if root has .eslintrc.js or .eslintrc.cjs
+ end,
+ }),
+ },
+ -- configure format on save
+ on_attach = function(current_client, bufnr)
+ if current_client.supports_method("textDocument/formatting") then
+ vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
+ vim.api.nvim_create_autocmd("BufWritePre", {
+ group = augroup,
+ buffer = bufnr,
+ callback = function()
+ vim.lsp.buf.format({
+ filter = function(client)
+ -- only use null-ls for formatting instead of lsp server
+ return client.name == "null-ls"
+ end,
+ bufnr = bufnr,
+ })
+ end,
+ })
+ end
+ end,
+ })
+ end,
+}
diff --git a/lua/ben/plugins/nvim-r.lua b/lua/ben/plugins/nvim-r.lua
new file mode 100644
index 0000000..0a38c0e
--- /dev/null
+++ b/lua/ben/plugins/nvim-r.lua
@@ -0,0 +1,4 @@
+return {
+ "jalvesaq/Nvim-R",
+ ft = { "R", "Rnoweb", "tex", "aux", "bib" },
+}
diff --git a/lua/ben/plugins/orgmode.lua b/lua/ben/plugins/orgmode.lua
new file mode 100644
index 0000000..1007b0a
--- /dev/null
+++ b/lua/ben/plugins/orgmode.lua
@@ -0,0 +1,26 @@
+return {
+ "nvim-orgmode/orgmode",
+ dependencies = {
+ { "nvim-treesitter/nvim-treesitter", lazy = true },
+ },
+ event = "VeryLazy",
+ config = function()
+ -- Load treesitter grammar for org
+ require("orgmode").setup_ts_grammar()
+
+ -- Setup treesitter
+ require("nvim-treesitter.configs").setup({
+ highlight = {
+ enable = true,
+ additional_vim_regex_highlighting = { "org" },
+ },
+ ensure_installed = { "org" },
+ })
+
+ -- Setup orgmode
+ require("orgmode").setup({
+ org_agenda_files = "~/Dropbox/org/*",
+ org_default_notes_file = "~/Dropbox/org/refile.org",
+ })
+ end,
+}
diff --git a/lua/ben/plugins/startify.lua b/lua/ben/plugins/startify.lua
new file mode 100644
index 0000000..07e3de5
--- /dev/null
+++ b/lua/ben/plugins/startify.lua
@@ -0,0 +1,28 @@
+return {
+ 'mhinz/vim-startify',
+ config = function()
+
+-- Define your custom header as a Lua table
+local header = {
+ ' _ _ _ ',
+ ' | \\ | | ___ _____ _(_)_ __ ___ ',
+ ' | \\| |/ _ \\/ _ \\ \\ / / | \'_ ` _ \\ ',
+ ' | |\\ | __/ (_) \\ V /| | | | | | | ',
+ ' |_| \\_|\\___|\\___/ \\_/ |_|_| |_| |_| ',
+ '',
+}
+
+
+-- Set the g:startify_custom_header variable
+local centered_header = vim.fn["startify#center"](header)
+vim.g.startify_custom_header = centered_header
+ end
+}
+
+-- _ _ _
+-- | \ | | ___ _____ _(_)_ __ ___
+-- | \| |/ _ \/ _ \ \ / / | '_ ` _ \
+-- | |\ | __/ (_) \ V /| | | | | | |
+-- |_| \_|\___|\___/ \_/ |_|_| |_| |_|
+--
+
diff --git a/lua/ben/plugins/surround.lua b/lua/ben/plugins/surround.lua
new file mode 100644
index 0000000..8465f29
--- /dev/null
+++ b/lua/ben/plugins/surround.lua
@@ -0,0 +1,4 @@
+return {
+ 'tpope/vim-surround',
+ dependencies = 'tpope/vim-repeat'
+}
diff --git a/lua/ben/plugins/telescope.lua b/lua/ben/plugins/telescope.lua
new file mode 100644
index 0000000..f5857cd
--- /dev/null
+++ b/lua/ben/plugins/telescope.lua
@@ -0,0 +1,25 @@
+return {
+ "nvim-telescope/telescope.nvim",
+ branch = "0.1.x",
+ dependencies = { "nvim-lua/plenary.nvim" },
+ keys = { -- LazyLoad telescope when it's actually needed
+
+ -- F.ind F.iles
+ { "<leader>ff", '<cmd>lua require("telescope.builtin").find_files()<cr>' },
+
+ -- F.ind B.uffers
+ { "<leader>fb", '<cmd>lua require("telescope.builtin").buffers()<cr>' },
+
+ -- F.ind G.it
+ { "<leader>fg", '<cmd>lua require("telescope.builtin").git_files()<cr>' },
+
+ -- F.ind H.elp
+ { "<leader>fh", '<cmd>lua require("telescope.builtin").help_tags()<cr>' },
+
+ -- F.ind Q.uick F.ix
+ { "<leader>fqf", '<cmd>lua require("telescope.builtin").quickfix()<cr>' },
+
+ -- F.ind C.olor S.cheme
+ { "<leader>fcs", '<cmd>lua require("telescope.builtin").colorscheme()<cr>' },
+ },
+}
diff --git a/lua/ben/plugins/treesitter-text-objects.lua b/lua/ben/plugins/treesitter-text-objects.lua
new file mode 100644
index 0000000..bcf1b92
--- /dev/null
+++ b/lua/ben/plugins/treesitter-text-objects.lua
@@ -0,0 +1,53 @@
+return {
+ "nvim-treesitter/nvim-treesitter-textobjects",
+ event = { "BufReadPost", "BufNewFile" },
+ dependencies = {
+ "nvim-treesitter/nvim-treesitter",
+ },
+ config = function()
+ require("nvim-treesitter.configs").setup({
+ textobjects = {
+ select = {
+ enable = true,
+
+ -- Automatically jump forward to textobj, similar to targets.vim
+ lookahead = true,
+
+ keymaps = {
+ -- You can use the capture groups defined in textobjects.scm
+ ["a="] = { query = "@assignment.outer", desc = "Select outer part of an assignment region" },
+ ["i="] = { query = "@assignment.inner", desc = "Select inner part of an assignment region" },
+
+ ["a:"] = { query = "@parameter.outer", desc = "Select outer part of a parameter/field region" },
+ ["i:"] = { query = "@parameter.inner", desc = "Select inner part of a parameter/field region" },
+
+ ["ai"] = { query = "@conditional.outer", desc = "Select outer part of a conditional region" },
+ ["ii"] = { query = "@conditional.inner", desc = "Select inner part of a conditional region" },
+
+ ["al"] = { query = "@loop.outer", desc = "Select outer part of a loop region" },
+ ["il"] = { query = "@loop.inner", desc = "Select inner part of a loop region" },
+
+ ["ab"] = { query = "@block.outer", desc = "Select outer part of a block region" }, -- overrides default text object block of parenthesis to parenthesis
+ ["ib"] = { query = "@block.inner", desc = "Select inner part of a block region" }, -- overrides default text object block of parenthesis to parenthesis
+
+ ["af"] = { query = "@function.outer", desc = "Select outer part of a function region" },
+ ["if"] = { query = "@function.inner", desc = "Select inner part of a function region" },
+
+ ["ac"] = { query = "@class.outer", desc = "Select outer part of a class region" },
+ ["ic"] = { query = "@class.inner", desc = "Select inner part of a class region" },
+ },
+ include_surrounding_whitespace = true,
+ },
+ swap = {
+ enable = true,
+ swap_next = {
+ ["<leader>on"] = "@parameter.inner", -- swap object under cursor with next
+ },
+ swap_previous = {
+ ["<leader>op"] = "@parameter.inner", -- swap object under cursor with previous
+ },
+ },
+ },
+ })
+ end,
+}
diff --git a/lua/ben/plugins/treesitter.lua b/lua/ben/plugins/treesitter.lua
new file mode 100644
index 0000000..362318d
--- /dev/null
+++ b/lua/ben/plugins/treesitter.lua
@@ -0,0 +1,57 @@
+return {
+ {
+ "nvim-treesitter/nvim-treesitter",
+ event = { "BufReadPre", "BufNewFile" },
+ build = ":TSUpdate",
+ dependencies = {
+ "windwp/nvim-ts-autotag",
+ },
+ config = function()
+ -- import nvim-treesitter plugin
+ local treesitter = require("nvim-treesitter.configs")
+
+ -- configure treesitter
+ treesitter.setup({ -- enable syntax highlighting
+ highlight = {
+ enable = true,
+ },
+ -- enable indentation
+ indent = { enable = true },
+ -- enable autotagging (w/ nvim-ts-autotag plugin)
+ autotag = { enable = true },
+ -- ensure these language parsers are installed
+ ensure_installed = {
+ "json",
+ "javascript",
+ "typescript",
+ "yaml",
+ "html",
+ "css",
+ "markdown",
+ "markdown_inline",
+ "graphql",
+ "bash",
+ "lua",
+ "go",
+ "latex",
+ "bibtex",
+ "rnoweb",
+ "org",
+ "rust",
+ "c",
+ "vim",
+ "nix",
+ "dockerfile",
+ "gitignore",
+ },
+ -- enable nvim-ts-context-commentstring plugin for commenting tsx and jsx
+ context_commentstring = {
+ enable = true,
+ enable_autocmd = false,
+ },
+ -- auto install above language parsers
+ auto_install = true,
+ })
+ end,
+ },
+}
diff --git a/lua/ben/plugins/vimtex.lua b/lua/ben/plugins/vimtex.lua
new file mode 100644
index 0000000..38b3676
--- /dev/null
+++ b/lua/ben/plugins/vimtex.lua
@@ -0,0 +1,4 @@
+return {
+ "lervag/vimtex",
+ ft = { "texinfo", "tex", "aux", "bib" },
+}