Modernize Neovim treesitter bootstrap
This commit is contained in:
parent
fe659f4386
commit
556f26441e
@ -12,6 +12,20 @@ vim.opt.undofile = true
|
|||||||
vim.opt.undolevels = 100000
|
vim.opt.undolevels = 100000
|
||||||
vim.opt.undoreload = 1000000
|
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
|
-- Loading Lazy plugin manager itself
|
||||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||||
local uv = vim.uv or vim.loop
|
local uv = vim.uv or vim.loop
|
||||||
@ -32,15 +46,19 @@ require("lazy").setup({
|
|||||||
-- Gruvbox colorscheme
|
-- Gruvbox colorscheme
|
||||||
{ "ellisonleao/gruvbox.nvim", priority = 1000 },
|
{ "ellisonleao/gruvbox.nvim", priority = 1000 },
|
||||||
-- Treesitter for better highlighting and moving
|
-- Treesitter for better highlighting and moving
|
||||||
{ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate",
|
{
|
||||||
|
"nvim-treesitter/nvim-treesitter",
|
||||||
|
lazy = false,
|
||||||
|
build = ":TSUpdate",
|
||||||
config = function()
|
config = function()
|
||||||
require("nvim-treesitter.configs").setup({
|
require("nvim-treesitter").setup()
|
||||||
ensure_installed = {
|
vim.treesitter.language.register("json", "jsonc")
|
||||||
"c", "query", "vimdoc", "vim", "bash", "go", "css",
|
|
||||||
"python", "html", "javascript", "json", "jsonc",
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
"lua", "rust", "typescript",
|
pattern = "*",
|
||||||
},
|
callback = function(args)
|
||||||
highlight = { enable = true },
|
pcall(vim.treesitter.start, args.buf)
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
@ -54,29 +72,32 @@ require("lazy").setup({
|
|||||||
{ "ethanholz/nvim-lastplace" },
|
{ "ethanholz/nvim-lastplace" },
|
||||||
{
|
{
|
||||||
"kdheepak/lazygit.nvim",
|
"kdheepak/lazygit.nvim",
|
||||||
-- optional for floating window border decoration
|
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"nvim-lua/plenary.nvim",
|
"nvim-lua/plenary.nvim",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ "rmagatti/auto-session" },
|
{ "rmagatti/auto-session", lazy = false },
|
||||||
{ "akinsho/toggleterm.nvim", version = "*", config = true },
|
{ "akinsho/toggleterm.nvim", version = "*", config = true },
|
||||||
{ "zwhitchcox/auto-session-nvim-tree" },
|
|
||||||
{ "jiaoshijie/undotree" },
|
{ "jiaoshijie/undotree" },
|
||||||
{
|
{
|
||||||
"williamboman/mason.nvim",
|
"williamboman/mason.nvim",
|
||||||
build = function() pcall(vim.cmd, "MasonUpdate") end,
|
build = function() pcall(vim.cmd, "MasonUpdate") end,
|
||||||
|
opts = {
|
||||||
|
ui = {
|
||||||
|
icons = {
|
||||||
|
package_installed = "✓",
|
||||||
|
package_pending = "➜",
|
||||||
|
package_uninstalled = "✗",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"folke/which-key.nvim",
|
"folke/which-key.nvim",
|
||||||
config = function()
|
config = function()
|
||||||
vim.o.timeout = true
|
vim.o.timeout = true
|
||||||
vim.o.timeoutlen = 300
|
vim.o.timeoutlen = 300
|
||||||
require("which-key").setup({
|
require("which-key").setup({})
|
||||||
-- your configuration comes here
|
|
||||||
-- or leave it empty to use the default settings
|
|
||||||
-- refer to the configuration section below
|
|
||||||
})
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -84,29 +105,38 @@ require("lazy").setup({
|
|||||||
keys = { "<space>m", "<space>j", "<space>s" },
|
keys = { "<space>m", "<space>j", "<space>s" },
|
||||||
dependencies = { "nvim-treesitter/nvim-treesitter" },
|
dependencies = { "nvim-treesitter/nvim-treesitter" },
|
||||||
config = function()
|
config = function()
|
||||||
require("treesj").setup({--[[ your config ]]
|
require("treesj").setup({})
|
||||||
})
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
{ "williamboman/mason-lspconfig.nvim" },
|
{
|
||||||
|
"williamboman/mason-lspconfig.nvim",
|
||||||
|
dependencies = {
|
||||||
|
"williamboman/mason.nvim",
|
||||||
|
"neovim/nvim-lspconfig",
|
||||||
|
},
|
||||||
|
opts = {
|
||||||
|
ensure_installed = { "lua_ls", "rust_analyzer" },
|
||||||
|
automatic_enable = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
{ "neovim/nvim-lspconfig" },
|
{ "neovim/nvim-lspconfig" },
|
||||||
})
|
})
|
||||||
|
|
||||||
require('undotree').setup({
|
require("undotree").setup({
|
||||||
float_diff = false, -- using float window previews diff, set this `true` will disable layout option
|
float_diff = false,
|
||||||
layout = "left_left_bottom", -- "left_bottom", "left_left_bottom"
|
layout = "left_left_bottom",
|
||||||
ignore_filetype = { 'undotree', 'undotreeDiff', 'qf', 'TelescopePrompt', 'spectre_panel', 'tsplayground' },
|
ignore_filetype = { "undotree", "undotreeDiff", "qf", "TelescopePrompt", "spectre_panel", "tsplayground" },
|
||||||
window = {
|
window = {
|
||||||
winblend = 0,
|
winblend = 0,
|
||||||
},
|
},
|
||||||
keymaps = {
|
keymaps = {
|
||||||
['j'] = "move_next",
|
["j"] = "move_next",
|
||||||
['k'] = "move_prev",
|
["k"] = "move_prev",
|
||||||
['J'] = "move_change_next",
|
["J"] = "move_change_next",
|
||||||
['K'] = "move_change_prev",
|
["K"] = "move_change_prev",
|
||||||
['<cr>'] = "action_enter",
|
["<cr>"] = "action_enter",
|
||||||
['p'] = "enter_diffbuf",
|
["p"] = "enter_diffbuf",
|
||||||
['q'] = "quit",
|
["q"] = "quit",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -117,7 +147,6 @@ require("nvim-lastplace").setup({
|
|||||||
lastplace_open_folds = true,
|
lastplace_open_folds = true,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
require("hop").setup()
|
require("hop").setup()
|
||||||
require("mini.ai").setup()
|
require("mini.ai").setup()
|
||||||
require("mini.pairs").setup()
|
require("mini.pairs").setup()
|
||||||
@ -130,36 +159,6 @@ require("mini.surround").setup()
|
|||||||
require("mini.cursorword").setup()
|
require("mini.cursorword").setup()
|
||||||
-- require("mini.completion").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 = {
|
vim.g.clipboard = {
|
||||||
name = "OSC 52",
|
name = "OSC 52",
|
||||||
copy = {
|
copy = {
|
||||||
@ -177,23 +176,29 @@ local hop = require("hop")
|
|||||||
|
|
||||||
vim.keymap.set("n", "<leader>s", function() hop.hint_words() end, { remap = true })
|
vim.keymap.set("n", "<leader>s", function() hop.hint_words() end, { remap = true })
|
||||||
|
|
||||||
|
|
||||||
local builtin = require("telescope.builtin")
|
local builtin = require("telescope.builtin")
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>fg", builtin.live_grep, {})
|
vim.keymap.set("n", "<leader>fg", builtin.live_grep, {})
|
||||||
vim.keymap.set("n", "<leader>fb", builtin.buffers, {})
|
vim.keymap.set("n", "<leader>fb", builtin.buffers, {})
|
||||||
vim.keymap.set("n", "<leader>fh", builtin.help_tags, {})
|
vim.keymap.set("n", "<leader>fh", builtin.help_tags, {})
|
||||||
|
|
||||||
--- set termguicolors to enable highlight groups
|
|
||||||
vim.opt.termguicolors = true
|
vim.opt.termguicolors = true
|
||||||
|
|
||||||
require("nvim-tree").setup({
|
require("nvim-tree").setup({
|
||||||
sort = {
|
sort = {
|
||||||
sorter = "name",
|
sorter = "name",
|
||||||
},
|
},
|
||||||
|
sync_root_with_cwd = true,
|
||||||
|
respect_buf_cwd = true,
|
||||||
view = {
|
view = {
|
||||||
width = 22,
|
width = 22,
|
||||||
},
|
},
|
||||||
|
actions = {
|
||||||
|
change_dir = {
|
||||||
|
enable = true,
|
||||||
|
global = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
renderer = {
|
renderer = {
|
||||||
group_empty = true,
|
group_empty = true,
|
||||||
},
|
},
|
||||||
@ -207,7 +212,7 @@ vim.api.nvim_set_keymap("n", "<leader>t", ":ToggleTerm<CR>", { noremap = true, s
|
|||||||
vim.api.nvim_set_keymap("n", "<leader>q", ":qa<CR>", { noremap = true, silent = true })
|
vim.api.nvim_set_keymap("n", "<leader>q", ":qa<CR>", { noremap = true, silent = true })
|
||||||
vim.api.nvim_set_keymap("n", "<leader>w", ":w<CR>", { noremap = true, silent = true })
|
vim.api.nvim_set_keymap("n", "<leader>w", ":w<CR>", { noremap = true, silent = true })
|
||||||
-- vim.keymap.set("n", "<leader>u", vim.cmd.UndotreeToggle)
|
-- vim.keymap.set("n", "<leader>u", vim.cmd.UndotreeToggle)
|
||||||
vim.keymap.set('n', '<leader>u', require('undotree').toggle, { noremap = true, silent = true })
|
vim.keymap.set("n", "<leader>u", require("undotree").toggle, { noremap = true, silent = true })
|
||||||
|
|
||||||
vim.o.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions"
|
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({
|
auto_session.setup({
|
||||||
log_level = "error",
|
log_level = "error",
|
||||||
auto_session_root_dir = vim.fn.stdpath("data") .. "/sessions/",
|
root_dir = vim.fn.stdpath("data") .. "/sessions/",
|
||||||
auto_session_enabled = true,
|
enabled = true,
|
||||||
auto_save_enabled = true,
|
auto_save = true,
|
||||||
auto_restore_enabled = true,
|
auto_restore = true,
|
||||||
auto_session_suppress_dirs = { "~/", "~/dev", "~/Downloads", "/" },
|
suppressed_dirs = { "~/", "~/dev", "~/Downloads", "/" },
|
||||||
auto_session_use_git_branch = nil,
|
git_use_branch_name = false,
|
||||||
cwd_change_handling = {
|
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]])
|
vim.cmd([[highlight IndentBlanklineIndent1 guifg=#443838 gui=nocombine]])
|
||||||
|
|
||||||
@ -266,4 +269,3 @@ vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, {
|
|||||||
pattern = "*.tmpl",
|
pattern = "*.tmpl",
|
||||||
command = "set syntax=python",
|
command = "set syntax=python",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -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"
|
||||||
@ -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
|
$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" -}}
|
{{ 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" -}}
|
{{ else if eq .chezmoi.osRelease.id "fedora" -}}
|
||||||
PAM_SSH_PKG=""
|
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 lua-language-server')"
|
||||||
nvim_run 5 -c ":lua pcall(vim.cmd, 'MasonInstall rust-analyzer')"
|
nvim_run 5 -c ":lua pcall(vim.cmd, 'MasonInstall rust-analyzer')"
|
||||||
nvim_run 5 -c ":TSUpdate"
|
nvim_run 5 -c ":TSUpdate"
|
||||||
|
~/.config/scripts/install-treesitter-parsers.sh 2>&1 | pad
|
||||||
fi
|
fi
|
||||||
|
|
||||||
{{ if eq .chezmoi.os "linux" -}}
|
{{ if eq .chezmoi.os "linux" -}}
|
||||||
@ -495,4 +496,3 @@ if [ "$NON_INTERACTIVE" -eq 0 ]; then
|
|||||||
tput cup $LINES 0
|
tput cup $LINES 0
|
||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user