aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--init.lua5
-rw-r--r--lazy-lock.json31
-rw-r--r--lua/simenandre/init.lua7
-rw-r--r--lua/simenandre/plugins/dap.lua2
-rw-r--r--lua/simenandre/plugins/harpoon.lua4
-rw-r--r--lua/simenandre/plugins/lsp.lua2
-rw-r--r--lua/simenandre/plugins/mini.lua2
-rw-r--r--lua/simenandre/plugins/telescope.lua2
-rw-r--r--lua/simenandre/plugins/treesitter.lua100
-rw-r--r--lua/simenandre/remap.lua11
10 files changed, 71 insertions, 95 deletions
diff --git a/init.lua b/init.lua
index 1b69e28..5d704ff 100644
--- a/init.lua
+++ b/init.lua
@@ -8,8 +8,11 @@ end ---@diagnostic disable-next-line: undefined-field
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
- { import = "simenandre.plugins", rocks = { enabled = false } },
+ { import = "simenandre.plugins" },
}, {
+ -- ~/.config/nvim is a read-only nix store path
+ lockfile = vim.fn.stdpath("state") .. "/lazy-lock.json",
+ rocks = { enabled = false },
ui = {
-- If you are using a Nerd Font: set icons to an empty table which will use the
-- default lazy.nvim defined Nerd Font icons, otherwise define a unicode icons table
diff --git a/lazy-lock.json b/lazy-lock.json
deleted file mode 100644
index 7f22452..0000000
--- a/lazy-lock.json
+++ /dev/null
@@ -1,31 +0,0 @@
-{
- "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
- "blink.cmp": { "branch": "main", "commit": "5f442681df24fe705d1ee7ce5b4d435aa4b4dee4" },
- "conform.nvim": { "branch": "master", "commit": "1a99fdc1d3aa9ccdf3021e67982a679a8c5c740c" },
- "copilot.vim": { "branch": "release", "commit": "782461159655b259cff10ecff05efa761e3d4764" },
- "fidget.nvim": { "branch": "main", "commit": "d855eed8a06531a7e8fd0684889b2943f373c469" },
- "friendly-snippets": { "branch": "main", "commit": "ea068f1becd91bcd4591fceb6420d4335e2e14d3" },
- "gitsigns.nvim": { "branch": "main", "commit": "1ef74b546732f185d0f806860fa5404df7614f28" },
- "grug-far.nvim": { "branch": "main", "commit": "f47594f05d10b0bedfc0ed78e488e7fd714d57be" },
- "harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" },
- "lazy.nvim": { "branch": "main", "commit": "48b52b5cfcf8f88ed0aff8fde573a5cc20b1306d" },
- "lazydev.nvim": { "branch": "main", "commit": "d5800897d9180cea800023f2429bce0a94ed6064" },
- "mason-lspconfig.nvim": { "branch": "main", "commit": "25c11854aa25558ee6c03432edfa0df0217324be" },
- "mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" },
- "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
- "mini.nvim": { "branch": "main", "commit": "e50cf9de614500a20e47cfc50e30a100042f91c3" },
- "nvim-dap": { "branch": "master", "commit": "90616ae6ae40053103dc66872886fc26b94c70c8" },
- "nvim-dap-go": { "branch": "main", "commit": "5511788255c92bdd845f8d9690f88e2e0f0ff9f2" },
- "nvim-lspconfig": { "branch": "master", "commit": "46ce5fd8c081f179a509da423077f8372e63ffc4" },
- "nvim-treesitter": { "branch": "master", "commit": "b7160e87aadbb3f5f6ee87ce139406fe3433044e" },
- "plenary.nvim": { "branch": "master", "commit": "ec289423a1693aeae6cd0d503bac2856af74edaa" },
- "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" },
- "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" },
- "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
- "todo-comments.nvim": { "branch": "main", "commit": "319c01b99b7a8c9ac2066bf0efd4d6ec68fef444" },
- "tokyonight.nvim": { "branch": "main", "commit": "4b386e66a9599057587c30538d5e6192e3d1c181" },
- "trouble.nvim": { "branch": "main", "commit": "254145ffd528b98eb20be894338e2d5c93fa02c2" },
- "vim-sleuth": { "branch": "master", "commit": "cd9d382e33bb817abe7f10cdc3a606bf1d491d75" },
- "vim-tmux-navigator": { "branch": "master", "commit": "a9b52e7d36114d40350099f254b5f299a35df978" },
- "which-key.nvim": { "branch": "main", "commit": "bfec3d6bc0a9b0b2cb11644642f78c2c3915eef0" }
-}
diff --git a/lua/simenandre/init.lua b/lua/simenandre/init.lua
index 3d28d3b..a8da17f 100644
--- a/lua/simenandre/init.lua
+++ b/lua/simenandre/init.lua
@@ -3,21 +3,20 @@ require("simenandre.remap")
-- Highlight when yanking (copying) text
-- Try it with `yap` in normal mode
--- See `:help vim.highlight.on_yank()`
+-- See `:help vim.hl.on_yank()`
vim.api.nvim_create_autocmd("TextYankPost", {
desc = "Highlight when yanking (copying) text",
group = vim.api.nvim_create_augroup("kickstart-highlight-yank", { clear = true }),
callback = function()
- vim.highlight.on_yank()
+ vim.hl.on_yank()
end,
})
-function open_daily_note()
+local function open_daily_note()
local date = os.date("%Y-%m-%d")
local notes_dir = vim.fs.joinpath(vim.env.HOME, "ghq/github.com/simenandre/notes")
local file_path = vim.fs.joinpath(notes_dir, date .. ".md")
vim.cmd("edit " .. file_path)
end
--- Map the function to <leader>dn (for "daily note")
vim.keymap.set("n", "<leader>da", open_daily_note, { noremap = true, silent = true, desc = "Open daily note" })
diff --git a/lua/simenandre/plugins/dap.lua b/lua/simenandre/plugins/dap.lua
index 686e535..642e645 100644
--- a/lua/simenandre/plugins/dap.lua
+++ b/lua/simenandre/plugins/dap.lua
@@ -1,4 +1,4 @@
return {
"mfussenegger/nvim-dap",
- "leoluz/nvim-dap-go",
+ { "leoluz/nvim-dap-go", dependencies = { "mfussenegger/nvim-dap" }, opts = {} },
}
diff --git a/lua/simenandre/plugins/harpoon.lua b/lua/simenandre/plugins/harpoon.lua
index ee2dfdb..248962c 100644
--- a/lua/simenandre/plugins/harpoon.lua
+++ b/lua/simenandre/plugins/harpoon.lua
@@ -1,9 +1,7 @@
return {
"ThePrimeagen/harpoon",
branch = "harpoon2",
- requires = {
- { "nvim-lua/plenary.nvim" },
- },
+ dependencies = { "nvim-lua/plenary.nvim" },
config = function()
local harpoon = require("harpoon")
harpoon:setup()
diff --git a/lua/simenandre/plugins/lsp.lua b/lua/simenandre/plugins/lsp.lua
index 4161489..91626b8 100644
--- a/lua/simenandre/plugins/lsp.lua
+++ b/lua/simenandre/plugins/lsp.lua
@@ -5,7 +5,7 @@ return {
ft = "lua",
opts = {
library = {
- { path = "luvit-meta/library", words = { "vim%.uv" } },
+ { path = "${3rd}/luv/library", words = { "vim%.uv" } },
},
},
},
diff --git a/lua/simenandre/plugins/mini.lua b/lua/simenandre/plugins/mini.lua
index de7156b..aa51e9d 100644
--- a/lua/simenandre/plugins/mini.lua
+++ b/lua/simenandre/plugins/mini.lua
@@ -1,6 +1,6 @@
return {
{ -- Collection of various small independent plugins/modules
- "echasnovski/mini.nvim",
+ "nvim-mini/mini.nvim",
config = function()
-- Better Around/Inside textobjects
--
diff --git a/lua/simenandre/plugins/telescope.lua b/lua/simenandre/plugins/telescope.lua
index 602cac1..4c27d78 100644
--- a/lua/simenandre/plugins/telescope.lua
+++ b/lua/simenandre/plugins/telescope.lua
@@ -81,8 +81,6 @@ return {
vim.keymap.set("n", "<leader>sf", builtin.find_files, { desc = "[S]earch [F]iles" })
vim.keymap.set("n", "<leader>ss", builtin.builtin, { desc = "[S]earch [S]elect Telescope" })
- vim.keymap.set("n", "<leader>st", builtin.treesitter, { desc = "[S]earch [T]reesitter" })
-
vim.keymap.set("n", "<leader>sw", builtin.grep_string, { desc = "[S]earch current [W]ord" })
vim.keymap.set("n", "<leader>sg", builtin.live_grep, { desc = "[S]earch by [G]rep" })
vim.keymap.set("n", "<leader>sd", builtin.diagnostics, { desc = "[S]earch [D]iagnostics" })
diff --git a/lua/simenandre/plugins/treesitter.lua b/lua/simenandre/plugins/treesitter.lua
index 77f617d..1eb9080 100644
--- a/lua/simenandre/plugins/treesitter.lua
+++ b/lua/simenandre/plugins/treesitter.lua
@@ -1,48 +1,66 @@
+local ensure_installed = {
+ "astro",
+ "bash",
+ "c",
+ "css",
+ "diff",
+ "gitcommit",
+ "gitignore",
+ "go",
+ "html",
+ "javascript",
+ "json",
+ "lua",
+ "luadoc",
+ "markdown",
+ "markdown_inline",
+ "nix",
+ "query",
+ "rust",
+ "ssh_config",
+ "toml",
+ "tsx",
+ "typescript",
+ "vim",
+ "vimdoc",
+ "yaml",
+ "zig",
+}
+
+local function start(buf, lang)
+ if not pcall(vim.treesitter.start, buf, lang) then
+ return
+ end
+ vim.bo[buf].indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
+end
+
return {
- { -- Highlight, edit, and navigate code
+ { -- Parsers and queries; highlighting itself is native (vim.treesitter.start)
"nvim-treesitter/nvim-treesitter",
+ branch = "main",
+ lazy = false,
build = ":TSUpdate",
- main = "nvim-treesitter.configs", -- Sets main module to use for opts
- -- [[ Configure Treesitter ]] See `:help nvim-treesitter`
config = function()
- require("nvim-treesitter.configs").setup({
- ensure_installed = {
- "bash",
- "ssh_config",
- "c",
- "diff",
- "html",
- "css",
- "gitcommit",
- "gitignore",
- "lua",
- "luadoc",
- "go",
- "json",
- "javascript",
- "rust",
- "zig",
- "yaml",
- "toml",
- "tsx",
- "typescript",
- "markdown",
- "markdown_inline",
- "query",
- "vim",
- "vimdoc",
- "astro",
- },
- -- Autoinstall languages that are not installed
- auto_install = true,
- highlight = {
- enable = true,
- -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules.
- -- If you are experiencing weird indenting issues, add the language to
- -- the list of additional_vim_regex_highlighting and disabled languages for indent.
- additional_vim_regex_highlighting = { "ruby" },
- },
- indent = { enable = true, disable = { "ruby" } },
+ local ts = require("nvim-treesitter")
+ ts.install(ensure_installed)
+
+ vim.api.nvim_create_autocmd("FileType", {
+ group = vim.api.nvim_create_augroup("treesitter-start", { clear = true }),
+ callback = function(args)
+ local lang = vim.treesitter.language.get_lang(args.match)
+ if not lang then
+ return
+ end
+ if vim.list_contains(ts.get_installed(), lang) then
+ start(args.buf, lang)
+ elseif vim.list_contains(ts.get_available(), lang) then
+ ts.install(lang):await(vim.schedule_wrap(function()
+ if vim.api.nvim_buf_is_valid(args.buf) then
+ start(args.buf, lang)
+ end
+ end))
+ end
+ end,
})
end,
},
diff --git a/lua/simenandre/remap.lua b/lua/simenandre/remap.lua
index ce91aa3..2c66c58 100644
--- a/lua/simenandre/remap.lua
+++ b/lua/simenandre/remap.lua
@@ -1,7 +1,6 @@
-- See `:help vim.keymap.set()`
vim.keymap.set("i", "<C-c>", "<Esc>")
-vim.keymap.set("n", "<leader>f", vim.lsp.buf.format)
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
@@ -13,19 +12,11 @@ vim.keymap.set("n", "<C-u>", "<C-u>zz")
vim.opt.hlsearch = true
vim.keymap.set("n", "<Esc>", "<cmd>nohlsearch<CR>")
--- Diagnostic keymaps
-vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, { desc = "Go to previous [D]iagnostic message" })
-vim.keymap.set("n", "]d", vim.diagnostic.goto_next, { desc = "Go to next [D]iagnostic message" })
+-- Diagnostic keymaps ([d and ]d are Neovim defaults)
vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float, { desc = "Show diagnostic [E]rror messages" })
vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist, { desc = "Open diagnostic [Q]uickfix list" })
-- Exit terminal mode
vim.keymap.set("t", "<Esc><Esc>", "<C-\\><C-n>", { desc = "Exit terminal mode" })
--- Keybinds to make split navigation easier.
-vim.keymap.set("n", "<C-h>", "<C-w><C-h>", { desc = "Move focus to the left window" })
-vim.keymap.set("n", "<C-l>", "<C-w><C-l>", { desc = "Move focus to the right window" })
-vim.keymap.set("n", "<C-j>", "<C-w><C-j>", { desc = "Move focus to the lower window" })
-vim.keymap.set("n", "<C-k>", "<C-w><C-k>", { desc = "Move focus to the upper window" })
-
vim.keymap.set("n", "<leader>pv", vim.cmd.Ex)