nvim changes
Signed-off-by: Tiago Garcia <tiago.rgarcia@ua.pt>
This commit is contained in:
parent
df1dce2334
commit
b12665989e
|
|
@ -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,
|
||||
},
|
||||
})
|
||||
|
|
@ -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 <BS> key
|
||||
map_c_h = false, -- Map the <C-h> key to delete a pair
|
||||
map_c_w = true, -- map <c-w> 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 <cr>
|
||||
: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)
|
||||
}
|
||||
)
|
||||
|
|
@ -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 </
|
||||
},
|
||||
})
|
||||
|
|
@ -9,7 +9,13 @@ lsp.preset("recommended")
|
|||
lsp.nvim_workspace()
|
||||
|
||||
local luasnip = require("luasnip")
|
||||
-- If you want insert `(` after select function or method item
|
||||
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
|
||||
local cmp = require('cmp')
|
||||
cmp.event:on(
|
||||
'confirm_done',
|
||||
cmp_autopairs.on_confirm_done()
|
||||
)
|
||||
local cmp_select = { behavior = cmp.SelectBehavior.Select }
|
||||
local cmp_mappings = lsp.defaults.cmp_mappings({
|
||||
['<C-p>'] = 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)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
vim.keymap.set("n", "<leader>w", vim.cmd.w)
|
||||
vim.keymap.set({ "n", "i" }, "<C-S>", vim.cmd.w)
|
||||
--vim.keymap.set("n", "<leader>e", vim.cmd.E)
|
||||
vim.keymap.set("i", "<C-BS>", "<C-w>")
|
||||
|
||||
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
|
||||
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
|
||||
|
|
|
|||
Loading…
Reference in New Issue