diff --git a/private_dot_config/nvim/init.lua b/private_dot_config/nvim/init.lua index bb438fb..9127ed3 100644 --- a/private_dot_config/nvim/init.lua +++ b/private_dot_config/nvim/init.lua @@ -12,6 +12,20 @@ vim.opt.undofile = true vim.opt.undolevels = 100000 vim.opt.undoreload = 1000000 +vim.lsp.config("lua_ls", { + settings = { + Lua = { + runtime = { version = "LuaJIT" }, + diagnostics = { globals = { "vim" } }, + workspace = { + library = vim.api.nvim_get_runtime_file("", true), + checkThirdParty = false, + }, + telemetry = { enable = false }, + }, + }, +}) + -- Loading Lazy plugin manager itself local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" local uv = vim.uv or vim.loop @@ -32,51 +46,58 @@ require("lazy").setup({ -- Gruvbox colorscheme { "ellisonleao/gruvbox.nvim", priority = 1000 }, -- Treesitter for better highlighting and moving - { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate", + { + "nvim-treesitter/nvim-treesitter", + lazy = false, + build = ":TSUpdate", config = function() - require("nvim-treesitter.configs").setup({ - ensure_installed = { - "c", "query", "vimdoc", "vim", "bash", "go", "css", - "python", "html", "javascript", "json", "jsonc", - "lua", "rust", "typescript", - }, - highlight = { enable = true }, + require("nvim-treesitter").setup() + vim.treesitter.language.register("json", "jsonc") + + vim.api.nvim_create_autocmd("FileType", { + pattern = "*", + callback = function(args) + pcall(vim.treesitter.start, args.buf) + end, }) end, }, { "nvim-telescope/telescope.nvim", dependencies = { "nvim-lua/plenary.nvim" } }, { "nvim-tree/nvim-tree.lua" }, { "jeffkreeftmeijer/vim-numbertoggle" }, - { "lukas-reineke/indent-blankline.nvim", main="ibl", opts={} }, + { "lukas-reineke/indent-blankline.nvim", main = "ibl", opts = {} }, { "phaazon/hop.nvim" }, { "echasnovski/mini.nvim", version = "*" }, { "mg979/vim-visual-multi", branch = "master" }, { "ethanholz/nvim-lastplace" }, { "kdheepak/lazygit.nvim", - -- optional for floating window border decoration dependencies = { "nvim-lua/plenary.nvim", }, }, - { "rmagatti/auto-session" }, + { "rmagatti/auto-session", lazy = false }, { "akinsho/toggleterm.nvim", version = "*", config = true }, - { "zwhitchcox/auto-session-nvim-tree" }, { "jiaoshijie/undotree" }, { "williamboman/mason.nvim", build = function() pcall(vim.cmd, "MasonUpdate") end, + opts = { + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗", + }, + }, + }, }, { "folke/which-key.nvim", config = function() vim.o.timeout = true vim.o.timeoutlen = 300 - require("which-key").setup({ - -- your configuration comes here - -- or leave it empty to use the default settings - -- refer to the configuration section below - }) + require("which-key").setup({}) end, }, { @@ -84,30 +105,39 @@ require("lazy").setup({ keys = { "m", "j", "s" }, dependencies = { "nvim-treesitter/nvim-treesitter" }, config = function() - require("treesj").setup({--[[ your config ]] - }) - end, -}, -{ "williamboman/mason-lspconfig.nvim" }, -{ "neovim/nvim-lspconfig" }, + require("treesj").setup({}) + end, + }, + { + "williamboman/mason-lspconfig.nvim", + dependencies = { + "williamboman/mason.nvim", + "neovim/nvim-lspconfig", + }, + opts = { + ensure_installed = { "lua_ls", "rust_analyzer" }, + automatic_enable = true, + }, + }, + { "neovim/nvim-lspconfig" }, }) -require('undotree').setup({ - float_diff = false, -- using float window previews diff, set this `true` will disable layout option - layout = "left_left_bottom", -- "left_bottom", "left_left_bottom" - ignore_filetype = { 'undotree', 'undotreeDiff', 'qf', 'TelescopePrompt', 'spectre_panel', 'tsplayground' }, - window = { - winblend = 0, - }, - keymaps = { - ['j'] = "move_next", - ['k'] = "move_prev", - ['J'] = "move_change_next", - ['K'] = "move_change_prev", - [''] = "action_enter", - ['p'] = "enter_diffbuf", - ['q'] = "quit", - }, +require("undotree").setup({ + float_diff = false, + layout = "left_left_bottom", + ignore_filetype = { "undotree", "undotreeDiff", "qf", "TelescopePrompt", "spectre_panel", "tsplayground" }, + window = { + winblend = 0, + }, + keymaps = { + ["j"] = "move_next", + ["k"] = "move_prev", + ["J"] = "move_change_next", + ["K"] = "move_change_prev", + [""] = "action_enter", + ["p"] = "enter_diffbuf", + ["q"] = "quit", + }, }) vim.cmd([[colorscheme gruvbox]]) @@ -117,7 +147,6 @@ require("nvim-lastplace").setup({ lastplace_open_folds = true, }) - require("hop").setup() require("mini.ai").setup() require("mini.pairs").setup() @@ -130,36 +159,6 @@ require("mini.surround").setup() require("mini.cursorword").setup() -- require("mini.completion").setup() - -require("mason").setup({ - ui = { - icons = { - package_installed = "✓", - package_pending = "➜", - package_uninstalled = "✗", - }, - }, -}) - -require("mason-lspconfig").setup({ - ensure_installed = { "lua_ls", "rust_analyzer" }, - automatic_enable = true, -}) - -vim.lsp.config("lua_ls", { - settings = { - Lua = { - runtime = { version = "LuaJIT" }, - diagnostics = { globals = { "vim" } }, - workspace = { - library = vim.api.nvim_get_runtime_file("", true), - checkThirdParty = false, - }, - telemetry = { enable = false }, - }, - }, -}) - vim.g.clipboard = { name = "OSC 52", copy = { @@ -177,23 +176,29 @@ local hop = require("hop") vim.keymap.set("n", "s", function() hop.hint_words() end, { remap = true }) - local builtin = require("telescope.builtin") vim.keymap.set("n", "fg", builtin.live_grep, {}) vim.keymap.set("n", "fb", builtin.buffers, {}) vim.keymap.set("n", "fh", builtin.help_tags, {}) ---- set termguicolors to enable highlight groups vim.opt.termguicolors = true require("nvim-tree").setup({ sort = { sorter = "name", }, + sync_root_with_cwd = true, + respect_buf_cwd = true, view = { width = 22, }, + actions = { + change_dir = { + enable = true, + global = true, + }, + }, renderer = { group_empty = true, }, @@ -207,7 +212,7 @@ vim.api.nvim_set_keymap("n", "t", ":ToggleTerm", { noremap = true, s vim.api.nvim_set_keymap("n", "q", ":qa", { noremap = true, silent = true }) vim.api.nvim_set_keymap("n", "w", ":w", { noremap = true, silent = true }) -- vim.keymap.set("n", "u", vim.cmd.UndotreeToggle) -vim.keymap.set('n', 'u', require('undotree').toggle, { noremap = true, silent = true }) +vim.keymap.set("n", "u", require("undotree").toggle, { noremap = true, silent = true }) vim.o.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions" @@ -215,18 +220,16 @@ local auto_session = require("auto-session") auto_session.setup({ log_level = "error", - auto_session_root_dir = vim.fn.stdpath("data") .. "/sessions/", - auto_session_enabled = true, - auto_save_enabled = true, - auto_restore_enabled = true, - auto_session_suppress_dirs = { "~/", "~/dev", "~/Downloads", "/" }, - auto_session_use_git_branch = nil, + root_dir = vim.fn.stdpath("data") .. "/sessions/", + enabled = true, + auto_save = true, + auto_restore = true, + suppressed_dirs = { "~/", "~/dev", "~/Downloads", "/" }, + git_use_branch_name = false, cwd_change_handling = { - restore_upcoming_session = true, -- This is necessary!! + restore_upcoming_session = true, }, }) --- require("auto-session-nvim-tree").setup(auto_session) - vim.cmd([[highlight IndentBlanklineIndent1 guifg=#443838 gui=nocombine]]) @@ -266,4 +269,3 @@ vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, { pattern = "*.tmpl", command = "set syntax=python", }) - diff --git a/private_dot_config/scripts/executable_install-treesitter-parsers.sh b/private_dot_config/scripts/executable_install-treesitter-parsers.sh new file mode 100644 index 0000000..3749b62 --- /dev/null +++ b/private_dot_config/scripts/executable_install-treesitter-parsers.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +set -euo pipefail + +if ! command -v nvim >/dev/null 2>&1; then + echo "nvim is required" >&2 + exit 1 +fi + +if ! command -v tree-sitter >/dev/null 2>&1; then + echo "tree-sitter CLI is required for nvim-treesitter main-branch parser installs" >&2 + exit 1 +fi + +if ! command -v curl >/dev/null 2>&1; then + echo "curl is required" >&2 + exit 1 +fi + +if ! command -v tar >/dev/null 2>&1; then + echo "tar is required" >&2 + exit 1 +fi + +INSTALL_EXPR="require('nvim-treesitter').install({'c','query','vimdoc','vim','bash','go','css','python','html','javascript','json','lua','rust','typescript'}):wait(300000)" + +XDG_STATE_HOME="${XDG_STATE_HOME:-/tmp/nvim-state-bootstrap}" \ + nvim --headless \ + "+lua ${INSTALL_EXPR}" \ + "+qa" diff --git a/run_onchange_after_install_main_deps.sh.tmpl b/run_onchange_after_install_main_deps.sh.tmpl index 1b5b3d2..2e26118 100644 --- a/run_onchange_after_install_main_deps.sh.tmpl +++ b/run_onchange_after_install_main_deps.sh.tmpl @@ -401,7 +401,7 @@ $SUDO pkg install --yes $ACT_PACKAGES neovim fish atuin lazygit fd-find pam_ssh_ $SUDO pkg_add -v neovim fish%main fd ripgrep unzip-- htop fzf bat gawk jq nnn-- mc ngrep mtr-- gcc%11 2>&1|pad {{ else if eq .chezmoi.os "darwin" -}} - brew install -q fish neovim $ACT_PACKAGES atuin jump fd sk dust lazygit 2>&1|pad + brew install -q fish neovim $ACT_PACKAGES atuin jump fd sk dust lazygit tree-sitter-cli 2>&1|pad {{ else if eq .chezmoi.osRelease.id "fedora" -}} PAM_SSH_PKG="" @@ -462,6 +462,7 @@ nvim_run 5 -c ":lua pcall(vim.cmd, 'MasonUpdate')" nvim_run 5 -c ":lua pcall(vim.cmd, 'MasonInstall lua-language-server')" nvim_run 5 -c ":lua pcall(vim.cmd, 'MasonInstall rust-analyzer')" nvim_run 5 -c ":TSUpdate" +~/.config/scripts/install-treesitter-parsers.sh 2>&1 | pad fi {{ if eq .chezmoi.os "linux" -}} @@ -495,4 +496,3 @@ if [ "$NON_INTERACTIVE" -eq 0 ]; then tput cup $LINES 0 fi echo -