diff --git a/.config/nvim/after/plugin/autoclose.lua b/.config/nvim/after/plugin/autoclose.lua deleted file mode 100644 index a6f1af1..0000000 --- a/.config/nvim/after/plugin/autoclose.lua +++ /dev/null @@ -1,24 +0,0 @@ -require("autoclose").setup({ - keys = { - ["("] = { escape = false, close = true, pair = "()", disabled_filetypes = {} }, - ["["] = { escape = false, close = true, pair = "[]", disabled_filetypes = {} }, - ["{"] = { escape = false, close = true, pair = "{}", disabled_filetypes = {} }, - - [">"] = { escape = true, close = false, pair = "<>", disabled_filetypes = {} }, - [")"] = { escape = true, close = false, pair = "()", disabled_filetypes = {} }, - ["]"] = { escape = true, close = false, pair = "[]", disabled_filetypes = {} }, - ["}"] = { escape = true, close = false, pair = "{}", disabled_filetypes = {} }, - - ['"'] = { escape = true, close = true, pair = '""', disabled_filetypes = {"markdown", "gitcommit", "tex", "asciidoc"} }, - ["'"] = { escape = true, close = true, pair = "''", disabled_filetypes = {"markdown", "gitcommit", "tex", "asciidoc"} }, - ["`"] = { escape = true, close = true, pair = "``", disabled_filetypes = {"markdown", "gitcommit", "tex", "asciidoc"} }, - - ["$"] = { escape = true, close = true, pair = "$$", enabled_filetypes = {"tex"} }, - }, - options = { - disabled_filetypes = { "text" }, - disable_when_touch = false, - pair_spaces = false, - auto_indent = true, - }, -}) diff --git a/.config/nvim/after/plugin/autopairs.lua b/.config/nvim/after/plugin/autopairs.lua new file mode 100644 index 0000000..fa18116 --- /dev/null +++ b/.config/nvim/after/plugin/autopairs.lua @@ -0,0 +1,54 @@ +local autopairs = require('nvim-autopairs') +local Rule = require('nvim-autopairs.rule') +local cond = require('nvim-autopairs.conds') + +autopairs.setup({ + { + enabled = function(bufnr) return true end, -- control if auto-pairs should be enabled when attaching to a buffer + disable_filetype = { "TelescopePrompt", "spectre_panel", "snacks_picker_input" }, + disable_in_macro = true, -- disable when recording or executing a macro + disable_in_visualblock = false, -- disable when insert after visual block mode + disable_in_replace_mode = true, + ignored_next_char = [=[[%w%%%'%[%"%.%`%$]]=], + enable_moveright = true, + enable_afterquote = true, -- add bracket pairs after quote + enable_check_bracket_line = false, --- check bracket in same line + enable_bracket_in_quote = true, -- + enable_abbr = false, -- trigger abbreviation + break_undo = true, -- switch for basic rule break undo sequence + check_ts = false, + map_cr = true, + map_bs = true, -- map the key + map_c_h = false, -- Map the key to delete a pair + map_c_w = true, -- map to delete a pair if possible + } +}) + +autopairs.add_rules({ + Rule("$", "$",{"tex", "latex"}) + -- don't add a pair if the next character is % + :with_pair(cond.not_after_regex("%%")) + -- don't add a pair if the previous character is xxx + :with_pair(cond.not_before_regex("xxx", 3)) + -- don't move right when repeat character + :with_move(cond.none()) + -- don't delete if the next character is xx + :with_del(cond.not_after_regex("xx")) + -- disable adding a newline when you press + :with_cr(cond.none()) + }, + -- disable for .vim files, but it work for another filetypes + Rule("a","a","-vim") +) + +autopairs.add_rules({ + Rule("$$","$$","tex") + :with_pair(function(opts) + print(vim.inspect(opts)) + if opts.line=="aa $$" then + -- don't add pair on that line + return false + end + end) + } +) diff --git a/.config/nvim/after/plugin/autotag.lua b/.config/nvim/after/plugin/autotag.lua new file mode 100644 index 0000000..54fde75 --- /dev/null +++ b/.config/nvim/after/plugin/autotag.lua @@ -0,0 +1,7 @@ +require('nvim-ts-autotag').setup({ + opts = { + enable_close = true, -- Auto close tags + enable_rename = true, -- Auto rename pairs of tags + enable_close_on_slash = true -- Auto close on trailing '] = cmp.mapping.select_prev_item(cmp_select), @@ -47,7 +53,7 @@ lsp.set_preferences({ } }) -lsp.on_attach(function(client, bufnr) +lsp.on_attach(function(_, bufnr) local opts = { buffer = bufnr, remap = false } vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts) diff --git a/.config/nvim/after/plugin/mason.lua b/.config/nvim/after/plugin/mason.lua new file mode 100644 index 0000000..2326ffa --- /dev/null +++ b/.config/nvim/after/plugin/mason.lua @@ -0,0 +1,17 @@ +require("mason-lspconfig").setup { + ensure_installed = { + "ansiblels", + "ast_grep", + "bashls", + "clangd", + "cmake", + "docker_compose_language_service", + "dockerls", + "jsonls", + "jdtls", + "lua_ls", + "pyright", + "ts_ls" + }, + automatic_installation = false, +} diff --git a/.config/nvim/after/plugin/treesitter.lua b/.config/nvim/after/plugin/treesitter.lua index e734201..653cb76 100644 --- a/.config/nvim/after/plugin/treesitter.lua +++ b/.config/nvim/after/plugin/treesitter.lua @@ -1,9 +1,6 @@ require 'nvim-treesitter.configs'.setup { -- A list of parser names, or "all" (the five listed parsers should always be installed) - ensure_installed = { "bash", "lua", "vim", "regex", "c", "c_sharp", - "python", "html", "css", "php", "javascript", "typescript", "sql" - }, - + ensure_installed = { "c", "cpp", "lua", "vim", "vimdoc", "query", "markdown", "markdown_inline" }, -- Install parsers synchronously (only applied to `ensure_installed`) sync_install = true, @@ -15,6 +12,21 @@ require 'nvim-treesitter.configs'.setup { highlight = { enable = true, + disable = function(lang, buf) + local max_filesize = 100 * 1024 -- 100 KB + local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) + if ok and stats and stats.size > max_filesize then + return true + end + local disabled_langs = { "latex" } + for _, l in ipairs(disabled_langs) do + if l == lang then + return true + end + end + return false + end, + -- Setting this to true will run `:h syntax` and tree-sitter at the same time. -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). -- Using this option may slow down your editor, and you may see some duplicate highlights. diff --git a/.config/nvim/lua/tiagorg/packer.lua b/.config/nvim/lua/tiagorg/packer.lua index 7e047ae..02d1553 100644 --- a/.config/nvim/lua/tiagorg/packer.lua +++ b/.config/nvim/lua/tiagorg/packer.lua @@ -47,7 +47,8 @@ return require('packer').startup(function(use) use "folke/trouble.nvim" use "stevearc/aerial.nvim" use 'numToStr/Comment.nvim' - use 'm4xshen/autoclose.nvim' + use 'windwp/nvim-autopairs' + use 'windwp/nvim-ts-autotag' use({ "kylechui/nvim-surround", tag = "*", -- Use for stability; omit to use `main` branch for the latest features diff --git a/.config/nvim/lua/tiagorg/remap.lua b/.config/nvim/lua/tiagorg/remap.lua index ff60ec5..a233819 100644 --- a/.config/nvim/lua/tiagorg/remap.lua +++ b/.config/nvim/lua/tiagorg/remap.lua @@ -1,6 +1,7 @@ vim.keymap.set("n", "w", vim.cmd.w) vim.keymap.set({ "n", "i" }, "", vim.cmd.w) --vim.keymap.set("n", "e", vim.cmd.E) +vim.keymap.set("i", "", "") vim.keymap.set("v", "J", ":m '>+1gv=gv") vim.keymap.set("v", "K", ":m '<-2gv=gv")