summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/config/lazy.lua54
-rw-r--r--lua/config/plugins/aerial.lua19
-rw-r--r--lua/config/plugins/colorizer.lua14
-rw-r--r--lua/config/plugins/colorscheme.lua64
-rw-r--r--lua/config/plugins/comments.lua7
-rw-r--r--lua/config/plugins/completion.lua24
-rw-r--r--lua/config/plugins/git.lua81
-rw-r--r--lua/config/plugins/icons.lua36
-rw-r--r--lua/config/plugins/lastplace.lua17
-rw-r--r--lua/config/plugins/lsp.lua106
-rw-r--r--lua/config/plugins/notes.lua35
-rw-r--r--lua/config/plugins/oil.lua9
-rw-r--r--lua/config/plugins/rest.lua24
-rw-r--r--lua/config/plugins/statusline.lua54
-rw-r--r--lua/config/plugins/telescope.lua117
-rw-r--r--lua/config/plugins/treesitter.lua179
-rw-r--r--lua/config/plugins/whichkey.lua13
-rw-r--r--lua/config/terminal.lua72
18 files changed, 925 insertions, 0 deletions
diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua
new file mode 100644
index 0000000..020b0bc
--- /dev/null
+++ b/lua/config/lazy.lua
@@ -0,0 +1,54 @@
+-- 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"
+ local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
+ if vim.v.shell_error ~= 0 then
+ vim.api.nvim_echo({
+ { "Failed to clone lazy.nvim:\n", "ErrorMsg" },
+ { out, "WarningMsg" },
+ { "\nPress any key to exit..." },
+ }, true, {})
+ vim.fn.getchar()
+ os.exit(1)
+ end
+end
+vim.opt.rtp:prepend(lazypath)
+
+-- Make sure to setup `mapleader` and `maplocalleader` before
+-- loading lazy.nvim so that mappings are correct.
+-- This is also a good place to setup other settings (vim.opt)
+vim.g.mapleader = " "
+vim.g.maplocalleader = " "
+
+-- Setup lazy.nvim
+require("lazy").setup({
+ spec = {
+ "rest-nvim/rest.nvim",
+ {
+ "mikemcbride/gruvbox-material.nvim",
+ priority = 1000,
+ as = "gruvbox_material",
+ config = function()
+ vim.cmd.colorscheme("gruvbox_material")
+ end,
+ },
+ { import = "config.plugins" },
+ },
+ rocks = {
+ hererocks = true,
+ },
+ change_detection = {
+ enabled = false,
+ notify = false,
+ },
+ -- Configure any other settings here. See the documentation for more details.
+ -- colorscheme that will be used when installing plugins.
+ install = {
+ missing = true,
+ colorscheme = { "habamax" },
+ },
+ checker = { enabled = false },
+})
+
+vim.opt.rtp:prepend("/usr/lib/x86_64-linux-gnu/nvim/")
diff --git a/lua/config/plugins/aerial.lua b/lua/config/plugins/aerial.lua
new file mode 100644
index 0000000..d3ff5f6
--- /dev/null
+++ b/lua/config/plugins/aerial.lua
@@ -0,0 +1,19 @@
+return {
+ {
+ "stevearc/aerial.nvim",
+ opts = {},
+ dependencies = {
+ "nvim-treesitter/nvim-treesitter",
+ "nvim-tree/nvim-web-devicons"
+ },
+ config = function()
+ require("aerial").setup({
+ on_attach = function(bufnr)
+ vim.keymap.set("n", "{", "<cmd>AerialPrev<CR>", { buffer = bufnr })
+ vim.keymap.set("n", "}", "<cmd>AerialNext<CR>", { buffer = bufnr })
+ end,
+ })
+ vim.keymap.set("n", "<leader>ua", "<CMD>AerialToggle!<CR>")
+ end,
+ },
+}
diff --git a/lua/config/plugins/colorizer.lua b/lua/config/plugins/colorizer.lua
new file mode 100644
index 0000000..b3ba3c8
--- /dev/null
+++ b/lua/config/plugins/colorizer.lua
@@ -0,0 +1,14 @@
+return {
+ {
+ "norcalli/nvim-colorizer.lua",
+ config = function()
+ require("colorizer").setup({
+ css = { css = true },
+ sass = { css = true },
+ javascript = { rgb_fn = true },
+ "haml",
+ "html",
+ })
+ end,
+ },
+}
diff --git a/lua/config/plugins/colorscheme.lua b/lua/config/plugins/colorscheme.lua
new file mode 100644
index 0000000..056e4b6
--- /dev/null
+++ b/lua/config/plugins/colorscheme.lua
@@ -0,0 +1,64 @@
+return {
+ -- NeoVim dark colorscheme inspired by the colors of the famous painting by Katsushika Hokusai.
+ {
+ "rebelot/kanagawa.nvim",
+ dependencies = { "nvim-treesitter/nvim-treesitter" },
+ config = function()
+ require("kanagawa").setup({
+ compile = false,
+ undercurl = true,
+ commentStyle = { italic = true },
+ functionStyle = {},
+ keywordStyle = { italic = true },
+ statementStyle = { bold = true },
+ typeStyle = {},
+ transparent = false,
+ dimInactive = true,
+ terminalColors = true,
+ colors = {
+ palette = {},
+ theme = { wave = {}, lotus = {}, dragon = {}, all = {} },
+ },
+ theme = "dragon",
+ background = {
+ dark = "wave",
+ light = "lotus"
+ },
+ overrides = function(colors)
+ local theme = colors.theme
+ local makeDiagnosticColor = function(color)
+ local c = require("kanagawa.lib.color")
+ return { fg = color, bg = c(color):blend(theme.ui.bg, 0.95):to_hex() }
+ end
+ return {
+ DiagnosticVirtualTextHint = makeDiagnosticColor(theme.diag.hint),
+ DiagnosticVirtualTextInfo = makeDiagnosticColor(theme.diag.info),
+ DiagnosticVirtualTextWarn = makeDiagnosticColor(theme.diag.warning),
+ DiagnosticVirtualTextError = makeDiagnosticColor(theme.diag.error),
+
+ NormalFloat = { bg = "none" },
+ FloatBorder = { bg = "none" },
+ FloatTitle = { bg = "none" },
+
+ NormalDark = { fg = theme.ui.fg_dim, bg = theme.ui.bg_m3 },
+ LazyNormal = { bg = theme.ui.bg_m3, fg = theme.ui.fg_dim },
+
+ Pmenu = { fg = theme.ui.shade0, bg = theme.ui.bg_p1 }, -- add `blend = vim.o.pumblend` to enable transparency
+ PmenuSel = { fg = "NONE", bg = theme.ui.bg_p2 },
+ PmenuSbar = { bg = theme.ui.bg_m1 },
+ PmenuThumb = { bg = theme.ui.bg_p2 },
+
+ TelescopeTitle = { fg = theme.ui.special, bold = true },
+ TelescopePromptNormal = { bg = theme.ui.bg_p1 },
+ TelescopePromptBorder = { fg = theme.ui.bg_p1, bg = theme.ui.bg_p1 },
+ TelescopeResultsNormal = { fg = theme.ui.fg_dim, bg = theme.ui.bg_m1 },
+ TelescopeResultsBorder = { fg = theme.ui.bg_m1, bg = theme.ui.bg_m1 },
+ TelescopePreviewNormal = { bg = theme.ui.bg_dim },
+ TelescopePreviewBorder = { bg = theme.ui.bg_dim, fg = theme.ui.bg_dim },
+ }
+ end,
+ })
+ vim.cmd.colorscheme("kanagawa")
+ end,
+ },
+}
diff --git a/lua/config/plugins/comments.lua b/lua/config/plugins/comments.lua
new file mode 100644
index 0000000..1ec45f1
--- /dev/null
+++ b/lua/config/plugins/comments.lua
@@ -0,0 +1,7 @@
+return {
+ {
+ "folke/todo-comments.nvim",
+ dependencies = { "nvim-lua/plenary.nvim" },
+ opts = {},
+ },
+}
diff --git a/lua/config/plugins/completion.lua b/lua/config/plugins/completion.lua
new file mode 100644
index 0000000..722891a
--- /dev/null
+++ b/lua/config/plugins/completion.lua
@@ -0,0 +1,24 @@
+return {
+ {
+ "saghen/blink.cmp",
+ dependencies = "rafamadriz/friendly-snippets",
+
+ version = "v0.10.0",
+
+ opts = {
+ keymap = { preset = 'default' },
+
+ appearance = {
+ use_nvim_cmp_as_default = true,
+ nerd_font_variant = 'mono'
+ },
+
+ sources = {
+ default = { "lsp", "path", "snippets", "buffer" },
+ },
+
+ signature = { enabled = true },
+ },
+ opts_extend = { "sources.default" }
+ }
+}
diff --git a/lua/config/plugins/git.lua b/lua/config/plugins/git.lua
new file mode 100644
index 0000000..5502ce7
--- /dev/null
+++ b/lua/config/plugins/git.lua
@@ -0,0 +1,81 @@
+return {
+ {
+ "lewis6991/gitsigns.nvim",
+ config = function()
+ local gitsigns = require("gitsigns")
+
+ gitsigns.setup({
+ signs_staged_enable = true,
+ signcolumn = true,
+ numhl = true,
+ linehl = false,
+ word_diff = false,
+ watch_gitdir = {
+ follow_files = true
+ },
+ auto_attach = true,
+ attach_to_untracked = false,
+ current_line_blame = false,
+ current_line_blame_opts = {
+ virt_text = true,
+ virt_text_pos = "eol",
+ delay = 1000,
+ ignore_whitespace = false,
+ virt_text_priority = 100,
+ use_focus = true,
+ },
+ current_line_blame_formatter = "<author>, <author_time:%R> - <summary>",
+ sign_priority = 6,
+ update_debounce = 100,
+ status_formatter = nil,
+ max_file_length = 40000, -- Disable if file is longer than this (in lines)
+ preview_config = {
+ border = "none",
+ style = "minimal",
+ relative = "cursor",
+ row = 0,
+ col = 1,
+ },
+
+ on_attach = function(bufnr)
+ local function map(mode, l, r, opts)
+ opts = opts or {}
+ opts.buffer = bufnr
+ vim.keymap.set(mode, l, r, opts)
+ end
+
+ -- Navigation
+ map("n", "]c", function()
+ if vim.wo.diff then
+ vim.cmd.normal({ "]c", bang = true })
+ else
+ gitsigns.nav_hunk("next", { target = "all" })
+ end
+ end, { desc = "Goto next change" })
+
+ map("n", "[c", function()
+ if vim.wo.diff then
+ vim.cmd.normal({ "[c", bang = true })
+ else
+ gitsigns.nav_hunk("prev", { target = "all" })
+ end
+ end, { desc = "Goto previous change" })
+
+ -- Actions
+ map("n", "<Leader>ga", gitsigns.stage_hunk, { desc = "stages the current block of changes to git" })
+ map("n", "<Leader>gu", gitsigns.undo_stage_hunk, { desc = "undo the last (git) staged change" })
+ map("n", "<Leader>gp", gitsigns.preview_hunk, { desc = "show the git diff for the current change block" })
+
+ map("n", "<Leader>gb", gitsigns.blame, { desc = "git blame for the whole file" })
+ map("n", "<Leader>gl", gitsigns.blame_line, { desc = "git blame for the current line" })
+
+ map("n", "<Leader>gh", gitsigns.toggle_linehl, { desc = "toggle git diff highlight by line" })
+ map("n", "<Leader>gw", gitsigns.toggle_word_diff, { desc = "toggle git diff highlight by word" })
+
+ -- Text object
+ map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>")
+ end,
+ })
+ end,
+ },
+}
diff --git a/lua/config/plugins/icons.lua b/lua/config/plugins/icons.lua
new file mode 100644
index 0000000..54a924e
--- /dev/null
+++ b/lua/config/plugins/icons.lua
@@ -0,0 +1,36 @@
+return {
+ {
+ "nvim-tree/nvim-web-devicons",
+ lazy = false,
+ config = function()
+ require("nvim-web-devicons").setup({
+ color_icons = true,
+ default = true,
+ strict = true,
+ variant = "dark",
+ override = {
+ zsh = {
+ icon = "",
+ color = "#428850",
+ cterm_color = "65",
+ name = "Zsh"
+ },
+ },
+ override_by_filename = {
+ [".gitignore"] = {
+ icon = "",
+ color = "#f1502f",
+ name = "Gitignore"
+ },
+ },
+ override_by_extension = {
+ ["log"] = {
+ icon = "",
+ color = "#81e043",
+ name = "Log"
+ },
+ },
+ })
+ end,
+ },
+}
diff --git a/lua/config/plugins/lastplace.lua b/lua/config/plugins/lastplace.lua
new file mode 100644
index 0000000..f409397
--- /dev/null
+++ b/lua/config/plugins/lastplace.lua
@@ -0,0 +1,17 @@
+return {
+ -- Intelligently reopen files at your last edit position in Vim.
+ {
+ "ethanholz/nvim-lastplace",
+ config = function()
+ require("nvim-lastplace").setup({
+ lastplace_ignore_buftype = { "quickfix", "nofile", "help" },
+ lastplace_ignore_filetype = { "gitcommit", "gitrebase" },
+ lastplace_open_folds = true
+ })
+ end
+ },
+
+ -- vim-fetch enables Vim to process line and column jump specifications
+ -- in file paths as found in stack traces and similar output.
+ { "wsdjeg/vim-fetch" },
+}
diff --git a/lua/config/plugins/lsp.lua b/lua/config/plugins/lsp.lua
new file mode 100644
index 0000000..16e785d
--- /dev/null
+++ b/lua/config/plugins/lsp.lua
@@ -0,0 +1,106 @@
+return {
+ {
+ "neovim/nvim-lspconfig",
+ dependencies = {
+ "saghen/blink.cmp",
+ },
+ opts = {
+ servers = {
+ clangd = {
+ cmd = {
+ "clangd",
+ "--header-insertion=iwyu",
+ "--background-index",
+ "--clang-tidy",
+ "--log=verbose",
+ },
+ filetypes = { "c", "cpp", "objc", "objcpp", "cuda", "proto" },
+ single_file_support = true,
+ },
+ cssls = {},
+ html = {},
+ jsonls = {},
+ lua_ls = {
+ settings = {
+ Lua = {
+ runtime = {
+ version = "LuaJIT",
+ },
+ diagnostics = {
+ globals = {
+ "vim",
+ "require",
+ },
+ },
+ workspace = {
+ library = vim.api.nvim_get_runtime_file("", true),
+ },
+ telemetry = {
+ enable = false,
+ },
+ },
+ },
+ },
+ marksman = {},
+ solargraph = {
+ cmd = {
+ vim.fn.expand('~/.local/share/nvim/mason/bin/solargraph'),
+ 'stdio',
+ },
+ },
+ ts_ls = {},
+ },
+ },
+
+ config = function(_, opts)
+ local lspconfig = require("lspconfig")
+ local blink = require("blink.cmp")
+
+ for server, config in pairs(opts.servers) do
+ config.capabilities = blink.get_lsp_capabilities()
+ lspconfig[server].setup(config)
+ end
+
+ vim.api.nvim_create_autocmd("LspAttach", {
+ callback = function(args)
+ local client = vim.lsp.get_client_by_id(args.data.client_id)
+ if not client then return end
+
+ vim.keymap.set("n", "gd", vim.lsp.buf.definition, { desc = "Jumps to definition", buffer = args.buf })
+ vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { desc = "Jumps to declaration", buffer = args.buf })
+ vim.keymap.set("n", "gi", vim.lsp.buf.implementation, { desc = "Lists all implementations", buffer = args.buf })
+
+ vim.keymap.set("n", "<Leader>cf", function() vim.lsp.buf.format({ async = true, buffer = args.buf }) end,
+ { desc = "Formats a buffer", buffer = args.buf })
+ vim.keymap.set("v", "<C-f>", function() vim.lsp.buf.format({ async = true, buffer = args.buf }) end,
+ { desc = "Formats a buffer", buffer = args.buf })
+
+ -- Disabled, kept temporarily here just for reference
+ if false and vim.bo.filetype == "lua" then
+ if client.supports_method("textDocument/formatting") then
+ vim.api.nvim_create_autocmd("BufWritePre", {
+ buffer = args.buf,
+ callback = function()
+ vim.lsp.buf.format({ bufnr = args.buf, id = client.id })
+ end,
+ })
+ end
+ end
+ end
+ })
+
+ vim.diagnostic.config({
+ underline = true,
+ virtual_text = { prefix = " ●", },
+ signs = {
+ text = {
+ [vim.diagnostic.severity.ERROR] = "",
+ [vim.diagnostic.severity.WARN] = "",
+ [vim.diagnostic.severity.INFO] = "",
+ [vim.diagnostic.severity.HINT] = "",
+ },
+ },
+ })
+ end,
+ },
+}
diff --git a/lua/config/plugins/notes.lua b/lua/config/plugins/notes.lua
new file mode 100644
index 0000000..c374e94
--- /dev/null
+++ b/lua/config/plugins/notes.lua
@@ -0,0 +1,35 @@
+return {
+ {
+ "zk-org/zk-nvim",
+ config = function()
+ require("zk").setup({
+ picker = "telescope",
+ lsp = {
+ config = {
+ cmd = { "zk", "lsp" },
+ name = "zk",
+ },
+ auto_attach = {
+ enabled = true,
+ filetypes = { "markdown" },
+ },
+ },
+ })
+
+ local opts = { noremap = true, silent = false }
+
+ -- Create a new note after asking for its title.
+ vim.api.nvim_set_keymap("n", "<leader>zn", "<Cmd>ZkNew { title = vim.fn.input('Title: ') }<CR>", opts)
+
+ -- Open notes.
+ vim.api.nvim_set_keymap("n", "<leader>zo", "<Cmd>ZkNotes { sort = { 'modified' } }<CR>", opts)
+ -- Open notes associated with the selected tags.
+ vim.api.nvim_set_keymap("n", "<leader>zt", "<Cmd>ZkTags<CR>", opts)
+
+ -- Search for the notes matching a given query.
+ vim.api.nvim_set_keymap("n", "<leader>zf", "<Cmd>ZkNotes { sort = { 'modified' }, match = { vim.fn.input('Search: ') } }<CR>", opts)
+ -- Search for the notes matching the current visual selection.
+ vim.api.nvim_set_keymap("v", "<leader>zf", ":'<,'>ZkMatch<CR>", opts)
+ end
+ }
+}
diff --git a/lua/config/plugins/oil.lua b/lua/config/plugins/oil.lua
new file mode 100644
index 0000000..9795053
--- /dev/null
+++ b/lua/config/plugins/oil.lua
@@ -0,0 +1,9 @@
+return {
+ {
+ "stevearc/oil.nvim",
+ opts = {},
+ dependencies = {
+ "nvim-tree/nvim-web-devicons",
+ },
+ },
+}
diff --git a/lua/config/plugins/rest.lua b/lua/config/plugins/rest.lua
new file mode 100644
index 0000000..e172764
--- /dev/null
+++ b/lua/config/plugins/rest.lua
@@ -0,0 +1,24 @@
+return {
+ {
+ "rest-nvim/rest.nvim",
+ dependencies = {
+ "nvim-treesitter/nvim-treesitter",
+ opts = function(_, opts)
+ opts.ensure_installed = opts.ensure_installed or {}
+ table.insert(opts.ensure_installed, "http")
+ end,
+ init = function()
+ vim.g.rest_nvim = {
+ request = {
+ hooks = {
+ user_agent = "neovim",
+ },
+ },
+ cookies = {
+ enable = false,
+ },
+ }
+ end,
+ },
+ },
+}
diff --git a/lua/config/plugins/statusline.lua b/lua/config/plugins/statusline.lua
new file mode 100644
index 0000000..0ca9582
--- /dev/null
+++ b/lua/config/plugins/statusline.lua
@@ -0,0 +1,54 @@
+return {
+ {
+ "nvim-lualine/lualine.nvim",
+ dependencies = { "nvim-tree/nvim-web-devicons", lazy = true },
+ config = function()
+ require("lualine").setup {
+ options = {
+ icons_enabled = true,
+ ignore_focus = {},
+ always_divide_middle = true,
+ separator = { left = "", right = "" },
+ section_separators = "",
+ component_separators = "",
+ },
+ sections = {
+ lualine_a = { "mode" },
+ lualine_b = {
+ { "branch", icon = "" },
+ { "diff", symbols = { added = " ", modified = " ", removed = " " } },
+ { "diagnostics" },
+ },
+ lualine_c = { '%=', { "filename", path = 1 } },
+ lualine_x = {},
+ lualine_y = { "fileformat", "encoding", "filetype" },
+ lualine_z = { "progress", "location" },
+ },
+ inactive_sections = {
+ lualine_a = {
+ { function() return vim.api.nvim_win_get_number(0) end }
+ },
+ lualine_b = {},
+ lualine_c = { '%=', { "filename", path = 1 } },
+ lualine_x = {},
+ lualine_y = { "filetype" },
+ lualine_z = { "location" },
+ },
+ tabline = {
+ lualine_a = {
+ {
+ "tabs",
+ show_modified_status = true,
+ use_mode_colors = true,
+ mode = 2,
+ },
+ },
+ lualine_b = {
+ { "aerial", },
+ },
+ },
+ extensions = { "aerial", "lazy", "oil", "quickfix" }
+ }
+ end,
+ },
+}
diff --git a/lua/config/plugins/telescope.lua b/lua/config/plugins/telescope.lua
new file mode 100644
index 0000000..4faa22b
--- /dev/null
+++ b/lua/config/plugins/telescope.lua
@@ -0,0 +1,117 @@
+return {
+ {
+ "nvim-telescope/telescope.nvim",
+ tag = "0.1.8",
+ dependencies = {
+ "nvim-lua/plenary.nvim",
+ {
+ "nvim-telescope/telescope-fzf-native.nvim",
+ build = "make",
+ config = function()
+ require("telescope").load_extension("fzf")
+ end,
+ },
+ },
+ config = function()
+ local actions = require("telescope.actions")
+ local action_layout = require("telescope.actions.layout")
+
+ local grep_appearance = {
+ layout_strategies = "vertical",
+ theme = "dropdown",
+ layout_config = {
+ prompt_position = "bottom",
+ width = 0.7,
+ height = 0.5,
+ },
+ }
+
+ local telescope = require("telescope")
+ telescope.setup({
+ defaults = {
+ mappings = {
+ i = {
+ ["<C-h>"] = "which_key",
+ ["<C-c>"] = false,
+ ["<C-f>"] = actions.to_fuzzy_refine,
+ ["<ESC>"] = actions.close,
+ ["<M-p>"] = action_layout.toggle_preview,
+ },
+ },
+ },
+ pickers = {
+ buffers = {
+ theme = "dropdown",
+ layout_config = {
+ prompt_position = "bottom",
+ },
+ previewer = false,
+ sort_lastused = true,
+ sort_mru = true,
+ ignore_current_buffer = true,
+ },
+ live_grep = grep_appearance,
+ grep_string = grep_appearance,
+ help_tags = {
+ theme = "dropdown",
+ layout_strategies = "vertical",
+ layout_config = {
+ width = 0.7,
+ },
+ },
+ },
+ extensions = {
+ fzf = {},
+ },
+ })
+
+ local builtin = require("telescope.builtin")
+
+ vim.keymap.set("n", "<Leader>b", builtin.buffers, { desc = "List buffers" })
+ vim.keymap.set("n", "<Leader>B", function()
+ builtin.live_grep({ grep_open_files = true })
+ end, { desc = "Searches open buffers contents" })
+
+ vim.keymap.set("n", "<Leader>f", builtin.live_grep, { desc = "Search file contents" })
+ vim.keymap.set("n", "<Leader>F", builtin.grep_string, { desc = "Search for the string under the cursor" })
+
+ vim.keymap.set("n", "<Leader>m", function()
+ builtin.treesitter({
+ symbols = "function",
+ previewer = true,
+ prompt_title = "Functions",
+ prompt_prefix = "𝑓"
+ })
+ end, { desc = "Lists function names from treesitter queries", })
+
+ vim.keymap.set("n", "<Leader>o", function()
+ local ok, _ = pcall(builtin.git_files, { previewer = false })
+ if not ok then
+ builtin.find_files()
+ end
+ end, { desc = "Open a file" })
+ vim.keymap.set("n", "<Leader>O", builtin.find_files, { desc = "Open a file" })
+
+ vim.keymap.set("n", "<Leader>gf", function()
+ local ok, _ = pcall(builtin.git_status, { previewer = false })
+ if not ok then
+ builtin.find_files()
+ end
+ end, { desc = "Show files marked as modified by git." })
+ vim.keymap.set("n", "<Leader>gF", function()
+ local ok, _ = pcall(builtin.git_files, {
+ previewer = false,
+ git_command = { "git", "diff-tree", "--no-commit-id", "--name-only", "HEAD", "-r" }
+ })
+ if not ok then
+ builtin.find_files()
+ end
+ end, { desc = "Show files in the present git commit." })
+
+ vim.keymap.set("n", "<Leader>gc", "<CMD>Telescope git_commits<CR>", { desc = "Show commits" })
+ vim.keymap.set("n", "<Leader>gC", "<CMD>Telescope git_bcommits<CR>", { desc = "Show commits for the current buffer" })
+
+ telescope.load_extension("zk")
+ end,
+ },
+}
diff --git a/lua/config/plugins/treesitter.lua b/lua/config/plugins/treesitter.lua
new file mode 100644
index 0000000..654c688
--- /dev/null
+++ b/lua/config/plugins/treesitter.lua
@@ -0,0 +1,179 @@
+return {
+ {
+ "nvim-treesitter/nvim-treesitter",
+ dependencies = {
+ "nvim-treesitter/nvim-treesitter-textobjects",
+ {
+ "nvim-treesitter/nvim-treesitter-context",
+ enabled = false,
+ config = function()
+ require("treesitter-context").setup({
+ mode = "cursor",
+ max_lines = 5,
+ multiline_threshold = 5,
+ })
+ end,
+ },
+ },
+ build = ":TSUpdate",
+ config = function()
+ require("nvim-treesitter.configs").setup({
+ ensure_installed = {
+ "bash",
+ "c",
+ "css",
+ "diff",
+ "gitcommit",
+ "html",
+ "http",
+ "javascript",
+ "json",
+ "lua",
+ "make",
+ "markdown",
+ "markdown_inline",
+ "query",
+ "ruby",
+ "vim",
+ "vimdoc",
+ "xml",
+ "yaml",
+ },
+ auto_install = false,
+ indent = { enable = true },
+
+ highlight = {
+ enable = true,
+ disable = function(_, buf)
+ local max_filesize = 100 * 1024 -- 100 KB
+ local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
+ if ok and stats and stats.size > max_filesize then
+ return true
+ end
+ end,
+ additional_vim_regex_highlighting = false,
+ },
+
+ textobjects = {
+ select = {
+ enable = true,
+ lookahead = true,
+ keymaps = {
+ ["aa"] = "@parameter.outer",
+ ["ia"] = "@parameter.inner",
+ ["af"] = "@function.outer",
+ ["if"] = "@function.inner",
+ ["ac"] = "@class.outer",
+ ["ic"] = "@class.inner",
+ ["ai"] = "@conditional.outer",
+ ["ii"] = "@conditional.inner",
+ ["al"] = "@loop.outer",
+ ["il"] = "@loop.inner",
+ ["ab"] = "@block.outer",
+ ["ib"] = "@loop.inner",
+ ["at"] = "@comment.outer",
+ },
+ },
+
+ move = {
+ enable = true,
+ set_jumps = true,
+ goto_next_start = {
+ ["]p"] = "@parameter.inner",
+ ["]m"] = "@function.outer",
+ ["]]"] = "@class.outer",
+ ["]l"] = "@loop.outer",
+ ["]i"] = "@conditional.outer",
+ ["]b"] = "@block.outer",
+ ["]t"] = "@comment.outer",
+ },
+ goto_next_end = {
+ ["]P"] = "@parameter.inner",
+ ["]M"] = "@function.outer",
+ ["]["] = "@class.outer",
+ ["]L"] = "@loop.outer",
+ ["]B"] = "@block.outer",
+ },
+ goto_previous_start = {
+ ["[p"] = "@parameter.inner",
+ ["[m"] = "@function.outer",
+ ["[["] = "@class.outer",
+ ["[l"] = "@loop.outer",
+ ["[i"] = "@conditional.outer",
+ ["[b"] = "@block.outer",
+ ["[t"] = "@comment.outer",
+ },
+ goto_previous_end = {
+ ["[P"] = "@parameter.inner",
+ ["[M"] = "@function.outer",
+ ["[]"] = "@class.outer",
+ ["[L"] = "@loop.outer",
+ ["[B"] = "@block.outer",
+ },
+ },
+
+ swap = {
+ enable = true,
+ swap_next = {
+ ["<Leader>a"] = "@parameter.inner",
+ },
+ swap_previous = {
+ ["<Leader>A"] = "@parameter.inner",
+ },
+ },
+
+ lsp_interop = {
+ enable = true,
+ border = "single",
+ floating_preview_opts = {},
+ peek_definition_code = {
+ ["<Leader>df"] = "@function.outer",
+ ["<Leader>dF"] = "@class.outer",
+ },
+ },
+ },
+ })
+
+ -- Crystal parser
+ local parsers = require("nvim-treesitter.parsers")
+ local parser_config = parsers.get_parser_configs()
+ parser_config.crystal = {
+ install_info = {
+ url = "~/Downloads/src/tree-sitter-crystal",
+ files = { "src/parser.c", "src/scanner.c" },
+ branch = "main",
+ },
+ filetype = "cr",
+ }
+
+ parser_config.haml = {
+ install_info = {
+ url = "https://github.com/vitallium/tree-sitter-haml",
+ files = { "src/parser.c", "src/scanner.c" },
+ branch = "main",
+ },
+ filetype = "haml",
+ }
+
+ -- Code folding
+ vim.opt.foldlevel = 99
+ vim.opt.foldlevelstart = 1
+ vim.opt.foldnestmax = 4
+ vim.opt.foldcolumn = "1"
+ vim.opt.foldenable = false
+ vim.api.nvim_create_autocmd("FileType", {
+ callback = function()
+ if parsers.has_parser() then
+ vim.opt.foldmethod = "expr"
+ vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()"
+ vim.opt.foldtext = ""
+ else
+ vim.opt.foldmethod = "indent"
+ vim.opt.foldtext = ""
+ end
+ end,
+ desc = "Set foldmethod",
+ })
+ end,
+ },
+}
diff --git a/lua/config/plugins/whichkey.lua b/lua/config/plugins/whichkey.lua
new file mode 100644
index 0000000..beff180
--- /dev/null
+++ b/lua/config/plugins/whichkey.lua
@@ -0,0 +1,13 @@
+return {
+ -- WhichKey is a lua plugin that displays a popup with possible keybindings of the command you started typing.
+ {
+ "folke/which-key.nvim",
+ event = "VeryLazy",
+ init = function()
+ vim.o.timeout = true
+ vim.o.timeoutlen = 10000
+ end,
+ opts = {
+ },
+ },
+}
diff --git a/lua/config/terminal.lua b/lua/config/terminal.lua
new file mode 100644
index 0000000..2df596e
--- /dev/null
+++ b/lua/config/terminal.lua
@@ -0,0 +1,72 @@
+-- Source: https://github.com/tjdevries/advent-of-nvim/blob/master/nvim/plugin/floaterminal.lua
+vim.keymap.set("t", "<ESC><ESC>", "<C-\\><C-n>")
+
+vim.api.nvim_create_autocmd("TermOpen", {
+ group = vim.api.nvim_create_augroup("config-term-open", { clear = true }),
+ callback = function()
+ vim.opt.number = false
+ vim.opt.relativenumber = false
+ vim.cmd("startinsert")
+ end,
+})
+
+local function create_terminal()
+ vim.cmd.vnew()
+ vim.cmd.term()
+ vim.cmd.wincmd("J")
+ vim.api.nvim_win_set_height(0, 15)
+end
+
+vim.keymap.set("n", "<Leader>T", create_terminal, { desc = "Open a terminal" })
+
+local state = {
+ floating = {
+ buf = -1,
+ win = -1,
+ },
+}
+
+local function create_floating_window(opts)
+ opts = opts or {}
+ local width = opts.width or math.floor(vim.o.columns * 0.8)
+ local height = opts.height or math.floor(vim.o.lines * 0.8)
+
+ local col = math.floor((vim.o.columns - width) / 2)
+ local row = math.floor((vim.o.lines - height) / 2)
+
+ local buf = nil
+ if vim.api.nvim_buf_is_valid(opts.buf) then
+ buf = opts.buf
+ else
+ buf = vim.api.nvim_create_buf(false, true)
+ end
+
+ local win_config = {
+ border = "double",
+ style = "minimal",
+ relative = "editor",
+ width = width,
+ height = height,
+ col = col,
+ row = row,
+ }
+
+ local win = vim.api.nvim_open_win(buf, true, win_config)
+
+ return { buf = buf, win = win }
+end
+
+vim.api.nvim_create_user_command("Floaterminal", function()
+ if not vim.api.nvim_win_is_valid(state.floating.win) then
+ state.floating = create_floating_window({ buf = state.floating.buf })
+ if vim.bo[state.floating.buf].buftype ~= "terminal" then
+ vim.cmd.term()
+ else
+ vim.cmd("startinsert")
+ end
+ else
+ vim.api.nvim_win_hide(state.floating.win)
+ end
+end, {})
+
+vim.keymap.set("n", "<Leader>t", "<CMD>Floaterminal<CR>", { desc = "Opens a floating terminal" })