updated nvim config

This commit is contained in:
Lucas Barbieri 2023-01-16 14:33:49 -03:00
parent 8b57b65974
commit 8b7a1cf657
9 changed files with 151 additions and 101 deletions

View File

@ -1,28 +1,30 @@
-- -- -- Setup nvim-cmp. -- -- import nvim-autopairs safely
-- local status_ok, npairs = pcall(require, "nvim-autopairs") -- local autopairs_setup, autopairs = pcall(require, "nvim-autopairs")
-- if not status_ok then -- if not autopairs_setup then
-- return -- return
-- end -- end
-- --
-- npairs.setup({ -- -- configure autopairs
-- check_ts = true, -- treesitter integration -- autopairs.setup({
-- disable_filetype = { "TelescopePrompt" }, -- check_ts = true, -- enable treesitter
-- ts_config = { -- ts_config = {
-- lua = { "string", "source" }, -- lua = { "string" }, -- don't add pairs in lua string treesitter nodes
-- javascript = { "string", "template_string" }, -- javascript = { "template_string" }, -- don't add pairs in javscript template_string treesitter nodes
-- java = false, -- java = false, -- don't check treesitter on java
-- }, -- },
--
-- fast_wrap = {
-- map = "<M-e>",
-- chars = { "{", "[", "(", '"', "'" },
-- pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""),
-- offset = 0, -- Offset from pattern match
-- end_key = "$",
-- keys = "qwertyuiopzxcvbnmasdfghjkl",
-- check_comma = true,
-- highlight = "PmenuSel",
-- highlight_grey = "LineNr",
-- },
-- }) -- })
-- --
-- -- import nvim-autopairs completion functionality safely
-- local cmp_autopairs_setup, cmp_autopairs = pcall(require, "nvim-autopairs.completion.cmp")
-- if not cmp_autopairs_setup then
-- return
-- end
--
-- -- import nvim-cmp plugin safely (completions plugin)
-- local cmp_setup, cmp = pcall(require, "cmp")
-- if not cmp_setup then
-- return
-- end
--
-- -- make autopairs and completion work together
-- cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())

View File

@ -6,7 +6,7 @@ vim.keymap.set("n", "<leader>a", mark.add_file)
vim.keymap.set("n", "<C-e>", ui.toggle_quick_menu) vim.keymap.set("n", "<C-e>", ui.toggle_quick_menu)
vim.keymap.set("n", "<C-h>", function() ui.nav_file(1) end) vim.keymap.set("n", "<C-m>", function() ui.nav_file(1) end)
vim.keymap.set("n", "<C-t>", function() ui.nav_file(2) end) vim.keymap.set("n", "<C-t>", function() ui.nav_file(2) end)
vim.keymap.set("n", "<C-n>", function() ui.nav_file(3) end) vim.keymap.set("n", "<C-n>", function() ui.nav_file(3) end)
vim.keymap.set("n", "<C-s>", function() ui.nav_file(4) end) vim.keymap.set("n", "<C-s>", function() ui.nav_file(4) end)

View File

