dealing with stupid loss of treesitter
This commit is contained in:
parent
2d601ba582
commit
9cee913bc4
12 changed files with 184 additions and 67 deletions
|
|
@ -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,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ vim.keymap.set('n', 'T', ":belowright split | terminal<CR> | :resize 8<CR>i")
|
|||
vim.keymap.set('n', '<leader>st', ':set spell!<CR>')
|
||||
|
||||
-- toggle nvim tree
|
||||
vim.keymap.set("n", "<leader>e", ":NvimTreeToggle<CR>")
|
||||
vim.keymap.set("n", "<leader>e", ":Lex<CR>")
|
||||
|
||||
-- mini pick
|
||||
vim.keymap.set("n", "<leader>p", ":Pick files<CR>")
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
})
|
||||
|
|
|
|||
7
.config/nvim/lua/config/plugins/conform.lua
Normal file
7
.config/nvim/lua/config/plugins/conform.lua
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
vim.pack.add{"https://github.com/stevearc/conform.nvim"}
|
||||
|
||||
require("conform").setup({
|
||||
formatters_by_ft = {
|
||||
python = { "isort", "black" },
|
||||
},
|
||||
})
|
||||
41
.config/nvim/lua/config/plugins/neotree.lua
Normal file
41
.config/nvim/lua/config/plugins/neotree.lua
Normal file
|
|
@ -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 = {
|
||||
["<space>"] = "none",
|
||||
["<cr>"] = "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", "<leader>e", ":Neotree toggle<CR>", { desc = "Toggle Neo-tree" })
|
||||
|
|
@ -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", "<CR>", 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
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -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 '<c-v>') or a table
|
||||
-- mapping query_strings to modes.
|
||||
selection_modes = {
|
||||
['@parameter.outer'] = 'v', -- charwise
|
||||
['@function.outer'] = 'V', -- linewise
|
||||
['@class.outer'] = '<c-v>', -- 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,
|
||||
})
|
||||
|
||||
|
|
|
|||
2
.config/nvim/lua/config/plugins/vim-markbar.lua
Normal file
2
.config/nvim/lua/config/plugins/vim-markbar.lua
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
vim.pack.add{"https://github.com/Yilin-Yang/vim-markbar"}
|
||||
|
||||
11
.config/nvim/lua/lsp/clangd.lua
Normal file
11
.config/nvim/lua/lsp/clangd.lua
Normal file
|
|
@ -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-*"
|
||||
}
|
||||
}
|
||||
24
.config/nvim/lua/lsp/pylsp.lua
Normal file
24
.config/nvim/lua/lsp/pylsp.lua
Normal file
|
|
@ -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 },
|
||||
},
|
||||
},
|
||||
},}
|
||||
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue