Cleanup nvim config

This commit is contained in:
Alexander Navarro 2023-10-26 09:12:49 -03:00
parent 33cce48101
commit d9e2c81e42
16 changed files with 174 additions and 488 deletions

View file

@ -9,12 +9,11 @@ return { -- Change colors.none if not using a transparent background
cmp = true,
indent_blankline = {
enabled = true,
scope_color = "lavender", -- catppuccin color (eg. `lavender`) Default: text
colored_indent_levels = true,
},
},
custom_highlights = function(colors)
return {
-- Fix colors for cmp
Pmenu = { bg = colors.none, blend = 0 },
FloatBorder = { bg = colors.none },
CmpItemMenu = { fg = colors.text, bg = colors.none },

View file

@ -3,20 +3,21 @@ return {
"echasnovski/mini.comment",
version = "*",
event = "VeryLazy",
depends = {
{ "nvim-treesitter/nvim-treesitter-context" },
},
opts = {
options = {
custom_commentstring = function()
return require("ts_context_commentstring.internal").calculate_commentstring()
or vim.bo.commentstring
or vim.bo.commentstring
end,
},
},
},
{
"LudoPinelli/comment-box.nvim",
-- init = nil,
event = "VeryLazy",
-- opts = {},
config = function()
require("comment-box").setup({
outer_blank_lines = true,
@ -25,9 +26,9 @@ return {
local cb = require("comment-box")
-- left aligned fixed size box with left aligned text
MAP({ "n", "v" }, "<Leader>cb", cb.lcbox, "Create a comment box")
MAP({ "n", "v" }, "gcb", cb.lcbox, "Create a comment box")
-- centered adapted box with centered text
MAP({ "n", "v" }, "<Leader>cl", cb.cline, "Create a comment line")
MAP({ "n", "v" }, "gcl", cb.cline, "Create a comment line")
end,
},
}

View file

@ -15,6 +15,7 @@ return {
local window_opts = {
border = "rounded",
side_padding = 1,
-- fix colors for catppuccin colorscheme
winhighlight = "Normal:Pmenu,FloatBorder:FloatBorder,CursorLine:PmenuSel,Search:None",
}
return {
@ -35,6 +36,7 @@ return {
["<C-d>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
["<BR>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
["<S-CR>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,

View file

@ -18,8 +18,8 @@ return {
dashboard.section.buttons.val = {
dashboard.button("LDR f f", " Find File ", "<leader>ff"),
dashboard.button("LDR e", "פּ File Explorer ", "<leader>fe"),
dashboard.button("LDR LDR t", " Harpoon", "<leader><leader>t"),
dashboard.button("LDR g g", " Git ", "<leader>gg"),
}
dashboard.section.footer.val =

View file

@ -1,9 +1,10 @@
return {
"stevearc/dressing.nvim",
opts = {
input = {
-- handle by noice
enabled = false,
},
},
-- better imputs
"stevearc/dressing.nvim",
opts = {
input = {
-- handle by noice
enabled = false,
},
},
}

View file

@ -1,6 +1,9 @@
return {
"stevearc/conform.nvim",
event = "VeryLazy",
opts = {
-- See aviable formatters in: https://github.com/stevearc/conform.nvim#formatters
-- Formatters can be installed by mason
formatters_by_ft = {
-- Conform will run multiple formatters sequentially
lua = { "stylua" },
@ -14,9 +17,27 @@ return {
-- have other formatters configured.
["_"] = { "trim_whitespace" },
},
format_on_save = {
timeout_ms = 500,
lsp_fallback = true,
},
format_on_save = function(bufnr)
-- Disable with a global or buffer-local variable
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
return { timeout_ms = 500, lsp_fallback = true }
end,
},
config = function(_, opts)
require("conform").setup(opts)
local function toggleAutoFormat()
-- to make this global, change b to g
if vim.b.disable_autoformat == nil then
vim.b.disable_autoformat = true
return
end
vim.b.disable_autoformat = not vim.b.disable_autoformat
end
MAP("n", "<leader>uf", toggleAutoFormat, "Toggle auto format")
end,
}

View file

@ -1,23 +1,23 @@
return {
{
"lewis6991/gitsigns.nvim",
event = { "BufReadPre", "BufNewFile" },
opts = {
-- See `:help gitsigns.txt`
signs = {
add = { text = "" },
change = { text = "" },
delete = { text = "" },
topdelete = { text = "" },
changedelete = { text = "" },
untracked = { text = "" },
},
on_attach = function(buffer)
local gs = package.loaded.gitsigns
{
"lewis6991/gitsigns.nvim",
event = { "BufReadPre", "BufNewFile" },
opts = {
-- See `:help gitsigns.txt`
signs = {
add = { text = "" },
change = { text = "" },
delete = { text = "" },
topdelete = { text = "" },
changedelete = { text = "" },
untracked = { text = "" },
},
on_attach = function(buffer)
local gs = package.loaded.gitsigns
local function map(mode, l, r, desc)
vim.keymap.set(mode, "<leader>g" .. l, r, { buffer = buffer, desc = desc })
end
local function map(mode, l, r, desc)
vim.keymap.set(mode, "<leader>g" .. l, r, { buffer = buffer, desc = desc })
end
-- stylua: ignore start
map("n", "j", gs.next_hunk, "Next Hunk")
@ -27,59 +27,59 @@ return {
map("n", "u", gs.undo_stage_hunk, "Undo Stage Hunk")
map("n", "R", gs.reset_buffer, "Reset Buffer")
map("n", "p", gs.preview_hunk, "Preview Hunk")
map("n", "l", function() gs.blame_line({ full = true }) end, "Blame Line")
map("n", "l", function() gs.blame_line() end, "Blame Line")
map("n", "d", gs.diffthis, "Diff This")
map("n", "D", function() gs.diffthis("~") end, "Diff This ~")
end,
},
},
end,
},
},
-- Testing main Git plugin
-- Testing main Git plugin
{
"tpope/vim-fugitive",
event = "VeryLazy",
keys = {
{ "<leader>gG", ":Git<CR>", { desc = "Fugitive" } },
},
},
{
"tpope/vim-fugitive",
event = "VeryLazy",
keys = {
{ "<leader>gG", ":Git<CR>", desc = "Fugitive" },
},
},
{
"kdheepak/lazygit.nvim",
event = "VeryLazy",
dependencies = {
"nvim-lua/plenary.nvim",
},
keys = {
{ "<leader>gL", ":LazyGit<CR>", { desc = "Lazygit" } },
},
},
{
"kdheepak/lazygit.nvim",
event = "VeryLazy",
dependencies = {
"nvim-lua/plenary.nvim",
},
keys = {
{ "<leader>gL", ":LazyGit<CR>", desc = "Lazygit" },
},
},
{
"NeogitOrg/neogit",
dependencies = {
"nvim-lua/plenary.nvim", -- required
"nvim-telescope/telescope.nvim", -- optional
"sindrets/diffview.nvim", -- optional
"ibhagwan/fzf-lua", -- optional
},
config = true,
opts = {
disable_insert_on_commit = "auto",
kind = "replace",
disable_line_numbers = false,
commit_editor = {
kind = "replace",
},
},
keys = {
{
"<leader>gg",
function()
require("neogit").open()
end,
{ desc = "Neogit" },
},
},
},
{
"NeogitOrg/neogit",
dependencies = {
"nvim-lua/plenary.nvim", -- required
"nvim-telescope/telescope.nvim", -- optional
"sindrets/diffview.nvim", -- optional
"ibhagwan/fzf-lua", -- optional
},
config = true,
opts = {
disable_insert_on_commit = "auto",
kind = "replace",
disable_line_numbers = false,
commit_editor = {
kind = "replace",
},
},
keys = {
{
"<leader>gg",
function()
require("neogit").open()
end,
desc = "Neogit",
},
},
},
}

View file

@ -46,17 +46,18 @@ return {
miniclue.gen_clues.windows(),
miniclue.gen_clues.z(),
{ mode = "n", keys = "<Leader>b", desc = "+Buffers" },
{ mode = "n", keys = "<Leader>c", desc = "+Comments" },
{ mode = "n", keys = "<Leader>bh", postkeys = "<Leader>b" },
{ mode = "n", keys = "<Leader>bl", postkeys = "<Leader>b" },
{ mode = "n", keys = "<Leader>l", desc = "+LSP" },
{ mode = "n", keys = "<Leader>f", desc = "+Find" },
{ mode = "n", keys = "<Leader>g", desc = "+Git" },
{ mode = "n", keys = "<Leader>w", desc = "+Workspace" },
{ mode = "n", keys = "<Leader>u", desc = "+UI" },
{ mode = "n", keys = "<Leader>un", desc = "+Noice" },
{ mode = "n", keys = "<Leader><Leader>", desc = "+Harpoon" },
{ mode = "n", keys = "<Leader>b", desc = "+Buffers" },
{ mode = "n", keys = "<Leader>bh", postkeys = "<Leader>b" },
{ mode = "n", keys = "<Leader>bl", postkeys = "<Leader>b" },
{ mode = "n", keys = "<Leader>c", desc = "+Comments" },
{ mode = "n", keys = "<Leader>f", desc = "+Find" },
{ mode = "n", keys = "<Leader>g", desc = "+Git" },
{ mode = "n", keys = "<Leader>l", desc = "+LSP" },
{ mode = "n", keys = "<Leader>r", desc = "+Replace" },
{ mode = "n", keys = "<Leader>u", desc = "+UI & Config" },
{ mode = "n", keys = "<Leader>un", desc = "+Noice" },
{ mode = "n", keys = "<Leader>w", desc = "+Workspace" },
},
-- Clue window settings

View file

@ -7,7 +7,7 @@ return {
"williamboman/mason-lspconfig.nvim",
-- Additional lua configuration, makes nvim stuff amazing!
{ "folke/neodev.nvim", opts = {} },
{ "folke/neodev.nvim", opts = {} },
},
config = function()
@ -43,6 +43,9 @@ return {
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, "Workspace List Folders")
nmap("<leader>lj", vim.diagnostic.goto_next, "Go to next diagnostic")
nmap("<leader>lk", vim.diagnostic.goto_prev, "Go to prev diagnostic")
-- Create a command `:Format` local to the LSP buffer
vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_)
vim.lsp.buf.format()