From 9cee913bc45d399ad3e236368c570d0da0e9f255 Mon Sep 17 00:00:00 2001 From: Dominic DiTaranto Date: Sun, 7 Jun 2026 18:07:37 -0400 Subject: [PATCH] dealing with stupid loss of treesitter --- .config/nvim/init.lua | 15 ++- .config/nvim/lua/config/keymaps.lua | 2 +- .config/nvim/lua/config/plugins/barbar.lua | 5 +- .config/nvim/lua/config/plugins/conform.lua | 7 ++ .config/nvim/lua/config/plugins/neotree.lua | 41 ++++++++ .../{test.py => lua/config/plugins/netrw.lua} | 0 .config/nvim/lua/config/plugins/nvim-tree.lua | 32 ++++++- .../nvim/lua/config/plugins/treesitter.lua | 95 +++++++------------ .../nvim/lua/config/plugins/vim-markbar.lua | 2 + .config/nvim/lua/lsp/clangd.lua | 11 +++ .config/nvim/lua/lsp/pylsp.lua | 24 +++++ .config/nvim/nvim-pack-lock.json | 17 ++++ 12 files changed, 184 insertions(+), 67 deletions(-) create mode 100644 .config/nvim/lua/config/plugins/conform.lua create mode 100644 .config/nvim/lua/config/plugins/neotree.lua rename .config/nvim/{test.py => lua/config/plugins/netrw.lua} (100%) create mode 100644 .config/nvim/lua/config/plugins/vim-markbar.lua create mode 100644 .config/nvim/lua/lsp/clangd.lua create mode 100644 .config/nvim/lua/lsp/pylsp.lua diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 90bffb3..4264a53 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -48,7 +48,7 @@ require("config.plugins.lualine") require("config.plugins.mason") require("config.plugins.mini") require("config.plugins.nvim-lspconfig") -require("config.plugins.nvim-tree") +require("config.plugins.neotree") require("config.plugins.prettier") require("config.plugins.telescope") require("config.plugins.theme") @@ -119,3 +119,16 @@ vim.api.nvim_create_autocmd('FileType', { }) end, }) + +vim.cmd("syntax on") + +vim.api.nvim_create_autocmd("FileType", { + callback = function() + local lang = vim.treesitter.language.get_lang(vim.bo.filetype) + if lang then + pcall(vim.treesitter.start) + + vim.cmd("syntax on") + end + end, +}) diff --git a/.config/nvim/lua/config/keymaps.lua b/.config/nvim/lua/config/keymaps.lua index ccbdecf..9de7dcc 100644 --- a/.config/nvim/lua/config/keymaps.lua +++ b/.config/nvim/lua/config/keymaps.lua @@ -27,7 +27,7 @@ vim.keymap.set('n', 'T', ":belowright split | terminal | :resize 8i") vim.keymap.set('n', 'st', ':set spell!') -- toggle nvim tree -vim.keymap.set("n", "e", ":NvimTreeToggle") +vim.keymap.set("n", "e", ":Lex") -- mini pick vim.keymap.set("n", "p", ":Pick files") diff --git a/.config/nvim/lua/config/plugins/barbar.lua b/.config/nvim/lua/config/plugins/barbar.lua index c555fd3..4e70a17 100644 --- a/.config/nvim/lua/config/plugins/barbar.lua +++ b/.config/nvim/lua/config/plugins/barbar.lua @@ -3,4 +3,7 @@ vim.pack.add({ { src = "https://github.com/romgrk/barbar.nvim" }, }) -require("barbar").setup() +require("barbar").setup({ + exclude_ft = { "netrw", "qf", "terminal" }, + auto_close = true, +}) diff --git a/.config/nvim/lua/config/plugins/conform.lua b/.config/nvim/lua/config/plugins/conform.lua new file mode 100644 index 0000000..87a6287 --- /dev/null +++ b/.config/nvim/lua/config/plugins/conform.lua @@ -0,0 +1,7 @@ +vim.pack.add{"https://github.com/stevearc/conform.nvim"} + +require("conform").setup({ + formatters_by_ft = { + python = { "isort", "black" }, + }, +}) diff --git a/.config/nvim/lua/config/plugins/neotree.lua b/.config/nvim/lua/config/plugins/neotree.lua new file mode 100644 index 0000000..dd39f30 --- /dev/null +++ b/.config/nvim/lua/config/plugins/neotree.lua @@ -0,0 +1,41 @@ +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + +vim.pack.add({ + "https://github.com/nvim-lua/plenary.nvim", + "https://github.com/MunifTanjim/nui.nvim", + "https://github.com/nvim-tree/nvim-web-devicons", + { + src = "https://github.com/nvim-neo-tree/neo-tree.nvim", + version = vim.version.range("3"), + }, +}) + +require("neo-tree").setup({ + close_if_last_window = true, + popup_border_style = "rounded", + enable_git_status = true, + enable_diagnostics = true, + filesystem = { + hijack_netrw_behavior = "open_current", + follow_current_file = { enabled = true }, + use_libuv_file_watcher = true, + }, + window = { + width = 30, + mappings = { + [""] = "none", + [""] = "open", + ["o"] = "open", + ["a"] = { "add", config = { show_path = "relative" } }, + ["d"] = "delete", + ["r"] = "rename", + ["y"] = "copy_to_clipboard", + ["x"] = "cut_to_clipboard", + ["p"] = "paste_from_clipboard", + ["q"] = "close_window", + }, + }, +}) + +vim.keymap.set("n", "e", ":Neotree toggle", { desc = "Toggle Neo-tree" }) diff --git a/.config/nvim/test.py b/.config/nvim/lua/config/plugins/netrw.lua similarity index 100% rename from .config/nvim/test.py rename to .config/nvim/lua/config/plugins/netrw.lua diff --git a/.config/nvim/lua/config/plugins/nvim-tree.lua b/.config/nvim/lua/config/plugins/nvim-tree.lua index 888d02a..4da255d 100644 --- a/.config/nvim/lua/config/plugins/nvim-tree.lua +++ b/.config/nvim/lua/config/plugins/nvim-tree.lua @@ -1,3 +1,33 @@ vim.pack.add{"https://github.com/nvim-tree/nvim-tree.lua"} -require("nvim-tree").setup() +local function my_on_attach(bufnr) + local api = require("nvim-tree.api") + + local function opts(desc) + return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } + end + + -- 1. Apply default mappings first + api.config.mappings.default_on_attach(bufnr) + + -- 2. OVERRIDE Enter key to force-open and instantly flush command line blocks + vim.keymap.set("n", "", function() + -- Open the file natively + api.node.open.edit() + + -- Force-clear any hidden "Press Enter" or UI pager messages + vim.cmd("echo '' | redraw") + end, opts("Open file instantly")) +end + +require("nvim-tree").setup({ + on_attach = my_on_attach, + actions = { + open_file = { + window_picker = { + enable = false, -- Keep this off to prevent extra prompt overhead + }, + }, + }, +}) + diff --git a/.config/nvim/lua/config/plugins/treesitter.lua b/.config/nvim/lua/config/plugins/treesitter.lua index f9b05e6..5aad76a 100644 --- a/.config/nvim/lua/config/plugins/treesitter.lua +++ b/.config/nvim/lua/config/plugins/treesitter.lua @@ -1,68 +1,37 @@ vim.pack.add({ - { - src = "https://github.com/nvim-treesitter/nvim-treesitter", - branch = "main", - build = ":TSUpdate", - lazy = false, - }, - { - src = "https://github.com/nvim-treesitter/nvim-treesitter-textobjects" - } + { + src = "https://github.com/MeanderingProgrammer/render-markdown.nvim" + } }) -require("nvim-treesitter.configs").setup({ - ensure_installed = {"python"}, - indent = { enable = true }, - modules = {}, - sync_install = false, - auto_install = true, - ignore_install = {}, - highlight = { - enable = true, - additional_vim_regex_highlighting = false, - }, - 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 - ["af"] = "@function.outer", - ["if"] = "@function.inner", - ["ac"] = "@class.outer", - -- You can optionally set descriptions to the mappings (used in the desc parameter of - -- nvim_buf_set_keymap) which plugins like which-key display - ["ic"] = { query = "@class.inner", desc = "Select inner part of a class region" }, - -- You can also use captures from other query groups like `locals.scm` - ["as"] = { query = "@local.scope", query_group = "locals", desc = "Select language scope" }, - }, - -- You can choose the select mode (default is charwise 'v') - -- - -- Can also be a function which gets passed a table with the keys - -- * query_string: eg '@function.inner' - -- * method: eg 'v' or 'o' - -- and should return the mode ('v', 'V', or '') or a table - -- mapping query_strings to modes. - selection_modes = { - ['@parameter.outer'] = 'v', -- charwise - ['@function.outer'] = 'V', -- linewise - ['@class.outer'] = '', -- blockwise - }, - -- If you set this to `true` (default is `false`) then any textobject is - -- extended to include preceding or succeeding whitespace. Succeeding - -- whitespace has priority in order to act similarly to eg the built-in - -- `ap`. - -- - -- Can also be a function which gets passed a table with the keys - -- * query_string: eg '@function.inner' - -- * selection_mode: eg 'v' - -- and should return true or false - include_surrounding_whitespace = true, - }, - }, - +-- 1. Register the python parser URL and metadata +local parser_config = vim.treesitter.language.get_lang('python') or {} +vim.treesitter.language.add('python', { + url = "https://github.com", + files = { "src/parser.c", "src/scanner.c" }, -- Note: scanner.c is required for Python +}) + +-- 2. Create a clean user command to compile it manually +vim.api.nvim_create_user_command('NativeInstallPython', function() + local install_dir = vim.fn.stdpath("data") .. "/site/parser" + vim.fn.mkdir(install_dir, "p") + + -- Clone and compile natively using a temporary directory + local tmp = vim.fn.tempname() + vim.fn.system(string.format("git clone https://github.com %s", tmp)) + vim.fn.system(string.format("gcc -o %s/python.so -shared %s/src/parser.c %s/src/scanner.c -Os -fPIC -I%s/src", install_dir, tmp, tmp, tmp)) + + print("Python parser compiled successfully to " .. install_dir) +end, {}) + +vim.cmd("syntax on") + +vim.api.nvim_create_autocmd("FileType", { + callback = function() + local lang = vim.treesitter.language.get_lang(vim.bo.filetype) + if lang then + pcall(vim.treesitter.start) + end + end, }) diff --git a/.config/nvim/lua/config/plugins/vim-markbar.lua b/.config/nvim/lua/config/plugins/vim-markbar.lua new file mode 100644 index 0000000..6f61b6c --- /dev/null +++ b/.config/nvim/lua/config/plugins/vim-markbar.lua @@ -0,0 +1,2 @@ +vim.pack.add{"https://github.com/Yilin-Yang/vim-markbar"} + diff --git a/.config/nvim/lua/lsp/clangd.lua b/.config/nvim/lua/lsp/clangd.lua new file mode 100644 index 0000000..885ee55 --- /dev/null +++ b/.config/nvim/lua/lsp/clangd.lua @@ -0,0 +1,11 @@ + +return { + cmd = { + "clangd", + "--background-index", + "--clang-tidy", + "--header-insertion=never", + -- Mandatory for Arch Linux ARM toolchain + "--query-driver=/usr/bin/arm-none-eabi-*" + } +} diff --git a/.config/nvim/lua/lsp/pylsp.lua b/.config/nvim/lua/lsp/pylsp.lua new file mode 100644 index 0000000..96b6bad --- /dev/null +++ b/.config/nvim/lua/lsp/pylsp.lua @@ -0,0 +1,24 @@ +return { + capabilities = { + offsetEncoding = { "utf-16" } + }, + settings = { + pylsp = { + plugins = { + jedi_definition = { + enabled = true, + follow_imports = true, + follow_builtin_imports = true, + }, + flake8 = { + enabled = true, + maxLineLength = 100, + }, + pycodestyle = { enabled = false }, + mccabe = { enabled = false }, + pyflakes = { enabled = false }, + autopep8 = { enabled = false }, + yapf = { enabled = false }, + }, + }, + },} diff --git a/.config/nvim/nvim-pack-lock.json b/.config/nvim/nvim-pack-lock.json index dbc1e3f..e904753 100644 --- a/.config/nvim/nvim-pack-lock.json +++ b/.config/nvim/nvim-pack-lock.json @@ -40,6 +40,10 @@ "rev": "323e7633034a8068636a11597cec03bca5465c50", "src": "https://github.com/neanias/everforest-nvim.git" }, + "feed.nvim": { + "rev": "4e0903343c47b13aa5355ed267dbd58300bff8be", + "src": "https://github.com/neo451/feed.nvim" + }, "image.nvim": { "rev": "da2be65c153ba15a14a342b05591652a6df70d58", "src": "https://github.com/3rd/image.nvim" @@ -68,10 +72,19 @@ "rev": "439cdcd6992bc9012efd7d8ed7a7b7a0f1fac32a", "src": "https://github.com/nvim-mini/mini.nvim" }, + "neo-tree.nvim": { + "rev": "83e7a2982fd12b9c3d35bc39dd5877cd91a02a61", + "src": "https://github.com/nvim-neo-tree/neo-tree.nvim", + "version": "3.0.0 - 4.0.0" + }, "nightfox.nvim": { "rev": "ba47d4b4c5ec308718641ba7402c143836f35aa9", "src": "https://github.com/EdenEast/nightfox.nvim" }, + "nui.nvim": { + "rev": "de740991c12411b663994b2860f1a4fd0937c130", + "src": "https://github.com/MunifTanjim/nui.nvim" + }, "nvim-autopairs": { "rev": "59bce2eef357189c3305e25bc6dd2d138c1683f5", "src": "https://github.com/windwp/nvim-autopairs" @@ -131,6 +144,10 @@ "vim-lsp-settings": { "rev": "14f38588d8fd0eaaa0e4f3607996e5be86698aba", "src": "https://github.com/mattn/vim-lsp-settings" + }, + "vim-markbar": { + "rev": "54cd772352b4da4506ce23e971f46f78446f0b6c", + "src": "https://github.com/Yilin-Yang/vim-markbar" } } }