@ -28,7 +28,7 @@ local cmp_select = { behavior = cmp.SelectBehavior.Select }
local cmp_mappings = lsp.defaults.cmp_mappings({ local cmp_mappings = lsp.defaults.cmp_mappings({
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select), ['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
['<C-n>'] = cmp.mapping.select_next_item(cmp_select), ['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
['<C-y>'] = cmp.mapping.confirm({ select = true }), ['<CR>'] = cmp.mapping.confirm({ select = true }),
["<C-Space>"] = cmp.mapping.complete(), ["<C-Space>"] = cmp.mapping.complete(),
}) })
@ -73,6 +73,15 @@ lsp.on_attach(function(client, bufnr)
vim.keymap.set("i", "<C-h>", vim.lsp.buf.signature_help, opts) vim.keymap.set("i", "<C-h>", vim.lsp.buf.signature_help, opts)
end) end)
-- local cmp_autopairs_setup, cmp_autopairs = pcall(require, "nvim-autopairs.completion.cmp")
-- if not cmp_autopairs_setup then
-- return
-- end
--
-- cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
require("luasnip.loaders.from_vscode").lazy_load()
lsp.setup() lsp.setup()
vim.diagnostic.config({ vim.diagnostic.config({

View File

@ -0,0 +1,3 @@
require'nvim-tmux-navigation'.setup {
disable_when_zoomed = true -- defaults to false
}

View File

@ -1,21 +1,20 @@
require("nvim-tree").setup({ -- require("nvim-tree").setup({
sort_by = "case_sensitive", -- sort_by = "case_sensitive",
view = { -- -- view = {
adaptive_size = true, -- -- adaptive_size = true,
prefer_startup_root = true, -- -- prefer_startup_root = true,
update_focused_file = { -- -- update_focused_file = {
{ update_root = true }, -- -- { update_root = true },
}, -- -- },
mappings = { -- -- mappings = {
list = { -- -- list = {
{ key = "u", action = "dir_up" }, -- -- { key = "u", action = "dir_up" },
}, -- -- },
}, -- -- },
}, -- renderer = {
renderer = { -- group_empty = true,
group_empty = true, -- },
}, -- filters = {
filters = { -- dotfiles = true,
dotfiles = true, -- },
}, -- })
})

View File

@ -1,25 +1,38 @@
require'nvim-treesitter.configs'.setup { require 'nvim-treesitter.configs'.setup {
-- A list of parser names, or "all" -- A list of parser names, or "all"
ensure_installed = { "help", "python", "javascript", "c", "lua", "rust", "bash" }, ensure_installed = {
"help",
"python",
"javascript",
"c",
"lua",
"rust",
"bash",
"gitignore",
"vim",
"markdown",
"html",
"css",
},
-- Install parsers synchronously (only applied to `ensure_installed`) -- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false, sync_install = true,
-- Automatically install missing parsers when entering buffer -- Automatically install missing parsers when entering buffer
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = true, auto_install = true,
highlight = { highlight = {
-- `false` will disable the whole extension -- `false` will disable the whole extension
enable = true, enable = true,
-- Setting this to true will run `:h syntax` and tree-sitter at the same time. -- 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). -- 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. -- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages -- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false, additional_vim_regex_highlighting = false,
}, },
autotag = { autotag = {
enable = true, enable = true,
}, },
} }

View File

@ -80,7 +80,6 @@ return require('packer').startup(function(use)
use 'xiyaowong/nvim-transparent' use 'xiyaowong/nvim-transparent'
-- use { -- use {
-- "windwp/nvim-autopairs", -- "windwp/nvim-autopairs",
-- config = function() require("nvim-autopairs").setup ({}) end
-- } -- }
use({ use({
'nyoom-engineering/oxocarbon.nvim', 'nyoom-engineering/oxocarbon.nvim',
@ -124,11 +123,18 @@ return require('packer').startup(function(use)
end end
}) })
use { "alexghergh/nvim-tmux-navigation" }
use 'windwp/nvim-ts-autotag' use 'windwp/nvim-ts-autotag'
use 'norcalli/nvim-colorizer.lua' use 'norcalli/nvim-colorizer.lua'
use 'ThePrimeagen/vim-be-good' use 'ThePrimeagen/vim-be-good'
use 'declancm/maximize.nvim'
use({"L3MON4D3/LuaSnip", tag = "v<CurrentMajor>.*"})
use "rafamadriz/friendly-snippets"
if packer_bootstrap then if packer_bootstrap then
require('packer').sync() require('packer').sync()
end end

View File

@ -1,38 +1,53 @@
vim.keymap.set("n", "<leader>pv", vim.cmd.Ex) local keymap = vim.keymap
vim.keymap.set("i", "jk", "<Esc>") local nvim_tmux_nav = require('nvim-tmux-navigation')
keymap.set("n", "<leader>pv", vim.cmd.Ex)
keymap.set("i", "jk", "<Esc>")
vim.g.mapleader = " " vim.g.mapleader = " "
vim.keymap.set("n", "<leader>pv", vim.cmd.Ex) keymap.set("n", "<leader>pv", vim.cmd.Ex)
vim.keymap.set("n", "<leader>e", vim.cmd.NvimTreeToggle) -- keymap.set("n", "<leader>e", vim.cmd.NreeToggle)
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv") keymap.set("v", "J", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv") keymap.set("v", "K", ":m '<-2<CR>gv=gv")
vim.keymap.set("n", "J", "mzJ`z") keymap.set("n", "J", "mzJ`z")
vim.keymap.set("n", "<C-d>", "<C-d>zz") keymap.set("n", "<C-d>", "<C-d>zz")
vim.keymap.set("n", "<C-u>", "<C-u>zz") keymap.set("n", "<C-u>", "<C-u>zz")
vim.keymap.set("n", "n", "nzzzv") keymap.set("n", "n", "nzzzv")
vim.keymap.set("n", "N", "Nzzzv") keymap.set("n", "N", "Nzzzv")
vim.keymap.set("x", "<leader>p", [["_dP]]) keymap.set("x", "<leader>p", [["_dP]])
vim.keymap.set({ "n", "v" }, "<leader>y", [["+y]]) keymap.set({ "n", "v" }, "<leader>y", [["+y]])
vim.keymap.set("n", "<leader>Y", [["+Y]]) keymap.set("n", "<leader>Y", [["+Y]])
vim.keymap.set({ "n", "v" }, "<leader>d", [["_d]]) keymap.set({ "n", "v" }, "<leader>d", [["_d]])
vim.keymap.set("i", "<C-c>", "<Esc>") keymap.set("i", "<C-c>", "<Esc>")
vim.keymap.set("n", "Q", "<nop>") keymap.set("n", "Q", "<nop>")
vim.keymap.set("n", "<C-f>", "<cmd>silent !tmux neww tmux-sessionizer<CR>") keymap.set("n", "<C-f>", "<cmd>silent !tmux neww tmux-sessionizer<CR>")
vim.keymap.set("n", "<leader>f", vim.lsp.buf.format) keymap.set("n", "<leader>f", vim.lsp.buf.format)
vim.keymap.set("n", "<C-k>", "<cmd>cnext<CR>zz") keymap.set("n", "<A-k>", "<cmd>cnext<CR>zz")
vim.keymap.set("n", "<C-j>", "<cmd>cprev<CR>zz") keymap.set("n", "<A-j>", "<cmd>cprev<CR>zz")
vim.keymap.set("n", "<leader>k", "<cmd>lnext<CR>zz") keymap.set("n", "<leader>k", "<cmd>lnext<CR>zz")
vim.keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz") keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz")
vim.keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]]) keymap.set("n", "<leader>r", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
vim.keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", { silent = true }) keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", { silent = true })
vim.keymap.set("t", "<leader><Esc>", [[<C-\><C-n>]]) keymap.set("t", "<leader><Esc>", [[<C-\><C-n>]])
keymap.set("n", "<leader>sv", "<C-w>v")
keymap.set("n", "<leader>sh", "<C-w>s")
keymap.set("n", "<leader>se", "<C-w>=")
keymap.set("n", "<leader>sx", ":close<CR>")
keymap.set('n', "<C-h>", nvim_tmux_nav.NvimTmuxNavigateLeft)
keymap.set('n', "<C-j>", nvim_tmux_nav.NvimTmuxNavigateDown)
keymap.set('n', "<C-k>", nvim_tmux_nav.NvimTmuxNavigateUp)
keymap.set('n', "<C-l>", nvim_tmux_nav.NvimTmuxNavigateRight)
keymap.set('n', "<C-\\>", nvim_tmux_nav.NvimTmuxNavigateLastActive)
keymap.set('n', "<C-Space>", nvim_tmux_nav.NvimTmuxNavigateNext)
keymap.set('n', '<Leader>sm', "<Cmd>lua require('maximize').toggle()<CR>")
vim.keymap.set("n", "<C-f>", "ysst")
vim.keymap.set("v", "<C-f>", "gSt")

View File

@ -4,7 +4,7 @@ vim.opt.mouse = 'a'
vim.opt.nu = true vim.opt.nu = true
vim.opt.relativenumber = true vim.opt.relativenumber = true
vim.opt.clipboard:append { 'unnamedplus' } vim.opt.clipboard:append {'unnamedplus'}
vim.opt.tabstop = 4 vim.opt.tabstop = 4
vim.opt.softtabstop = 4 vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4 vim.opt.shiftwidth = 4
@ -22,7 +22,6 @@ vim.opt.undofile = true
vim.opt.hlsearch = false vim.opt.hlsearch = false
vim.opt.incsearch = true vim.opt.incsearch = true
vim.opt.termguicolors = true
vim.opt.scrolloff = 8 vim.opt.scrolloff = 8
vim.opt.signcolumn = "yes" vim.opt.signcolumn = "yes"
@ -38,6 +37,10 @@ vim.g.mapleader = " "
-- vim.g.loaded_netrwPlugin = 1 -- vim.g.loaded_netrwPlugin = 1
-- Case insensitive searching UNLESS /C or capital in search -- Case insensitive searching UNLESS /C or capital in search
vim.o.ignorecase = true vim.opt.ignorecase = true
vim.o.completeopt = 'menuone,noselect' vim.opt.completeopt = 'menuone,noselect'
vim.o.smartcase = true vim.opt.smartcase = true
vim.opt.splitright = true
vim.opt.splitbelow = true
vim.opt.termguicolors = true