(nvim) nvim v0.12 migration
This commit is contained in:
parent
f0db0ada98
commit
7b2eb8c525
51 changed files with 1629 additions and 1627 deletions
|
|
@ -1,80 +0,0 @@
|
|||
{
|
||||
"workspace.library": [
|
||||
"/home/jc/.local/share/nvim/lazy/neodev.nvim/types/stable",
|
||||
"/home/jc/Applications/nvim-linux64/share/nvim/runtime/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/neodev.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/telescope.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/telescope-fzf-native.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/which-key.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/gitsigns.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/lsp-zero.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/nvim-dap-ui/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/todo-comments.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/nvim-lspconfig/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/lazy.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/mason.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/fzf-lua/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/nvim-treesitter-textobjects/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/mason-lspconfig.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/telescope-dap.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/nvim-web-devicons/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/telescope-file-browser.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/nvim-cmp/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/lualine.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/nvim-treesitter/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/nvim-ts-autotag/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/nvim-ts-context-commentstring/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/git.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/nvim-autopairs/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/Comment.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/rose-pine/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/indent-blankline.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/harpoon/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/LuaSnip/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/nvim-dap/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/cmp-nvim-lsp/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/plenary.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/null-ls.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/neodev.nvim/types/stable",
|
||||
"/home/jc/Applications/nvim-linux64/share/nvim/runtime/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/neodev.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/telescope.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/telescope-fzf-native.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/which-key.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/gitsigns.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/lsp-zero.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/nvim-dap-ui/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/todo-comments.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/nvim-lspconfig/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/lazy.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/mason.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/fzf-lua/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/nvim-treesitter-textobjects/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/mason-lspconfig.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/telescope-dap.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/nvim-web-devicons/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/telescope-file-browser.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/nvim-cmp/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/lualine.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/nvim-treesitter/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/nvim-ts-autotag/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/nvim-ts-context-commentstring/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/git.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/nvim-autopairs/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/Comment.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/rose-pine/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/indent-blankline.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/harpoon/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/LuaSnip/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/nvim-dap/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/cmp-nvim-lsp/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/plenary.nvim/lua",
|
||||
"/home/jc/.local/share/nvim/lazy/null-ls.nvim/lua",
|
||||
"/home/jc/ghq/juancwu/dotfiles/nvim/lua",
|
||||
"/home/jc/ghq/juancwu/dotfiles/nvim/lua",
|
||||
"${3rd}/luv/library"
|
||||
],
|
||||
"diagnostics.globals": [
|
||||
"vim"
|
||||
]
|
||||
}
|
||||
29
nvim/lua/autocmds.lua
Normal file
29
nvim/lua/autocmds.lua
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
-- highlight on yank
|
||||
local highligh_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true })
|
||||
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||
callback = function()
|
||||
vim.highlight.on_yank()
|
||||
end,
|
||||
group = highligh_group,
|
||||
pattern = "*",
|
||||
})
|
||||
|
||||
-- disable indent group on some file types
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = {
|
||||
"help",
|
||||
"alpha",
|
||||
"dashboard",
|
||||
"neo-tree",
|
||||
"Trouble",
|
||||
"trouble",
|
||||
"lazy",
|
||||
"mason",
|
||||
"notify",
|
||||
"toggleterm",
|
||||
"lazyterm",
|
||||
},
|
||||
callback = function()
|
||||
vim.b.miniindentscope_disable = true
|
||||
end,
|
||||
})
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
local Utils = require("juancwu.utils")
|
||||
local os_utils = require("os_utils")
|
||||
|
||||
if Utils.os.is_linux() then
|
||||
if os_utils.is_linux() then
|
||||
local wayland_display = os.getenv("WAYLAND_DISPLAY")
|
||||
local ssh_tty = os.getenv("SSH_TTY")
|
||||
if Utils.os.is_wsl() then
|
||||
if os_utils.is_wsl() then
|
||||
vim.g.clipboard = {
|
||||
name = "win32yank",
|
||||
copy = {
|
||||
|
|
@ -57,7 +57,7 @@ if Utils.os.is_linux() then
|
|||
cache_enabled = 1,
|
||||
}
|
||||
end
|
||||
elseif Utils.os.is_mac() then
|
||||
elseif os_utils.is_mac() then
|
||||
vim.g.clipboard = {
|
||||
name = "mac-clipboard",
|
||||
copy = {
|
||||
11
nvim/lua/cmds.lua
Normal file
11
nvim/lua/cmds.lua
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
vim.api.nvim_create_user_command("FormatDisable", function()
|
||||
vim.g.disable_autoformat = true
|
||||
end, {
|
||||
desc = "Disable autoformat on save",
|
||||
})
|
||||
|
||||
vim.api.nvim_create_user_command("FormatEnable", function()
|
||||
vim.g.disable_autoformat = false
|
||||
end, {
|
||||
desc = "Enable autoformat on save",
|
||||
})
|
||||
75
nvim/lua/colorscheme.lua
Normal file
75
nvim/lua/colorscheme.lua
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
vim.pack.add({ { src = "https://github.com/catppuccin/nvim", name = "catppuccin" } })
|
||||
|
||||
require("catppuccin").setup({
|
||||
flavour = "auto", -- latte, frappe, macchiato, mocha
|
||||
background = { -- :h background
|
||||
light = "latte",
|
||||
dark = "mocha",
|
||||
},
|
||||
transparent_background = false, -- disables setting the background color.
|
||||
float = {
|
||||
transparent = false, -- enable transparent floating windows
|
||||
solid = false, -- use solid styling for floating windows, see |winborder|
|
||||
},
|
||||
term_colors = false, -- sets terminal colors (e.g. `g:terminal_color_0`)
|
||||
dim_inactive = {
|
||||
enabled = false, -- dims the background color of inactive window
|
||||
shade = "dark",
|
||||
percentage = 0.15, -- percentage of the shade to apply to the inactive window
|
||||
},
|
||||
no_italic = false, -- Force no italic
|
||||
no_bold = false, -- Force no bold
|
||||
no_underline = false, -- Force no underline
|
||||
styles = { -- Handles the styles of general hi groups (see `:h highlight-args`):
|
||||
comments = { "italic" }, -- Change the style of comments
|
||||
conditionals = { "italic" },
|
||||
loops = {},
|
||||
functions = {},
|
||||
keywords = {},
|
||||
strings = {},
|
||||
variables = {},
|
||||
numbers = {},
|
||||
booleans = {},
|
||||
properties = {},
|
||||
types = {},
|
||||
operators = {},
|
||||
-- miscs = {}, -- Uncomment to turn off hard-coded styles
|
||||
},
|
||||
lsp_styles = { -- Handles the style of specific lsp hl groups (see `:h lsp-highlight`).
|
||||
virtual_text = {
|
||||
errors = { "italic" },
|
||||
hints = { "italic" },
|
||||
warnings = { "italic" },
|
||||
information = { "italic" },
|
||||
ok = { "italic" },
|
||||
},
|
||||
underlines = {
|
||||
errors = { "underline" },
|
||||
hints = { "underline" },
|
||||
warnings = { "underline" },
|
||||
information = { "underline" },
|
||||
ok = { "underline" },
|
||||
},
|
||||
inlay_hints = {
|
||||
background = true,
|
||||
},
|
||||
},
|
||||
color_overrides = {},
|
||||
custom_highlights = {},
|
||||
default_integrations = true,
|
||||
auto_integrations = false,
|
||||
integrations = {
|
||||
cmp = true,
|
||||
gitsigns = true,
|
||||
nvimtree = true,
|
||||
notify = false,
|
||||
mini = {
|
||||
enabled = true,
|
||||
indentscope_color = "",
|
||||
},
|
||||
-- For more plugins integrations please scroll down (https://github.com/catppuccin/nvim#integrations)
|
||||
},
|
||||
})
|
||||
|
||||
-- setup must be called before loading
|
||||
vim.cmd.colorscheme("catppuccin-nvim")
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
---@class Config: ConfigOptions
|
||||
local M = {}
|
||||
|
||||
---@class ConfigOptions
|
||||
local defaultOpts = {
|
||||
---@type string | fun()
|
||||
colorscheme = "catppuccin",
|
||||
}
|
||||
|
||||
vim.g.disable_autoformat = false
|
||||
|
||||
---@param name "options" | "keymaps" | "clipboard"
|
||||
function M.load(name)
|
||||
local mod = "juancwu.config." .. name
|
||||
local error_handler = function(err)
|
||||
local msg = "Failed loading " .. mod .. "\n\n" .. err
|
||||
print(msg)
|
||||
end
|
||||
xpcall(function()
|
||||
require(mod)
|
||||
end, error_handler)
|
||||
end
|
||||
|
||||
---@type ConfigOptions
|
||||
local options
|
||||
|
||||
---@param opts? ConfigOptions
|
||||
function M.setup(opts)
|
||||
options = vim.tbl_deep_extend("force", defaultOpts, opts or {}) or {}
|
||||
|
||||
M.load("options")
|
||||
M.load("keymaps")
|
||||
M.load("clipboard")
|
||||
|
||||
require("lazy").setup("juancwu.plugins")
|
||||
|
||||
-- try to load colorscheme
|
||||
xpcall(function()
|
||||
if type(M.colorscheme) == "function" then
|
||||
M.colorscheme()
|
||||
else
|
||||
vim.cmd.colorscheme(M.colorscheme)
|
||||
end
|
||||
end, function(err)
|
||||
if type(M.colorscheme) == "string" then
|
||||
local msg = "Failed to load colorscheme " .. M.colorscheme .. "\n\n" .. err
|
||||
print(msg)
|
||||
else
|
||||
print("Failed to load colorscheme\n\n" .. err)
|
||||
end
|
||||
vim.cmd.colorscheme("rose-pine")
|
||||
end)
|
||||
|
||||
-- create command to disable autoformat
|
||||
vim.api.nvim_create_user_command("FormatDisable", function(args)
|
||||
vim.g.disable_autoformat = true
|
||||
end, { desc = "Disable Autoformat" })
|
||||
vim.api.nvim_create_user_command("FormatEnable", function(args)
|
||||
vim.g.disable_autoformat = false
|
||||
end, { desc = "Enable Autoformat" })
|
||||
end
|
||||
|
||||
setmetatable(M, {
|
||||
__index = function(_, k)
|
||||
if options == nil then
|
||||
return vim.deepcopy(defaultOpts)[k]
|
||||
end
|
||||
|
||||
return options[k]
|
||||
end,
|
||||
})
|
||||
|
||||
return M
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
-- easy escape
|
||||
vim.keymap.set("i", "<C-[>", "<Esc>", { noremap = true, silent = true })
|
||||
vim.keymap.set("v", "<C-[>", "<Esc>", { noremap = true, silent = true })
|
||||
vim.keymap.set("n", "<C-[>", "<Esc>", { noremap = true, silent = true })
|
||||
|
||||
-- open the explorer
|
||||
vim.keymap.set("n", "<leader>ex", "<cmd>Ex<CR>")
|
||||
|
||||
-- move highlighted lines
|
||||
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
|
||||
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
|
||||
|
||||
-- make cursor stay in same position when appending line below
|
||||
vim.keymap.set("n", "J", "mzJ`z")
|
||||
|
||||
-- make cursor stay in the middle while moving down/up the page
|
||||
vim.keymap.set("n", "<C-d>", "<C-d>zz")
|
||||
vim.keymap.set("n", "<C-u>", "<C-u>zz")
|
||||
|
||||
-- make cursor stay in the middle while looking through search results
|
||||
vim.keymap.set("n", "n", "nzzzv")
|
||||
vim.keymap.set("n", "N", "Nzzzv")
|
||||
|
||||
-- select and replace
|
||||
vim.keymap.set("n", "<leader>ss", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
|
||||
|
||||
-- do not copy with x, for god sake, WHY copy something that is being deleted??
|
||||
vim.keymap.set("n", "x", '"_x')
|
||||
|
||||
-- no copy, delete line, for god sake...
|
||||
vim.keymap.set("n", "dd", '"_dd')
|
||||
vim.keymap.set("n", "dx", "dd") -- cut line, under my control
|
||||
vim.keymap.set("v", "d", '"_d')
|
||||
|
||||
-- copy/paste to/from system clipboard
|
||||
vim.keymap.set({ "n", "v" }, "<leader>y", '"+y')
|
||||
vim.keymap.set({ "n", "v" }, "<leader>p", '"+p')
|
||||
|
||||
-- increment/decrement a count, helpful for changing indeces
|
||||
vim.keymap.set("n", "+", "<C-a>")
|
||||
vim.keymap.set("n", "-", "<C-x>")
|
||||
|
||||
-- do not copy when deleting word
|
||||
vim.keymap.set("n", "dw", '"_dw')
|
||||
vim.keymap.set("n", "db", 'vb"_d') -- delete in backwards
|
||||
|
||||
vim.keymap.set("n", "<C-a>", "gg<S-v>G") -- select all
|
||||
|
||||
-- split pane
|
||||
vim.keymap.set("n", "ss", ":split<Return><C-w>w", { silent = true }) -- horizontal
|
||||
vim.keymap.set("n", "sv", ":vsplit<Return><C-w>w", { silent = true }) -- vertical
|
||||
|
||||
-- pane movement
|
||||
vim.keymap.set("n", "..", "<C-w>w") -- toggle
|
||||
vim.keymap.set("n", "sh", "<C-w>h")
|
||||
vim.keymap.set("n", "sk", "<C-w>k")
|
||||
vim.keymap.set("n", "sl", "<C-w>l")
|
||||
vim.keymap.set("n", "sj", "<C-w>j")
|
||||
|
||||
-- resize pane
|
||||
vim.keymap.set("n", "<C-w><left>", "<C-w>5>")
|
||||
vim.keymap.set("n", "<C-w><right>", "<C-w>5<")
|
||||
vim.keymap.set("n", "<C-w><up>", "<C-w>5+")
|
||||
vim.keymap.set("n", "<C-w><down>", "<C-w>5-")
|
||||
|
||||
-- lazygit on floaterm
|
||||
vim.keymap.set("n", "<leader>g", "<cmd>FloatermNew lazygit<CR>", { noremap = true })
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
local M = {}
|
||||
|
||||
---@param opts? ConfigOptions
|
||||
function M.setup(opts)
|
||||
require("juancwu.config").setup(opts)
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
@ -1,139 +0,0 @@
|
|||
-- return { -- Autocompletion
|
||||
-- "hrsh7th/nvim-cmp",
|
||||
-- event = "InsertEnter",
|
||||
-- dependencies = {
|
||||
-- -- Snippet Engine & its associated nvim-cmp source
|
||||
-- {
|
||||
-- "L3MON4D3/LuaSnip",
|
||||
-- build = (function()
|
||||
-- -- Build Step is needed for regex support in snippets.
|
||||
-- -- This step is not supported in many windows environments.
|
||||
-- -- Remove the below condition to re-enable on windows.
|
||||
-- if vim.fn.has("win32") == 1 or vim.fn.executable("make") == 0 then
|
||||
-- return
|
||||
-- end
|
||||
-- return "make install_jsregexp"
|
||||
-- end)(),
|
||||
-- dependencies = {
|
||||
-- {
|
||||
-- "rafamadriz/friendly-snippets",
|
||||
-- config = function()
|
||||
-- require("luasnip.loaders.from_vscode").lazy_load()
|
||||
-- end,
|
||||
-- },
|
||||
-- },
|
||||
-- },
|
||||
-- "saadparwaiz1/cmp_luasnip",
|
||||
-- "hrsh7th/cmp-nvim-lsp",
|
||||
-- "hrsh7th/cmp-path",
|
||||
-- },
|
||||
-- config = function()
|
||||
-- -- See `:help cmp`
|
||||
-- local cmp = require("cmp")
|
||||
-- local luasnip = require("luasnip")
|
||||
-- luasnip.config.setup({})
|
||||
--
|
||||
-- cmp.setup({
|
||||
-- snippet = {
|
||||
-- expand = function(args)
|
||||
-- luasnip.lsp_expand(args.body)
|
||||
-- end,
|
||||
-- },
|
||||
-- completion = { completeopt = "menu,menuone,noinsert" },
|
||||
--
|
||||
-- -- For an understanding of why these mappings were
|
||||
-- -- chosen, you will need to read `:help ins-completion`
|
||||
-- --
|
||||
-- -- No, but seriously. Please read `:help ins-completion`, it is really good!
|
||||
-- mapping = cmp.mapping.preset.insert({
|
||||
-- -- Select the [n]ext item
|
||||
-- ["<C-n>"] = cmp.mapping.select_next_item(),
|
||||
-- -- Select the [p]revious item
|
||||
-- ["<C-p>"] = cmp.mapping.select_prev_item(),
|
||||
--
|
||||
-- -- Scroll the documentation window [b]ack / [f]orward
|
||||
-- ["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||
-- ["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
--
|
||||
-- -- Accept ([y]es) the completion.
|
||||
-- -- This will auto-import if your LSP supports it.
|
||||
-- -- This will expand snippets if the LSP sent a snippet.
|
||||
-- ["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||
--
|
||||
-- -- Manually trigger a completion from nvim-cmp.
|
||||
-- -- Generally you don't need this, because nvim-cmp will display
|
||||
-- -- completions whenever it has completion options available.
|
||||
-- ["<C-Space>"] = cmp.mapping.complete({}),
|
||||
--
|
||||
-- -- <c-l> will move you to the right of each of the expansion locations.
|
||||
-- -- <c-h> is similar, except moving you backwards.
|
||||
-- ["<C-l>"] = cmp.mapping(function()
|
||||
-- if luasnip.expand_or_locally_jumpable() then
|
||||
-- luasnip.expand_or_jump()
|
||||
-- end
|
||||
-- end, { "i", "s" }),
|
||||
-- ["<C-h>"] = cmp.mapping(function()
|
||||
-- if luasnip.locally_jumpable(-1) then
|
||||
-- luasnip.jump(-1)
|
||||
-- end
|
||||
-- end, { "i", "s" }),
|
||||
-- }),
|
||||
-- sources = {
|
||||
-- {
|
||||
-- name = "lazydev",
|
||||
-- -- set group index to 0 to skip loading LuaLS completions as lazydev recommends it
|
||||
-- group_index = 0,
|
||||
-- },
|
||||
-- { name = "nvim_lsp" },
|
||||
-- { name = "luasnip" },
|
||||
-- { name = "path" },
|
||||
-- },
|
||||
-- })
|
||||
-- end,
|
||||
-- }
|
||||
--
|
||||
|
||||
return {
|
||||
"saghen/blink.cmp",
|
||||
-- optional: provides snippets for the snippet source
|
||||
dependencies = { "rafamadriz/friendly-snippets" },
|
||||
version = "1.*",
|
||||
|
||||
---@module 'blink.cmp'
|
||||
---@type blink.cmp.Config
|
||||
opts = {
|
||||
-- C-space: Open menu or open docs if already open
|
||||
-- C-n/C-p or Up/Down: Select next/previous item
|
||||
-- C-e: Hide menu
|
||||
-- C-k: Toggle signature help (if signature.enabled = true)
|
||||
--
|
||||
-- See :h blink-cmp-config-keymap for defining your own keymap
|
||||
keymap = { preset = "enter" },
|
||||
signature = {
|
||||
enabled = true,
|
||||
},
|
||||
|
||||
appearance = {
|
||||
-- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
|
||||
-- Adjusts spacing to ensure icons are aligned
|
||||
nerd_font_variant = "mono",
|
||||
},
|
||||
|
||||
-- (Default) Only show the documentation popup when manually triggered
|
||||
completion = { documentation = { auto_show = true } },
|
||||
|
||||
-- Default list of enabled providers defined so that you can extend it
|
||||
-- elsewhere in your config, without redefining it, due to `opts_extend`
|
||||
sources = {
|
||||
default = { "lsp", "path", "snippets", "buffer" },
|
||||
},
|
||||
|
||||
-- (Default) Rust fuzzy matcher for typo resistance and significantly better performance
|
||||
-- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation,
|
||||
-- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"`
|
||||
--
|
||||
-- See the fuzzy documentation for more information
|
||||
fuzzy = { implementation = "prefer_rust_with_warning" },
|
||||
},
|
||||
opts_extend = { "sources.default" },
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
return {
|
||||
"windwp/nvim-autopairs",
|
||||
event = "InsertEnter",
|
||||
dependencies = { "hrsh7th/nvim-cmp" },
|
||||
config = function()
|
||||
require("nvim-autopairs").setup({})
|
||||
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
|
||||
local cmp = require("cmp")
|
||||
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
|
||||
end,
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
return {
|
||||
"windwp/nvim-ts-autotag",
|
||||
dependencies = { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" },
|
||||
ft = {
|
||||
"html",
|
||||
"javascript",
|
||||
"typescript",
|
||||
"javascriptreact",
|
||||
"typescriptreact",
|
||||
"svelte",
|
||||
"vue",
|
||||
"tsx",
|
||||
"jsx",
|
||||
"xml",
|
||||
"php",
|
||||
"markdown",
|
||||
"astro",
|
||||
"glimmer",
|
||||
"handlebars",
|
||||
"hbs",
|
||||
"templ",
|
||||
"blade",
|
||||
},
|
||||
config = function()
|
||||
local autotag = require("nvim-ts-autotag")
|
||||
autotag.setup({
|
||||
enable = true,
|
||||
enable_close_on_slash = false,
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
return {
|
||||
-- rose-pine
|
||||
{
|
||||
"rose-pine/nvim",
|
||||
name = "rose-pine",
|
||||
priority = 1000,
|
||||
},
|
||||
|
||||
-- onedark
|
||||
{
|
||||
"navarasu/onedark.nvim",
|
||||
priority = 1000,
|
||||
},
|
||||
|
||||
-- solarized-osaka
|
||||
{
|
||||
"craftzdog/solarized-osaka.nvim",
|
||||
priority = 1000,
|
||||
opts = {
|
||||
transparent = false,
|
||||
},
|
||||
},
|
||||
|
||||
-- tokyonight
|
||||
{
|
||||
"folke/tokyonight.nvim",
|
||||
lazy = true,
|
||||
opts = { style = "moon" },
|
||||
},
|
||||
|
||||
-- catppuccin
|
||||
{
|
||||
"catppuccin/nvim",
|
||||
lazy = true,
|
||||
name = "catppuccin",
|
||||
priority = 1000,
|
||||
opts = {
|
||||
flavour = "mocha",
|
||||
integrations = { blink_cmp = true },
|
||||
},
|
||||
},
|
||||
|
||||
-- great kanagawa
|
||||
{
|
||||
"rebelot/kanagawa.nvim",
|
||||
opts = {},
|
||||
},
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
return {
|
||||
"numToStr/Comment.nvim",
|
||||
dependencies = {
|
||||
{
|
||||
"JoosepAlviste/nvim-ts-context-commentstring",
|
||||
opts = {
|
||||
enable_autocmd = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
config = function()
|
||||
local comment = require("Comment")
|
||||
comment.setup({
|
||||
pre_hook = function(ctx)
|
||||
-- only for tsx/jsx filetypes
|
||||
if vim.bo.filetype == "typescriptreact" or vim.bo.filetype == "javascriptreact" then
|
||||
local U = require("Comment.utils")
|
||||
|
||||
-- determine wheter to use linwise or blockwise commentstring
|
||||
local type = ctx.ctype == U.ctype.linewise and "__default" or "__multiline"
|
||||
|
||||
-- determine the location where to calcualte commentstring from
|
||||
local location = nil
|
||||
if ctx.ctype == U.ctype.blockwise then
|
||||
location = require("ts_context_commentstring.utils").get_cursor_location()
|
||||
elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then
|
||||
location = require("ts_context_commentstring.utils").get_visual_start_location()
|
||||
end
|
||||
|
||||
return require("ts_context_commentstring.internal").calculate_commentstring({
|
||||
key = type,
|
||||
location = location,
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
local formatters_by_ft = {
|
||||
lua = { "stylua" },
|
||||
javascript = { "biome" },
|
||||
typescript = { "biome" },
|
||||
javascriptreact = { "biome" },
|
||||
typescriptreact = { "biome" },
|
||||
css = { "biome" },
|
||||
markdown = { "biome" },
|
||||
jsonc = { "biome" },
|
||||
json = { "biome" },
|
||||
go = { "gofmt", "goimports" },
|
||||
python = { "autopep8" },
|
||||
yaml = { "yamlfmt" },
|
||||
yml = { "yamlfmt" },
|
||||
zig = { "zigfmt" },
|
||||
rust = { "rustfmt" },
|
||||
templ = { "templ" },
|
||||
php = { "pint" },
|
||||
blade = { "blade-formatter" },
|
||||
}
|
||||
|
||||
return {
|
||||
"stevearc/conform.nvim",
|
||||
event = { "BufWritePre", "BufEnter" },
|
||||
cmd = { "ConformInfo" },
|
||||
keys = {
|
||||
{
|
||||
"<leader>ff",
|
||||
function()
|
||||
require("conform").format({ async = true, lsp_format = "fallback" })
|
||||
end,
|
||||
mode = "",
|
||||
desc = "[F]ormat buffer",
|
||||
},
|
||||
},
|
||||
config = function()
|
||||
require("conform").setup({
|
||||
notify_on_error = false,
|
||||
formatters_by_ft = formatters_by_ft,
|
||||
formatters = {
|
||||
pint = {
|
||||
command = "vendor/bin/pint",
|
||||
args = { "$FILENAME" },
|
||||
stdin = false,
|
||||
},
|
||||
["blade-formatter"] = {
|
||||
command = "blade-formatter",
|
||||
args = {
|
||||
"--write",
|
||||
"--stdin",
|
||||
},
|
||||
},
|
||||
},
|
||||
format_on_save = function(bufnr)
|
||||
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
|
||||
return
|
||||
end
|
||||
return {
|
||||
timeout_ms = 2500,
|
||||
lsp_format = "fallback",
|
||||
}
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_user_command("FormatDisable", function()
|
||||
vim.g.disable_autoformat = true
|
||||
end, {
|
||||
desc = "Disable autoformat on save",
|
||||
})
|
||||
|
||||
vim.api.nvim_create_user_command("FormatEnable", function()
|
||||
vim.g.disable_autoformat = false
|
||||
end, {
|
||||
desc = "Enable autoformat on save",
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
return {
|
||||
"tpope/vim-fugitive",
|
||||
cmd = {
|
||||
"Git",
|
||||
"G",
|
||||
"Gdiffsplit",
|
||||
"Gread",
|
||||
"Gwrite",
|
||||
"Ggrep",
|
||||
"GMove",
|
||||
"GDelete",
|
||||
"GBrowse",
|
||||
"GRemove",
|
||||
"GRename",
|
||||
"Glgrep",
|
||||
"Gedit",
|
||||
},
|
||||
keys = {
|
||||
{ "<leader>gs", "<cmd>Git<CR>", desc = "Git status" },
|
||||
{ "<leader>gbl", "<cmd>Git blame<CR>", desc = "Open [G]it [Bl]ame" },
|
||||
{ "<leader>gd", "<cmd>Gdiffsplit<CR>", desc = "Open [G]it [D]iff" },
|
||||
},
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
return {
|
||||
"lewis6991/gitsigns.nvim",
|
||||
opts = {
|
||||
current_line_blame = true,
|
||||
current_line_blame_opts = {
|
||||
virt_text = true,
|
||||
virt_text_pos = "eol",
|
||||
delay = 1000,
|
||||
ignore_whitespace = false,
|
||||
},
|
||||
signs = {
|
||||
add = { text = "+" },
|
||||
change = { text = "~" },
|
||||
delete = { text = "_" },
|
||||
topdelete = { text = "-" },
|
||||
changedelete = { text = "~" },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
return {
|
||||
"folke/lazydev.nvim",
|
||||
ft = "lua",
|
||||
opts = {
|
||||
library = {
|
||||
{ path = "luvit-meta/library", words = { "vim%.uv" } },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -1,214 +0,0 @@
|
|||
return {
|
||||
-- lspconfig
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
|
||||
{ "williamboman/mason.nvim", opts = {} },
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
||||
|
||||
-- status updates for LSP
|
||||
{ "j-hui/fidget.nvim", opts = {} },
|
||||
|
||||
{ "saghen/blink.cmp" },
|
||||
},
|
||||
config = function()
|
||||
-- stole this from kickstart, great config
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }),
|
||||
callback = function(event)
|
||||
-- This is the helper function to set keymaps locally for this buffer
|
||||
local map = function(keys, func, desc, mode)
|
||||
mode = mode or "n"
|
||||
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = "LSP: " .. desc })
|
||||
end
|
||||
|
||||
-- Use built-in LSP for definitions (replaces deprecated Telescope function)
|
||||
map("gd", vim.lsp.buf.definition, "[G]oto [D]efinition")
|
||||
|
||||
-- Use Telescope for references (auto-closes on selection)
|
||||
map("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences")
|
||||
|
||||
-- Use built-in LSP for implementation (replaces deprecated Telescope function)
|
||||
map("gI", vim.lsp.buf.implementation, "[G]oto [I]mplementation")
|
||||
|
||||
-- Use built-in LSP for type definitions (replaces deprecated Telescope function)
|
||||
map("<leader>D", vim.lsp.buf.type_definition, "Type [D]efinition")
|
||||
|
||||
-- Telescope for document symbols (this is a good use for Telescope)
|
||||
map("<leader>ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols")
|
||||
|
||||
-- Telescope for workspace symbols (also a good use for Telescope)
|
||||
map("<leader>ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols")
|
||||
|
||||
-- Built-in LSP for renaming
|
||||
map("<leader>rn", vim.lsp.buf.rename, "[R]e[n]ame")
|
||||
|
||||
-- Built-in LSP for code actions
|
||||
map("<leader>ca", vim.lsp.buf.code_action, "[C]ode [A]ction", { "n", "x" })
|
||||
|
||||
-- Built-in LSP for declaration
|
||||
map("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
|
||||
|
||||
-- Built-in LSP for diagnostics
|
||||
map("[d", vim.diagnostic.goto_prev, "Go to previous diagnostic")
|
||||
map("]d", vim.diagnostic.goto_next, "Go to next diagnostic")
|
||||
|
||||
-- The following two autocommands are used to highlight references of the
|
||||
-- word under your cursor when your cursor rests there for a little while.
|
||||
-- See `:help CursorHold` for information about when this is executed
|
||||
--
|
||||
-- When you move your cursor, the highlights will be cleared (the second autocommand).
|
||||
local client = vim.lsp.get_client_by_id(event.data.client_id)
|
||||
if client and client:supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then
|
||||
local highlight_augroup = vim.api.nvim_create_augroup("kickstart-lsp-highlight", { clear = false })
|
||||
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
|
||||
buffer = event.buf,
|
||||
group = highlight_augroup,
|
||||
callback = vim.lsp.buf.document_highlight,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
|
||||
buffer = event.buf,
|
||||
group = highlight_augroup,
|
||||
callback = vim.lsp.buf.clear_references,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("LspDetach", {
|
||||
group = vim.api.nvim_create_augroup("kickstart-lsp-detach", { clear = true }),
|
||||
callback = function(event2)
|
||||
vim.lsp.buf.clear_references()
|
||||
vim.api.nvim_clear_autocmds({ group = "kickstart-lsp-highlight", buffer = event2.buf })
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = require("blink.cmp").get_lsp_capabilities(capabilities)
|
||||
|
||||
vim.filetype.add({
|
||||
extension = {
|
||||
templ = "templ",
|
||||
},
|
||||
pattern = {
|
||||
[".*%.blade%.php"] = "blade",
|
||||
},
|
||||
})
|
||||
|
||||
local servers = {
|
||||
ts_ls = {},
|
||||
gopls = {},
|
||||
zls = {},
|
||||
rust_analyzer = {},
|
||||
templ = {
|
||||
filetypes = { "templ" },
|
||||
},
|
||||
intelephense = {},
|
||||
html = {
|
||||
filetypes = { "html", "twig", "hbs", "blade" },
|
||||
},
|
||||
emmet_ls = {
|
||||
filetypes = {
|
||||
"html",
|
||||
"typescriptreact",
|
||||
"javascriptreact",
|
||||
"css",
|
||||
"sass",
|
||||
"scss",
|
||||
"less",
|
||||
"blade",
|
||||
},
|
||||
},
|
||||
lua_ls = {
|
||||
settings = {
|
||||
Lua = {
|
||||
completion = {
|
||||
callSnippet = "Replace",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
cssls = {},
|
||||
css_variables = {},
|
||||
tailwindcss = {
|
||||
filetypes = {
|
||||
"templ",
|
||||
"html",
|
||||
"javascript",
|
||||
"typescript",
|
||||
"javascriptreact",
|
||||
"typescriptreact",
|
||||
"blade",
|
||||
},
|
||||
init_options = {
|
||||
userLanguages = {
|
||||
templ = "html",
|
||||
blade = "html",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
local ensure_installed = vim.tbl_keys(servers or {})
|
||||
vim.list_extend(ensure_installed, { "stylua", "yamlfmt", "biome", "goimports", "pint", "blade-formatter" })
|
||||
-- require("mason-tool-installer").setup({ ensure_installed = ensure_installed })
|
||||
|
||||
local profiles = {
|
||||
base = { "yamlfmt" },
|
||||
lua = { "lua_ls", "stylua" },
|
||||
web = {
|
||||
"ts_ls",
|
||||
"tailwindcss",
|
||||
"biome",
|
||||
"intelephense",
|
||||
"templ",
|
||||
"cssls",
|
||||
"css_variables",
|
||||
"html",
|
||||
"emmet_ls",
|
||||
"pint",
|
||||
"blade-formatter",
|
||||
},
|
||||
go = { "gopls", "goimports" },
|
||||
rust = { "rust_analyzer" },
|
||||
zig = { "zls" },
|
||||
all = ensure_installed,
|
||||
}
|
||||
|
||||
vim.api.nvim_create_user_command("InstallProfile", function(opts)
|
||||
local profile_name = opts.args
|
||||
local tools = profiles[profile_name]
|
||||
|
||||
if not tools then
|
||||
print(
|
||||
"Profile '"
|
||||
.. profile_name
|
||||
.. "' not found. Available: "
|
||||
.. table.concat(vim.tbl_keys(profiles), ", ")
|
||||
)
|
||||
return
|
||||
end
|
||||
|
||||
require("mason-tool-installer").setup({ ensure_installed = tools })
|
||||
vim.cmd("MasonToolsInstall")
|
||||
end, {
|
||||
desc = "Install tools for a specific profile (e.g., web, lua, go)",
|
||||
nargs = 1,
|
||||
complete = function()
|
||||
return vim.tbl_keys(profiles)
|
||||
end,
|
||||
})
|
||||
|
||||
require("mason-lspconfig").setup({
|
||||
handlers = {
|
||||
function(server_name)
|
||||
local server = servers[server_name] or {}
|
||||
server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {})
|
||||
require("lspconfig")[server_name].setup(server)
|
||||
end,
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
return {
|
||||
"nvim-lualine/lualine.nvim",
|
||||
dependencies = { "nvim-tree/nvim-web-devicons", lazy = true },
|
||||
config = function()
|
||||
local lualine = require("lualine")
|
||||
|
||||
lualine.setup({
|
||||
options = {
|
||||
icons_enabled = false,
|
||||
--[[ section_separators = {
|
||||
left = '',
|
||||
right = ''
|
||||
},
|
||||
component_separators = {
|
||||
left = '',
|
||||
right = ''
|
||||
}, ]]
|
||||
section_separators = "",
|
||||
component_separators = "|",
|
||||
disabled_filetypes = {},
|
||||
},
|
||||
sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = {
|
||||
{
|
||||
"filename",
|
||||
file_status = true, -- display file status
|
||||
path = 1, -- no file path
|
||||
},
|
||||
},
|
||||
lualine_x = {
|
||||
{
|
||||
"diagnostics",
|
||||
sources = { "nvim_diagnostic" },
|
||||
symbols = { error = " ", warn = " ", info = " ", hint = "" },
|
||||
},
|
||||
"enconding",
|
||||
"filetype",
|
||||
},
|
||||
lualine_y = { "progress" },
|
||||
lualine_z = { "location" },
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = {
|
||||
{
|
||||
"filename",
|
||||
file_status = true,
|
||||
path = 1,
|
||||
},
|
||||
},
|
||||
lualine_x = { "location" },
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
},
|
||||
tabline = {},
|
||||
extensions = { "fugitive" },
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
return {
|
||||
"Bilal2453/luvit-meta",
|
||||
lazy = true,
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
return {
|
||||
"echasnovski/mini.indentscope",
|
||||
version = false, -- wait till new 0.7.0 release to put it back on semver
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
opts = {
|
||||
-- symbol = "▏",
|
||||
symbol = "│",
|
||||
options = { try_as_border = true },
|
||||
},
|
||||
init = function()
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = {
|
||||
"help",
|
||||
"alpha",
|
||||
"dashboard",
|
||||
"neo-tree",
|
||||
"Trouble",
|
||||
"trouble",
|
||||
"lazy",
|
||||
"mason",
|
||||
"notify",
|
||||
"toggleterm",
|
||||
"lazyterm",
|
||||
},
|
||||
callback = function()
|
||||
vim.b.miniindentscope_disable = true
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
return {
|
||||
"nvim-neo-tree/neo-tree.nvim",
|
||||
enabled = false,
|
||||
branch = "v2.x",
|
||||
cmd = { "Neotree" },
|
||||
keys = {
|
||||
{ "<leader>fs", "<cmd>NeoTreeFloatToggle<CR>", desc = "Toggle [F]ile [S]ystem Floating Menu" },
|
||||
{ "<C-b>", "<cmd>NeoTreeFocusToggle<CR>", desc = "Open Side File System" },
|
||||
},
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
"MunifTanjim/nui.nvim",
|
||||
},
|
||||
opts = {
|
||||
use_default_mappings = true,
|
||||
mappings = {
|
||||
["<space>"] = {
|
||||
"toggle_node",
|
||||
nowait = true, -- disable `nowait` if you have existing combos starting with this char that you want to use
|
||||
},
|
||||
["<2-LeftMouse>"] = "open",
|
||||
["<cr>"] = "open",
|
||||
["<esc>"] = "cancel", -- close preview or floating neo-tree window
|
||||
["P"] = { "toggle_preview", config = { use_float = true } },
|
||||
["l"] = "focus_preview",
|
||||
["O"] = "open_split",
|
||||
["o"] = "open_vsplit",
|
||||
["S"] = "none",
|
||||
["s"] = "none",
|
||||
-- ["S"] = "split_with_window_picker",
|
||||
-- ["s"] = "vsplit_with_window_picker",
|
||||
["t"] = "open_tabnew",
|
||||
-- ["<cr>"] = "open_drop",
|
||||
-- ["t"] = "open_tab_drop",
|
||||
["w"] = "open_with_window_picker",
|
||||
--["P"] = "toggle_preview", -- enter preview mode, which shows the current node without focusing
|
||||
["C"] = "close_node",
|
||||
-- ['C'] = 'close_all_subnodes',
|
||||
["z"] = "close_all_nodes",
|
||||
--["Z"] = "expand_all_nodes",
|
||||
["a"] = {
|
||||
"add",
|
||||
-- this command supports BASH style brace expansion ("x{a,b,c}" -> xa,xb,xc). see `:h neo-tree-file-actions` for details
|
||||
-- some commands may take optional config options, see `:h neo-tree-mappings` for details
|
||||
config = {
|
||||
show_path = "none", -- "none", "relative", "absolute"
|
||||
},
|
||||
},
|
||||
["A"] = "add_directory", -- also accepts the optional config.show_path option like "add". this also supports BASH style brace expansion.
|
||||
["d"] = "delete",
|
||||
["r"] = "rename",
|
||||
["y"] = "copy_to_clipboard",
|
||||
["x"] = "cut_to_clipboard",
|
||||
["p"] = "paste_from_clipboard",
|
||||
["c"] = "copy", -- takes text input for destination, also accepts the optional config.show_path option like "add":
|
||||
-- ["c"] = {
|
||||
-- "copy",
|
||||
-- config = {
|
||||
-- show_path = "none" -- "none", "relative", "absolute"
|
||||
-- }
|
||||
--}
|
||||
["m"] = "move", -- takes text input for destination, also accepts the optional config.show_path option like "add".
|
||||
["q"] = "close_window",
|
||||
["R"] = "refresh",
|
||||
["?"] = "show_help",
|
||||
["<"] = "prev_source",
|
||||
[">"] = "next_source",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
local linters_by_ft = {
|
||||
javascript = { "biomejs", "eslint" },
|
||||
typescript = { "biomejs", "eslint" },
|
||||
javascriptreact = { "biomejs", "eslint" },
|
||||
typescriptreact = { "biomejs", "eslint" },
|
||||
jsonc = { "biomejs" },
|
||||
json = { "biomejs" },
|
||||
css = { "biomejs" },
|
||||
}
|
||||
|
||||
-- Function to find the first config file by walking up the directory tree
|
||||
local function find_first_config()
|
||||
local current_dir = vim.fn.expand("%:p:h")
|
||||
local home_dir = vim.fn.expand("$HOME")
|
||||
|
||||
local config_files = {
|
||||
biomejs = { "biome.json" },
|
||||
eslint = { ".eslintrc", ".eslintrc.js", ".eslintrc.json", ".eslintrc.yml" },
|
||||
}
|
||||
|
||||
while current_dir ~= home_dir and current_dir ~= "/" do
|
||||
for linter, patterns in pairs(config_files) do
|
||||
for _, pattern in ipairs(patterns) do
|
||||
local config_file = current_dir .. "/" .. pattern
|
||||
if vim.fn.filereadable(config_file) == 1 then
|
||||
return linter
|
||||
end
|
||||
end
|
||||
end
|
||||
current_dir = vim.fn.fnamemodify(current_dir, ":h")
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Function to determine the linter based on config files and file type
|
||||
local function get_linter()
|
||||
local filetype = vim.bo.filetype
|
||||
local available_linters = linters_by_ft[filetype] or {}
|
||||
local linter = find_first_config()
|
||||
|
||||
if linter then
|
||||
if vim.tbl_contains(available_linters, linter) then
|
||||
vim.g.current_linter = linter
|
||||
return linter
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
local function lint()
|
||||
local nvimlint = require("lint")
|
||||
local linter = get_linter()
|
||||
if linter ~= nil then
|
||||
nvimlint.try_lint(linter)
|
||||
else
|
||||
print("No linter found for filetype: " .. vim.bo.filetype)
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
"mfussenegger/nvim-lint",
|
||||
keys = {
|
||||
{
|
||||
"<leader>lf",
|
||||
function()
|
||||
lint()
|
||||
end,
|
||||
mode = "n",
|
||||
desc = "[L]int [F]ile",
|
||||
},
|
||||
},
|
||||
config = function()
|
||||
vim.api.nvim_create_user_command("Lint", function()
|
||||
lint()
|
||||
end, { desc = "Lint file" })
|
||||
|
||||
vim.api.nvim_create_user_command("LintInfo", function()
|
||||
print("Current linter: " .. (vim.g.current_linter or "none"))
|
||||
end, {
|
||||
desc = "Show current linter being used",
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
return {
|
||||
"stevearc/oil.nvim",
|
||||
---@module 'oil'
|
||||
---@type oil.SetupOpts
|
||||
-- Optional dependencies
|
||||
dependencies = { { "echasnovski/mini.icons", opts = {} } },
|
||||
-- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations.
|
||||
lazy = false,
|
||||
config = function()
|
||||
local oil = require("oil")
|
||||
|
||||
oil.setup({
|
||||
view_options = {
|
||||
show_hidden = true,
|
||||
},
|
||||
})
|
||||
end,
|
||||
keys = {
|
||||
{
|
||||
"<leader>oo",
|
||||
function()
|
||||
require("oil").open()
|
||||
end,
|
||||
mode = "n",
|
||||
desc = "[O]pen [O]il",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
return {
|
||||
"MeanderingProgrammer/render-markdown.nvim",
|
||||
dependencies = { "nvim-treesitter/nvim-treesitter", "echasnovski/mini.nvim" }, -- if you use the mini.nvim suite
|
||||
-- dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.icons' }, -- if you use standalone mini plugins
|
||||
-- dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, -- if you prefer nvim-web-devicons
|
||||
---@module 'render-markdown'
|
||||
---@type render.md.UserConfig
|
||||
opts = {},
|
||||
}
|
||||
|
|
@ -1,187 +0,0 @@
|
|||
local function get_fd_command()
|
||||
if vim.fn.executable("fd") == 1 then
|
||||
return "fd"
|
||||
elseif vim.fn.executable("fdfind") == 1 then
|
||||
return "fdfind"
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
return {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
version = "0.1.8",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
{
|
||||
"nvim-telescope/telescope-fzf-native.nvim",
|
||||
build = "make",
|
||||
enabled = true,
|
||||
cond = function()
|
||||
return vim.fn.executable("make") == 1
|
||||
end,
|
||||
},
|
||||
{
|
||||
"nvim-telescope/telescope-file-browser.nvim",
|
||||
dependencies = {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
"nvim-lua/plenary.nvim",
|
||||
},
|
||||
enabled = true,
|
||||
},
|
||||
{ "nvim-telescope/telescope-ui-select.nvim" },
|
||||
{ "nvim-tree/nvim-web-devicons", enabled = vim.g.have_nerd_font },
|
||||
},
|
||||
config = function()
|
||||
local telescope = require("telescope")
|
||||
local actions = require("telescope.actions")
|
||||
local builtin = require("telescope.builtin")
|
||||
local fb_actions = require("telescope").extensions.file_browser.actions
|
||||
|
||||
local function telescope_buffer_dir()
|
||||
return vim.fn.expand("%:p:h")
|
||||
end
|
||||
|
||||
telescope.setup({
|
||||
defaults = {
|
||||
mappings = {
|
||||
n = {
|
||||
["q"] = actions.close,
|
||||
},
|
||||
},
|
||||
},
|
||||
extensions = {
|
||||
["ui-select"] = {
|
||||
require("telescope.themes").get_dropdown(),
|
||||
},
|
||||
file_browser = {
|
||||
theme = "dropdown",
|
||||
hijack_netrw = false,
|
||||
hidden = true,
|
||||
mappings = {
|
||||
["i"] = {
|
||||
["<C-w>"] = function()
|
||||
vim.cmd("normal vbd")
|
||||
end,
|
||||
["<C-j>"] = function(bufnr)
|
||||
actions.move_selection_next(bufnr)
|
||||
end,
|
||||
["<C-k>"] = function(bufnr)
|
||||
actions.move_selection_previous(bufnr)
|
||||
end,
|
||||
["<C-s>"] = function(bufnr)
|
||||
actions.select_vertical(bufnr)
|
||||
end,
|
||||
},
|
||||
["n"] = {
|
||||
["a"] = fb_actions.create,
|
||||
["h"] = fb_actions.goto_parent_dir,
|
||||
["/"] = function()
|
||||
vim.cmd("startinsert")
|
||||
end,
|
||||
["d"] = fb_actions.remove,
|
||||
["e"] = fb_actions.change_cwd,
|
||||
["<C-s>"] = function(bufnr)
|
||||
actions.select_vertical(bufnr)
|
||||
end,
|
||||
["<C-a>"] = function(bufnr)
|
||||
actions.toggle_all(bufnr)
|
||||
end,
|
||||
["<C-d>"] = function(bufnr)
|
||||
actions.move_selection_next(bufnr)
|
||||
end,
|
||||
["<C-u>"] = function(bufnr)
|
||||
actions.move_selection_previous(bufnr)
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
pcall(telescope.load_extension, "file_browser")
|
||||
pcall(telescope.load_extension, "fzf")
|
||||
pcall(telescope.load_extension, "ui-select")
|
||||
|
||||
-- Builtin pickers
|
||||
vim.keymap.set("n", "<leader>sf", function()
|
||||
local fd_cmd = get_fd_command()
|
||||
local config = {
|
||||
hidden = true,
|
||||
file_ignore_patterns = {
|
||||
"node%_modules/.*",
|
||||
"%.git/.*",
|
||||
"%.rustup/.*",
|
||||
"target/.*",
|
||||
".devbox/.*",
|
||||
".nix/.*",
|
||||
"vendor/.*",
|
||||
"storage/.*",
|
||||
},
|
||||
}
|
||||
|
||||
if fd_cmd then
|
||||
config.find_command = {
|
||||
fd_cmd,
|
||||
"--type",
|
||||
"f",
|
||||
"--color",
|
||||
"never",
|
||||
"--hidden",
|
||||
"--no-ignore",
|
||||
}
|
||||
end
|
||||
|
||||
builtin.find_files(config)
|
||||
end, { desc = "[S]earch [F]iles" })
|
||||
vim.keymap.set("n", "<leader>sh", builtin.help_tags, { desc = "[S]earch [H]elp Tags" })
|
||||
vim.keymap.set("n", "<leader>sb", builtin.buffers, { desc = "[S]earch [B]uffers" })
|
||||
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" })
|
||||
-- vim.keymap.set("n", "gr", builtin.lsp_references, { desc = "[G]o to [R]eferences", noremap = true })
|
||||
-- vim.keymap.set("n", "gd", builtin.lsp_definitions, { desc = "[G]o to [D]efinitions" })
|
||||
-- vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { desc = "[G]o to [D]eclaration" })
|
||||
-- vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, { desc = "[R]e[N]ame" })
|
||||
|
||||
-- Git pickers
|
||||
vim.keymap.set("n", "<leader>gf", builtin.git_files, { desc = "Search [G]it [F]iles" })
|
||||
vim.keymap.set("n", "<leader>gs", builtin.git_status, { desc = "List [G]it [S]tatus" })
|
||||
vim.keymap.set("n", "<leader>gh", builtin.git_stash, { desc = "List [G]it [S]tash" })
|
||||
vim.keymap.set("n", "<leader>gbb", builtin.git_branches, { desc = "List [G]it [B]ranches" })
|
||||
vim.keymap.set("n", "<leader>gc", builtin.git_bcommits, { desc = "List Buffer [G]it [C]ommits" })
|
||||
|
||||
-- File Browser Ext
|
||||
vim.keymap.set("n", "<leader>fs", function()
|
||||
telescope.extensions.file_browser.file_browser({
|
||||
path = "%:p:h",
|
||||
cwd = telescope_buffer_dir(),
|
||||
respect_gitignore = false,
|
||||
hidden = true,
|
||||
grouped = true,
|
||||
previewer = false,
|
||||
initial_mode = "normal",
|
||||
layout_config = { height = 40 },
|
||||
})
|
||||
end, { desc = "Open [F]ile [S]ystem Menu" })
|
||||
|
||||
vim.keymap.set("n", "<leader>/", function()
|
||||
builtin.current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({
|
||||
winblend = 10,
|
||||
previewer = false,
|
||||
}))
|
||||
end, { desc = "[/] Fuzzily serach in current buffer" })
|
||||
|
||||
-- live grep in open files only
|
||||
vim.keymap.set("n", "<leader>s/", function()
|
||||
builtin.live_grep({
|
||||
grep_open_files = true,
|
||||
prompt_title = "Live Grep in Open Files",
|
||||
})
|
||||
end, { desc = "[S]search [/] in Open Files" })
|
||||
|
||||
-- shortcut for searching neovim config files
|
||||
vim.keymap.set("n", "<leader>sn", function()
|
||||
builtin.find_files({ cwd = vim.fn.stdpath("config") })
|
||||
end, { desc = "[S]earch [N]eovim files" })
|
||||
end,
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
return {
|
||||
"folke/todo-comments.nvim",
|
||||
dependencies = { "nvim-lua/plenary.nvim" },
|
||||
opts = {},
|
||||
}
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
return {
|
||||
"akinsho/toggleterm.nvim",
|
||||
version = "*",
|
||||
keys = {
|
||||
{
|
||||
"<leader>lg",
|
||||
function()
|
||||
local Terminal = require("toggleterm.terminal").Terminal
|
||||
local lazygit = Terminal:new({
|
||||
cmd = "lazygit",
|
||||
direction = "float",
|
||||
float_opts = {
|
||||
border = "double",
|
||||
},
|
||||
on_open = function(term)
|
||||
vim.cmd("startinsert!")
|
||||
end,
|
||||
on_close = function(term)
|
||||
vim.cmd("startinsert!")
|
||||
end,
|
||||
})
|
||||
lazygit:toggle()
|
||||
end,
|
||||
desc = "Open lazygit in a floating window",
|
||||
},
|
||||
},
|
||||
opts = {
|
||||
size = 20,
|
||||
open_mapping = [[<c-\>]],
|
||||
hide_numbers = true,
|
||||
shade_filetypes = {},
|
||||
shade_terminals = true,
|
||||
shading_factor = 2,
|
||||
start_in_insert = true,
|
||||
insert_mappings = true,
|
||||
terminal_mappings = true,
|
||||
persist_size = true,
|
||||
persist_mode = true,
|
||||
direction = "float",
|
||||
close_on_exit = true,
|
||||
shell = vim.o.shell,
|
||||
float_opts = {
|
||||
border = "curved",
|
||||
winblend = 0,
|
||||
highlights = {
|
||||
border = "Normal",
|
||||
background = "Normal",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -1,100 +0,0 @@
|
|||
return {
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
build = ":TSUpdate",
|
||||
event = {
|
||||
"BufReadPost",
|
||||
"BufNewFile",
|
||||
},
|
||||
branch = "master",
|
||||
dependencies = {
|
||||
"nvim-treesitter/nvim-treesitter-textobjects",
|
||||
},
|
||||
config = function()
|
||||
local treesitter = require("nvim-treesitter.configs")
|
||||
|
||||
treesitter.setup({
|
||||
-- A list of parser names, or "all"
|
||||
ensure_installed = {
|
||||
"vimdoc",
|
||||
"javascript",
|
||||
"typescript",
|
||||
"c",
|
||||
"lua",
|
||||
"rust",
|
||||
"go",
|
||||
"gosum",
|
||||
"gomod",
|
||||
"php",
|
||||
"blade",
|
||||
},
|
||||
-- Install parsers synchronously (only applied to `ensure_installed`)
|
||||
sync_install = false,
|
||||
-- Automatically install missing parsers when entering buffer
|
||||
auto_install = true,
|
||||
indent = {
|
||||
enable = true,
|
||||
},
|
||||
highlight = {
|
||||
enable = true,
|
||||
additional_vim_regex_highlighting = true,
|
||||
},
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
init_selection = "<leader>c",
|
||||
node_incremental = "<C-p>",
|
||||
scope_incremental = "<C-s>",
|
||||
node_decremental = "<M-p>",
|
||||
},
|
||||
},
|
||||
textobjects = {
|
||||
select = {
|
||||
enable = true,
|
||||
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
|
||||
keymaps = {
|
||||
-- You can use the capture groups defined in textobjects.scm
|
||||
["aa"] = "@parameter.outer",
|
||||
["ia"] = "@parameter.inner",
|
||||
["af"] = "@function.outer",
|
||||
["if"] = "@function.inner",
|
||||
["ac"] = "@class.outer",
|
||||
["ic"] = "@class.inner",
|
||||
},
|
||||
},
|
||||
move = {
|
||||
enable = true,
|
||||
set_jumps = true, -- whether to set jumps in the jumplist
|
||||
goto_next_start = {
|
||||
["]m"] = "@function.outer",
|
||||
["]]"] = "@class.outer",
|
||||
},
|
||||
goto_next_end = {
|
||||
["]M"] = "@function.outer",
|
||||
["]["] = "@class.outer",
|
||||
},
|
||||
goto_previous_start = {
|
||||
["[m"] = "@function.outer",
|
||||
["[["] = "@class.outer",
|
||||
},
|
||||
goto_previous_end = {
|
||||
["[M"] = "@function.outer",
|
||||
["[]"] = "@class.outer",
|
||||
},
|
||||
},
|
||||
swap = {
|
||||
enable = true,
|
||||
swap_next = {
|
||||
["<leader>]"] = "@parameter.inner",
|
||||
},
|
||||
swap_previous = {
|
||||
["<leader>["] = "@parameter.inner",
|
||||
},
|
||||
},
|
||||
},
|
||||
autotag = {
|
||||
enable = false,
|
||||
enable_close_on_slash = false,
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
return {
|
||||
"mbbill/undotree",
|
||||
keys = {
|
||||
{ "<leader>u", "<cmd>UndotreeToggle<CR>", desc = "Toggle Undotree" },
|
||||
},
|
||||
config = function()
|
||||
local has_persistent_undo = vim.api.nvim_call_function("has", { "persistent_undo" })
|
||||
|
||||
if has_persistent_undo then
|
||||
local target_path = vim.api.nvim_call_function("expand", { "~/.undodir" })
|
||||
|
||||
local is_directory = vim.api.nvim_call_function("isdirectory", { target_path })
|
||||
|
||||
if not is_directory then
|
||||
vim.api.nvim_call_function("mkdir", { target_path, "p", 0700 })
|
||||
end
|
||||
|
||||
vim.opt.undodir = target_path
|
||||
vim.opt.undofile = true
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
return {
|
||||
{
|
||||
"folke/which-key.nvim",
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
vim.opt.timeout = true
|
||||
vim.opt.timeoutlen = 300
|
||||
|
||||
local wk = require("which-key")
|
||||
|
||||
wk.setup({
|
||||
delay = 0,
|
||||
icons = {
|
||||
mappings = vim.g.have_nerd_font,
|
||||
keys = vim.g.have_nerd_font and {} or {
|
||||
Up = "<Up> ",
|
||||
Down = "<Down> ",
|
||||
Left = "<Left> ",
|
||||
Right = "<Right> ",
|
||||
C = "<C-…> ",
|
||||
M = "<M-…> ",
|
||||
D = "<D-…> ",
|
||||
S = "<S-…> ",
|
||||
CR = "<CR> ",
|
||||
Esc = "<Esc> ",
|
||||
ScrollWheelDown = "<ScrollWheelDown> ",
|
||||
ScrollWheelUp = "<ScrollWheelUp> ",
|
||||
NL = "<NL> ",
|
||||
BS = "<BS> ",
|
||||
Space = "<Space> ",
|
||||
Tab = "<Tab> ",
|
||||
F1 = "<F1>",
|
||||
F2 = "<F2>",
|
||||
F3 = "<F3>",
|
||||
F4 = "<F4>",
|
||||
F5 = "<F5>",
|
||||
F6 = "<F6>",
|
||||
F7 = "<F7>",
|
||||
F8 = "<F8>",
|
||||
F9 = "<F9>",
|
||||
F10 = "<F10>",
|
||||
F11 = "<F11>",
|
||||
F12 = "<F12>",
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
---@class Utils
|
||||
---@field os juancwu.utils.os
|
||||
local M = setmetatable({}, {
|
||||
__index = function(t, k)
|
||||
t[k] = require("juancwu.utils." .. k)
|
||||
return t[k]
|
||||
end,
|
||||
})
|
||||
|
||||
return M
|
||||
187
nvim/lua/keymaps.lua
Normal file
187
nvim/lua/keymaps.lua
Normal file
|
|
@ -0,0 +1,187 @@
|
|||
-- easy escape
|
||||
vim.keymap.set("i", "<C-[>", "<Esc>", { noremap = true, silent = true })
|
||||
vim.keymap.set("v", "<C-[>", "<Esc>", { noremap = true, silent = true })
|
||||
vim.keymap.set("n", "<C-[>", "<Esc>", { noremap = true, silent = true })
|
||||
|
||||
-- open the explorer
|
||||
vim.keymap.set("n", "<leader>ex", "<cmd>Ex<CR>")
|
||||
|
||||
-- move highlighted lines
|
||||
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
|
||||
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
|
||||
|
||||
-- make cursor stay in same position when appending line below
|
||||
vim.keymap.set("n", "J", "mzJ`z")
|
||||
|
||||
-- make cursor stay in the middle while moving down/up the page
|
||||
vim.keymap.set("n", "<C-d>", "<C-d>zz")
|
||||
vim.keymap.set("n", "<C-u>", "<C-u>zz")
|
||||
|
||||
-- make cursor stay in the middle while looking through search results
|
||||
vim.keymap.set("n", "n", "nzzzv")
|
||||
vim.keymap.set("n", "N", "Nzzzv")
|
||||
|
||||
-- select and replace
|
||||
vim.keymap.set("n", "<leader>ss", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
|
||||
|
||||
-- do not copy with x, for god sake, WHY copy something that is being deleted??
|
||||
vim.keymap.set("n", "x", '"_x')
|
||||
|
||||
-- no copy, delete line, for god sake...
|
||||
vim.keymap.set("n", "dd", '"_dd')
|
||||
vim.keymap.set("n", "dx", "dd") -- cut line, under my control
|
||||
vim.keymap.set("v", "d", '"_d')
|
||||
|
||||
-- copy/paste to/from system clipboard
|
||||
vim.keymap.set({ "n", "v" }, "<leader>y", '"+y')
|
||||
vim.keymap.set({ "n", "v" }, "<leader>p", '"+p')
|
||||
|
||||
-- increment/decrement a count, helpful for changing indeces
|
||||
vim.keymap.set("n", "+", "<C-a>")
|
||||
vim.keymap.set("n", "-", "<C-x>")
|
||||
|
||||
-- do not copy when deleting word
|
||||
vim.keymap.set("n", "dw", '"_dw')
|
||||
vim.keymap.set("n", "db", 'vb"_d') -- delete in backwards
|
||||
|
||||
vim.keymap.set("n", "<C-a>", "gg<S-v>G") -- select all
|
||||
|
||||
-- split pane
|
||||
vim.keymap.set("n", "ss", ":split<Return><C-w>w", { silent = true }) -- horizontal
|
||||
vim.keymap.set("n", "sv", ":vsplit<Return><C-w>w", { silent = true }) -- vertical
|
||||
|
||||
-- pane movement
|
||||
vim.keymap.set("n", "..", "<C-w>w") -- toggle
|
||||
vim.keymap.set("n", "sh", "<C-w>h")
|
||||
vim.keymap.set("n", "sk", "<C-w>k")
|
||||
vim.keymap.set("n", "sl", "<C-w>l")
|
||||
vim.keymap.set("n", "sj", "<C-w>j")
|
||||
|
||||
-- resize pane
|
||||
vim.keymap.set("n", "<C-w><left>", "<C-w>5>")
|
||||
vim.keymap.set("n", "<C-w><right>", "<C-w>5<")
|
||||
vim.keymap.set("n", "<C-w><up>", "<C-w>5+")
|
||||
vim.keymap.set("n", "<C-w><down>", "<C-w>5-")
|
||||
|
||||
-- lazygit on floaterm
|
||||
vim.keymap.set("n", "<leader>lg", function()
|
||||
local Terminal = require("toggleterm.terminal").Terminal
|
||||
local lazygit = Terminal:new({
|
||||
cmd = "lazygit",
|
||||
direction = "float",
|
||||
float_opts = {
|
||||
border = "double",
|
||||
},
|
||||
on_open = function(term)
|
||||
vim.cmd("startinsert!")
|
||||
end,
|
||||
on_close = function(term)
|
||||
vim.cmd("startinsert!")
|
||||
end,
|
||||
})
|
||||
lazygit:toggle()
|
||||
end, { desc = "Open lazygit in a floating window" })
|
||||
|
||||
-- built-in package manager update
|
||||
vim.keymap.set("n", "<leader>pu", "<cmd>lua vim.pack.update()<CR>")
|
||||
|
||||
-- oil.nvim
|
||||
vim.keymap.set("n", "<leader>oo", "<cmd>Oil<CR>")
|
||||
|
||||
-- conform.nvim
|
||||
vim.keymap.set("n", "<leader>ff", "<cmd>lua require('conform').format({ async = true, lsp_format = 'fallback' })<CR>")
|
||||
|
||||
-- telescope
|
||||
local telescope = require("telescope")
|
||||
local builtin = require("telescope.builtin")
|
||||
|
||||
local function get_fd_command()
|
||||
if vim.fn.executable("fd") == 1 then
|
||||
return "fd"
|
||||
elseif vim.fn.executable("fdfind") == 1 then
|
||||
return "fdfind"
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local function telescope_buffer_dir()
|
||||
return vim.fn.expand("%:p:h")
|
||||
end
|
||||
|
||||
-- Builtin pickers
|
||||
vim.keymap.set("n", "<leader>sf", function()
|
||||
local fd_cmd = get_fd_command()
|
||||
local config = {
|
||||
hidden = true,
|
||||
file_ignore_patterns = {
|
||||
"node%_modules/.*",
|
||||
"%.git/.*",
|
||||
"%.rustup/.*",
|
||||
"target/.*",
|
||||
".devbox/.*",
|
||||
".nix/.*",
|
||||
"vendor/.*",
|
||||
"storage/.*",
|
||||
},
|
||||
}
|
||||
|
||||
if fd_cmd then
|
||||
config.find_command = {
|
||||
fd_cmd,
|
||||
"--type",
|
||||
"f",
|
||||
"--color",
|
||||
"never",
|
||||
"--hidden",
|
||||
"--no-ignore",
|
||||
}
|
||||
end
|
||||
|
||||
builtin.find_files(config)
|
||||
end, { desc = "[S]earch [F]iles" })
|
||||
vim.keymap.set("n", "<leader>sh", builtin.help_tags, { desc = "[S]earch [H]elp Tags" })
|
||||
vim.keymap.set("n", "<leader>sb", builtin.buffers, { desc = "[S]earch [B]uffers" })
|
||||
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" })
|
||||
|
||||
-- Git pickers
|
||||
vim.keymap.set("n", "<leader>gf", builtin.git_files, { desc = "Search [G]it [F]iles" })
|
||||
vim.keymap.set("n", "<leader>gs", builtin.git_status, { desc = "List [G]it [S]tatus" })
|
||||
vim.keymap.set("n", "<leader>gh", builtin.git_stash, { desc = "List [G]it [S]tash" })
|
||||
vim.keymap.set("n", "<leader>gbb", builtin.git_branches, { desc = "List [G]it [B]ranches" })
|
||||
vim.keymap.set("n", "<leader>gc", builtin.git_bcommits, { desc = "List Buffer [G]it [C]ommits" })
|
||||
|
||||
-- File Browser Ext
|
||||
vim.keymap.set("n", "<leader>fs", function()
|
||||
telescope.extensions.file_browser.file_browser({
|
||||
path = "%:p:h",
|
||||
cwd = telescope_buffer_dir(),
|
||||
respect_gitignore = false,
|
||||
hidden = true,
|
||||
grouped = true,
|
||||
previewer = false,
|
||||
initial_mode = "normal",
|
||||
layout_config = { height = 40 },
|
||||
})
|
||||
end, { desc = "Open [F]ile [S]ystem Menu" })
|
||||
|
||||
vim.keymap.set("n", "<leader>/", function()
|
||||
builtin.current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({
|
||||
winblend = 10,
|
||||
previewer = false,
|
||||
}))
|
||||
end, { desc = "[/] Fuzzily serach in current buffer" })
|
||||
|
||||
-- live grep in open files only
|
||||
vim.keymap.set("n", "<leader>s/", function()
|
||||
builtin.live_grep({
|
||||
grep_open_files = true,
|
||||
prompt_title = "Live Grep in Open Files",
|
||||
})
|
||||
end, { desc = "[S]search [/] in Open Files" })
|
||||
|
||||
-- shortcut for searching neovim config files
|
||||
vim.keymap.set("n", "<leader>sn", function()
|
||||
builtin.find_files({ cwd = vim.fn.stdpath("config") })
|
||||
end, { desc = "[S]earch [N]eovim files" })
|
||||
89
nvim/lua/lsp.lua
Normal file
89
nvim/lua/lsp.lua
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
-- Workaround for Neovim 0.12 bug: vim/lsp/document_color.lua#get_hex_code
|
||||
-- doesn't clamp lsp.Color channels, so a server returning a channel slightly
|
||||
-- above 1.0 produces a malformed 7-char hex (e.g. "#1006467") and crashes
|
||||
-- get_contrast_color. Clamp channels before the upstream handler runs.
|
||||
do
|
||||
require("vim.lsp.document_color")
|
||||
local Provider = require("vim.lsp._capability").all.document_color
|
||||
local orig_handler = Provider.handler
|
||||
Provider.handler = function(self, err, result, ctx)
|
||||
if type(result) == "table" then
|
||||
for _, res in ipairs(result) do
|
||||
local c = res and res.color
|
||||
if c then
|
||||
c.red = math.max(0, math.min(1, tonumber(c.red) or 0))
|
||||
c.green = math.max(0, math.min(1, tonumber(c.green) or 0))
|
||||
c.blue = math.max(0, math.min(1, tonumber(c.blue) or 0))
|
||||
if c.alpha ~= nil then
|
||||
c.alpha = math.max(0, math.min(1, tonumber(c.alpha) or 0))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return orig_handler(self, err, result, ctx)
|
||||
end
|
||||
end
|
||||
|
||||
vim.lsp.enable({
|
||||
"bashls",
|
||||
"cssls",
|
||||
"css_variables",
|
||||
"gopls",
|
||||
"html",
|
||||
"lua_ls",
|
||||
"rust-analyzer",
|
||||
"tailwindcss",
|
||||
"templ",
|
||||
"ts_ls",
|
||||
})
|
||||
vim.diagnostic.config({ virtual_text = true })
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("juancwu-lsp-attach", { clear = true }),
|
||||
callback = function(event)
|
||||
local map = function(keys, func, desc, mode)
|
||||
mode = mode or "n"
|
||||
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = "LSP: " .. desc })
|
||||
end
|
||||
|
||||
map("gd", vim.lsp.buf.definition, "[G]oto [D]efinition")
|
||||
map("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences")
|
||||
map("gI", vim.lsp.buf.implementation, "[G]oto [I]mplementation")
|
||||
map("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
|
||||
map("<leader>D", vim.lsp.buf.type_definition, "Type [D]efinition")
|
||||
map("<leader>ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols")
|
||||
map("<leader>ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols")
|
||||
map("<leader>rn", vim.lsp.buf.rename, "[R]e[n]ame")
|
||||
map("<leader>ca", vim.lsp.buf.code_action, "[C]ode [A]ction", { "n", "x" })
|
||||
map("[d", function()
|
||||
vim.diagnostic.jump({ count = -1, float = true })
|
||||
end, "Go to previous diagnostic")
|
||||
map("]d", function()
|
||||
vim.diagnostic.jump({ count = 1, float = true })
|
||||
end, "Go to next diagnostic")
|
||||
|
||||
local client = vim.lsp.get_client_by_id(event.data.client_id)
|
||||
if client and client:supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then
|
||||
local highlight_augroup = vim.api.nvim_create_augroup("juancwu-lsp-highlight", { clear = false })
|
||||
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
|
||||
buffer = event.buf,
|
||||
group = highlight_augroup,
|
||||
callback = vim.lsp.buf.document_highlight,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
|
||||
buffer = event.buf,
|
||||
group = highlight_augroup,
|
||||
callback = vim.lsp.buf.clear_references,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("LspDetach", {
|
||||
group = vim.api.nvim_create_augroup("juancwu-lsp-detach", { clear = true }),
|
||||
callback = function(event2)
|
||||
vim.lsp.buf.clear_references()
|
||||
vim.api.nvim_clear_autocmds({ group = "juancwu-lsp-highlight", buffer = event2.buf })
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
|
@ -42,16 +42,6 @@ vim.opt.termguicolors = true -- good shit, just take it
|
|||
-- activate persistent undo
|
||||
vim.opt.undofile = true
|
||||
|
||||
-- highlight on yank
|
||||
local highligh_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true })
|
||||
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||
callback = function()
|
||||
vim.highlight.on_yank()
|
||||
end,
|
||||
group = highligh_group,
|
||||
pattern = "*",
|
||||
})
|
||||
|
||||
vim.opt.completeopt = "menu,menuone,noselect"
|
||||
|
||||
vim.opt.breakindent = true
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
---@class juancwu.utils.os
|
||||
local M = {}
|
||||
|
||||
---@return boolean
|
||||
318
nvim/lua/plugins.lua
Normal file
318
nvim/lua/plugins.lua
Normal file
|
|
@ -0,0 +1,318 @@
|
|||
-- blink blink dependencies
|
||||
vim.pack.add({ { src = "https://github.com/nvim-mini/mini.icons.git" } })
|
||||
require("mini.icons").setup()
|
||||
|
||||
-- mason for easy install of lsp, formatters, etc
|
||||
vim.pack.add({
|
||||
{ src = "https://github.com/mason-org/mason.nvim" },
|
||||
})
|
||||
|
||||
-- mason setup
|
||||
require("mason").setup({})
|
||||
|
||||
-- see git blame, diff in editor
|
||||
vim.pack.add({
|
||||
{ src = "https://github.com/lewis6991/gitsigns.nvim", version = "v2.1.0" },
|
||||
})
|
||||
|
||||
require("gitsigns").setup({
|
||||
current_line_blame = true,
|
||||
current_line_blame_opts = {
|
||||
virt_text = true,
|
||||
virt_text_pos = "eol",
|
||||
delay = 1000,
|
||||
ignore_whitespace = false,
|
||||
},
|
||||
signs = {
|
||||
add = { text = "+" },
|
||||
change = { text = "~" },
|
||||
delete = { text = "_" },
|
||||
topdelete = { text = "-" },
|
||||
changedelete = { text = "~" },
|
||||
},
|
||||
})
|
||||
|
||||
-- autocomplete
|
||||
vim.pack.add({
|
||||
{ src = "https://github.com/saghen/blink.cmp", version = "v1.10.2" },
|
||||
})
|
||||
|
||||
require("blink.cmp").setup({
|
||||
fuzzy = { implementation = "prefer_rust_with_warning" },
|
||||
signature = { enabled = true },
|
||||
keymap = {
|
||||
preset = "default",
|
||||
["<C-y>"] = { "show", "show_documentation", "hide_documentation" },
|
||||
["<C-n>"] = { "select_and_accept" },
|
||||
["<C-k>"] = { "select_prev", "fallback" },
|
||||
["<C-j>"] = { "select_next", "fallback" },
|
||||
["<C-l>"] = { "snippet_forward", "fallback" },
|
||||
["<C-h>"] = { "snippet_backward", "fallback" },
|
||||
-- ["<C-e>"] = { "hide" },
|
||||
},
|
||||
|
||||
appearance = {
|
||||
use_nvim_cmp_as_default = true,
|
||||
nerd_font_variant = "normal",
|
||||
},
|
||||
|
||||
completion = {
|
||||
documentation = {
|
||||
auto_show = true,
|
||||
auto_show_delay_ms = 200,
|
||||
},
|
||||
},
|
||||
|
||||
cmdline = {
|
||||
keymap = {
|
||||
preset = "inherit",
|
||||
["<CR>"] = { "accept_and_enter", "fallback" },
|
||||
},
|
||||
},
|
||||
|
||||
sources = { default = { "lsp" } },
|
||||
})
|
||||
|
||||
-- filesystem navigation
|
||||
vim.pack.add({
|
||||
{ src = "https://github.com/stevearc/oil.nvim.git", version = "v2.15.0" },
|
||||
})
|
||||
|
||||
require("oil").setup({
|
||||
columns = {
|
||||
"icon",
|
||||
},
|
||||
view_options = {
|
||||
show_hidden = true,
|
||||
},
|
||||
})
|
||||
|
||||
-- formatting
|
||||
vim.pack.add({
|
||||
{
|
||||
src = "https://github.com/stevearc/conform.nvim.git",
|
||||
version = "v9.1.0",
|
||||
},
|
||||
})
|
||||
|
||||
local formatters_by_ft = {
|
||||
lua = { "stylua" },
|
||||
javascript = { "biome" },
|
||||
typescript = { "biome" },
|
||||
javascriptreact = { "biome" },
|
||||
typescriptreact = { "biome" },
|
||||
css = { "biome" },
|
||||
markdown = { "biome" },
|
||||
jsonc = { "biome" },
|
||||
json = { "biome" },
|
||||
go = { "gofmt", "goimports" },
|
||||
python = { "autopep8" },
|
||||
yaml = { "yamlfmt" },
|
||||
yml = { "yamlfmt" },
|
||||
zig = { "zigfmt" },
|
||||
rust = { "rustfmt" },
|
||||
templ = { "templ" },
|
||||
php = { "pint" },
|
||||
blade = { "blade-formatter" },
|
||||
}
|
||||
|
||||
require("conform").setup({
|
||||
notify_on_error = false,
|
||||
formatters_by_ft = formatters_by_ft,
|
||||
formatters = {
|
||||
pint = {
|
||||
command = "vendor/bin/pint",
|
||||
args = { "$FILENAME" },
|
||||
stdin = false,
|
||||
},
|
||||
["blade-formatter"] = {
|
||||
command = "blade-formatter",
|
||||
args = {
|
||||
"--write",
|
||||
"--stdin",
|
||||
},
|
||||
},
|
||||
},
|
||||
format_on_save = function(bufnr)
|
||||
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
|
||||
return
|
||||
end
|
||||
return {
|
||||
timeout_ms = 2500,
|
||||
lsp_format = "fallback",
|
||||
}
|
||||
end,
|
||||
})
|
||||
|
||||
-- tree-sitter
|
||||
vim.pack.add({
|
||||
{
|
||||
src = "https://github.com/nvim-treesitter/nvim-treesitter.git",
|
||||
version = "4916d6592ede8c07973490d9322f187e07dfefac",
|
||||
},
|
||||
})
|
||||
vim.pack.add({
|
||||
{
|
||||
src = "https://github.com/nvim-treesitter/nvim-treesitter-textobjects.git",
|
||||
version = "851e865342e5a4cb1ae23d31caf6e991e1c99f1e",
|
||||
},
|
||||
})
|
||||
|
||||
-- floating windows
|
||||
vim.pack.add({
|
||||
{
|
||||
src = "https://github.com/akinsho/toggleterm.nvim.git",
|
||||
version = "v2.13.1",
|
||||
},
|
||||
})
|
||||
|
||||
require("toggleterm").setup({
|
||||
size = 20,
|
||||
open_mapping = [[<c-\>]],
|
||||
hide_numbers = true,
|
||||
shade_filetypes = {},
|
||||
shade_terminals = true,
|
||||
shading_factor = 2,
|
||||
start_in_insert = true,
|
||||
insert_mappings = true,
|
||||
terminal_mappings = true,
|
||||
persist_size = true,
|
||||
persist_mode = true,
|
||||
direction = "float",
|
||||
close_on_exit = true,
|
||||
shell = vim.o.shell,
|
||||
float_opts = {
|
||||
border = "curved",
|
||||
winblend = 0,
|
||||
highlights = {
|
||||
border = "Normal",
|
||||
background = "Normal",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- show indentation group
|
||||
vim.pack.add({
|
||||
{
|
||||
src = "https://github.com/nvim-mini/mini.indentscope.git",
|
||||
version = "v0.17.0",
|
||||
},
|
||||
})
|
||||
|
||||
require("mini.indentscope").setup({
|
||||
symbol = "│",
|
||||
options = { try_as_border = true },
|
||||
})
|
||||
|
||||
-- telescope
|
||||
vim.pack.add({
|
||||
{
|
||||
src = "https://github.com/nvim-lua/plenary.nvim.git",
|
||||
version = "v0.1.4",
|
||||
},
|
||||
})
|
||||
vim.pack.add({
|
||||
{
|
||||
src = "https://github.com/nvim-telescope/telescope.nvim.git",
|
||||
version = "v0.2.2",
|
||||
},
|
||||
})
|
||||
vim.pack.add({
|
||||
{
|
||||
src = "https://github.com/nvim-telescope/telescope-fzf-native.nvim.git",
|
||||
version = "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c",
|
||||
},
|
||||
})
|
||||
vim.pack.add({
|
||||
{
|
||||
src = "https://github.com/nvim-telescope/telescope-file-browser.nvim.git",
|
||||
version = "3610dc7dc91f06aa98b11dca5cc30dfa98626b7e",
|
||||
},
|
||||
})
|
||||
vim.pack.add({
|
||||
{
|
||||
src = "https://github.com/nvim-telescope/telescope-ui-select.nvim.git",
|
||||
version = "6e51d7da30bd139a6950adf2a47fda6df9fa06d2",
|
||||
},
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("PackChanged", {
|
||||
desc = "Build telescope-fzf-native.nvim",
|
||||
callback = function(ev)
|
||||
local data = ev.data
|
||||
if
|
||||
data
|
||||
and data.spec
|
||||
and data.spec.name == "telescope-fzf-native.nvim"
|
||||
and (data.kind == "install" or data.kind == "update")
|
||||
and vim.fn.executable("make") == 1
|
||||
then
|
||||
vim.system({ "make" }, { cwd = data.path }):wait()
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
local telescope = require("telescope")
|
||||
local actions = require("telescope.actions")
|
||||
local fb_actions = telescope.extensions.file_browser.actions
|
||||
|
||||
telescope.setup({
|
||||
defaults = {
|
||||
mappings = {
|
||||
n = {
|
||||
["q"] = actions.close,
|
||||
},
|
||||
},
|
||||
},
|
||||
extensions = {
|
||||
["ui-select"] = {
|
||||
require("telescope.themes").get_dropdown(),
|
||||
},
|
||||
file_browser = {
|
||||
theme = "dropdown",
|
||||
hijack_netrw = false,
|
||||
hidden = true,
|
||||
mappings = {
|
||||
["i"] = {
|
||||
["<C-w>"] = function()
|
||||
vim.cmd("normal vbd")
|
||||
end,
|
||||
["<C-j>"] = function(bufnr)
|
||||
actions.move_selection_next(bufnr)
|
||||
end,
|
||||
["<C-k>"] = function(bufnr)
|
||||
actions.move_selection_previous(bufnr)
|
||||
end,
|
||||
["<C-s>"] = function(bufnr)
|
||||
actions.select_vertical(bufnr)
|
||||
end,
|
||||
},
|
||||
["n"] = {
|
||||
["a"] = fb_actions.create,
|
||||
["h"] = fb_actions.goto_parent_dir,
|
||||
["/"] = function()
|
||||
vim.cmd("startinsert")
|
||||
end,
|
||||
["d"] = fb_actions.remove,
|
||||
["e"] = fb_actions.change_cwd,
|
||||
["<C-s>"] = function(bufnr)
|
||||
actions.select_vertical(bufnr)
|
||||
end,
|
||||
["<C-a>"] = function(bufnr)
|
||||
actions.toggle_all(bufnr)
|
||||
end,
|
||||
["<C-d>"] = function(bufnr)
|
||||
actions.move_selection_next(bufnr)
|
||||
end,
|
||||
["<C-u>"] = function(bufnr)
|
||||
actions.move_selection_previous(bufnr)
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
pcall(telescope.load_extension, "file_browser")
|
||||
pcall(telescope.load_extension, "fzf")
|
||||
pcall(telescope.load_extension, "ui-select")
|
||||
47
nvim/lua/treesitter.lua
Normal file
47
nvim/lua/treesitter.lua
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
local treesitter = require("nvim-treesitter")
|
||||
|
||||
treesitter.setup({
|
||||
install_dir = vim.fn.stdpath("data") .. "/site",
|
||||
autotag = {
|
||||
enable = false,
|
||||
enable_close_on_slash = false,
|
||||
},
|
||||
})
|
||||
|
||||
-- Install parsers
|
||||
local ensured_installed = {
|
||||
"go",
|
||||
"gosum",
|
||||
"gomod",
|
||||
"rust",
|
||||
"c",
|
||||
"php",
|
||||
"blade",
|
||||
"javascript",
|
||||
"typescript",
|
||||
"lua",
|
||||
"templ",
|
||||
}
|
||||
local already_installed = treesitter.get_installed()
|
||||
local parsers_to_install = vim.iter(ensured_installed)
|
||||
:filter(function(parser)
|
||||
return not vim.tbl_contains(already_installed, parser)
|
||||
end)
|
||||
:totable()
|
||||
treesitter.install(parsers_to_install)
|
||||
|
||||
-- highlighting and indentation
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
callback = function()
|
||||
-- Enable treesitter highlighting and disable regex syntax
|
||||
pcall(vim.treesitter.start)
|
||||
-- Enable treesitter-based indentation
|
||||
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
|
||||
end,
|
||||
})
|
||||
|
||||
-- textobjects
|
||||
-- Disable entire built-in ftplugin mappings to avoid conflicts.
|
||||
-- See https://github.com/neovim/neovim/tree/master/runtime/ftplugin for built-in ftplugins.
|
||||
vim.g.no_plugin_maps = true
|
||||
require("nvim-treesitter-textobjects").setup({})
|
||||
Loading…
Add table
Add a link
Reference in a new issue