Compare commits

...

10 Commits

Author SHA1 Message Date
3fc6fde51c go stuff & a mess more
Some checks failed
Close stale issues and PRs / stale (push) Has been cancelled
2025-03-28 14:53:54 -04:00
bf3c2c8003 add fileline.nvim 2024-01-16 10:30:44 -05:00
2230159029 snippets 2024-01-05 20:29:03 -05:00
97cf8dedbc . 2023-12-21 21:55:19 -05:00
9e694b6608 .. 2023-12-20 13:29:15 -05:00
4dd73953f5 .. 2023-12-19 12:03:13 -05:00
b16dc0991b .. 2023-12-17 00:54:17 -05:00
fb4b0a7261 HELLO NvChad 2023-12-16 23:48:41 -05:00
Vitor Boschi da Silva
c8777040fb [feat] Make gitsigns init function async (#2538)
* [feat] Make gitsigns init function async

This function is running git and also initializing a shell, which can be
a relatively slow operation. By leveraging the jobs api, we run the
command in background, reducing the time it takes for the buffer to be
available to the user. It also uses the list format for the job, which
allow us to bypass the shell entirely.

* performance: use uv.cwd() instead of fn.expand 

benchmarked luv's cwd and it seems to be 20x faster than the expand function

---------

Co-authored-by: Sidhanth Rathod <siduck@tutanota.com>
2023-12-08 20:51:09 +05:30
Gean Marroquin
9d37797e6f remove Search, IncSearch and CurSearch highlights from cmp windows (#2490) 2023-11-13 09:57:03 +05:30
18 changed files with 712 additions and 28 deletions

3
.gitignore vendored
View File

@@ -1,5 +1,5 @@
plugin
custom
# custom
spell
ftplugin
syntax
@@ -8,3 +8,4 @@ coc-settings.json
lazy-lock.json
after
**/.DS_Store
.elixir-tools/

View File

@@ -34,7 +34,7 @@ M.ui = {
theme = "default", -- default/vscode/vscode_colored/minimal
-- default/round/block/arrow separators work only for default statusline theme
-- round and block will work for minimal theme only
separator_style = "default",
separator_style = "block",
overriden_modules = nil,
},
@@ -44,6 +44,9 @@ M.ui = {
enabled = true,
lazyload = true,
overriden_modules = nil,
buttons = function()
return ""
end,
},
-- nvdash (dashboard)

View File

@@ -55,7 +55,7 @@ M.general = {
},
t = {
["<C-x>"] = { vim.api.nvim_replace_termcodes("<C-\\><C-N>", true, true, true), "Escape terminal mode" },
["<C-n>"] = { vim.api.nvim_replace_termcodes("<C-\\><C-N>", true, true, true), "Escape terminal mode" },
},
v = {

3
lua/custom/README.md Normal file
View File

@@ -0,0 +1,3 @@
# Example_config
This can be used as an example custom config for NvChad. Do check the https://github.com/NvChad/nvcommunity

20
lua/custom/chadrc.lua Normal file
View File

@@ -0,0 +1,20 @@
---@type ChadrcConfig
local M = {}
-- Path to overriding theme and highlights files
local highlights = require "custom.highlights"
M.ui = {
theme = "everblush",
theme_toggle = { "everblush", "one_light" },
hl_override = highlights.override,
hl_add = highlights.add,
}
M.plugins = "custom.plugins"
-- check core.mappings for table structure
M.mappings = require "custom.mappings"
return M

View File

@@ -0,0 +1,54 @@
local on_attach = require("plugins.configs.lspconfig").on_attach
local capabilities = require("plugins.configs.lspconfig").capabilities
local lspconfig = require "lspconfig"
local util = require "lspconfig/util"
-- if you just want default config for the servers then put them in a table
local servers = { "html", "cssls", "ts_ls", "clangd" }
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {
on_attach = on_attach,
capabilities = capabilities,
}
end
lspconfig.gopls.setup {
cmd = { "gopls" },
filetypes = { "go", "gomod", "gowork", "gotmpl" },
root_dir = util.root_pattern("go.work", "go.mod", ".git"),
settings = {
gopls = {
completeUnimported = true,
usePlaceholders = true,
analyses = {
unusedParameters = true,
},
},
},
}
lspconfig.ts_ls.setup {
filetypes = { "javascript", "typescript", "typescriptreact", "typescript.tsx" },
capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()),
on_attach = function(client, bufnr)
local opts = { noremap = true, silent = true }
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>f", "<cmd>lua vim.lsp.buf.format()<CR>", opts)
end,
}
-- lspconfig.rust_analyzer.setup({
-- on_attach = on_attach,
-- capabilities = capabilities,
-- filetypes = {"rust"},
-- root_dir = util.root_pattern("Cargo.toml"),
-- settings = {},
-- ['rust-analyzer'] = {
-- cargo = {
-- allFeatures = true,
-- }
-- }
-- })
--
-- lspconfig.pyright.setup { blabla}

View File

@@ -0,0 +1,21 @@
local null_ls = require "null-ls"
local b = null_ls.builtins
local sources = {
-- webdev stuff
b.formatting.deno_fmt, -- choosed deno for ts/js files cuz its very fast!
b.formatting.prettier.with { filetypes = { "html", "markdown", "css" } }, -- so prettier works only on these filetypes
-- Lua
b.formatting.stylua,
-- cpp
b.formatting.clang_format,
}
null_ls.setup {
debug = true,
sources = sources,
}

View File

@@ -0,0 +1,28 @@
local options = {
terminals = {
-- shell = vim.o.shell,
-- list = {},
type_opts = {
float = {
-- relative = "editor",
row = 0,
col = 0,
width = 0.9,
height = 0.9,
-- border = "single",
},
-- horizontal = { location = "rightbelow", split_ratio = 0.3 },
-- vertical = { location = "rightbelow", split_ratio = 0.5 },
},
},
-- behavior = {
-- autoclose_on_quit = {
-- enabled = false,
-- confirm = true,
-- },
-- close_on_exit = true,
-- auto_insert = true,
-- },
}
return options

View File

@@ -0,0 +1,67 @@
local cmp = require "cmp"
local M = {}
M.treesitter = {
ensure_installed = {
"vim",
"lua",
"html",
"css",
"javascript",
"typescript",
"tsx",
"c",
"markdown",
"markdown_inline",
},
indent = {
enable = true,
-- disable = {
-- "python"
-- },
},
}
M.mason = {
ensure_installed = {
-- lua stuff
"lua-language-server",
"stylua",
-- web dev stuff
"css-lsp",
"html-lsp",
"typescript-language-server",
"deno",
"prettier",
-- c/cpp stuff
"clangd",
"clang-format",
},
}
-- git support in nvimtree
M.nvimtree = {
git = {
enable = true,
},
renderer = {
highlight_git = true,
icons = {
show = {
git = true,
},
},
},
}
-- M.cmp = {
-- mapping = {
-- ["<A-Space>"] = cmp.mapping.complete(),
-- }
-- }
return M

View File

@@ -0,0 +1,13 @@
-- local on_attach = require("plugins.configs.lspconfig").on_attach
-- local capabilities = require("plugins.configs.lspconfig").capabilities
--
local options = {
-- server = {
-- on_attach = vim.tbl_deep_extend("force", on_attach, {
-- vim.keymap.set("n", "<leader>H", rt)
-- },
-- capabilities = capabilities,
-- },
}
return options

19
lua/custom/highlights.lua Normal file
View File

@@ -0,0 +1,19 @@
-- To find any highlight groups: "<cmd> Telescope highlights"
-- Each highlight group can take a table with variables fg, bg, bold, italic, etc
-- base30 variable names can also be used as colors
local M = {}
---@type Base46HLGroupsList
M.override = {
Comment = {
italic = true,
},
}
---@type HLTable
M.add = {
NvimTreeOpenedFolderName = { fg = "green", bold = true },
}
return M

14
lua/custom/init.lua Normal file
View File

@@ -0,0 +1,14 @@
-- local autocmd = vim.api.nvim_create_autocmd
-- Auto resize panes when resizing nvim window
-- autocmd("VimResized", {
-- pattern = "*",
-- command = "tabdo wincmd =",
-- })
--
local opt = vim.opt
opt.laststatus = 3
opt.swapfile = false
vim.g.lua_snippets_path = { vim.fn.stdpath "config" .. "/snippets" }

100
lua/custom/mappings.lua Normal file
View File

@@ -0,0 +1,100 @@
---@type MappingsTable
local M = {}
M.general = {
i = {
["<c-r>"] = { "<c-v>", "paste from OS without autopairing" },
},
n = {
-- [";"] = { ":", "enter command mode", opts = { nowait = true } },
["go"] = {
function()
vim.lsp.buf.format { async = true }
end,
"LSP formatting",
},
["<leader>wv"] = { "<C-w>v", "Split vertical" },
["<leader>ws"] = { "<C-w>s", "Split horizontal" },
["<leader>wo"] = { "<C-w>o", "Maximize split" },
["<leader>wc"] = { "<C-w>c", "Close split" },
["<leader>wx"] = { "<C-w>c", "Close split" },
["<leader>w="] = { "<C-w>=", "Even splits" },
["<leader>h"] = { "<C-w>h", "Focus left split" },
["<leader>j"] = { "<C-w>j", "Focus lower split" },
["<leader>k"] = { "<C-w>k", "Focus upper split" },
["<leader>l"] = { "<C-w>l", "Focus right split" },
["<leader>ee"] = { ':e <C-R>=expand("%:p:h" . "/" <CR><CR>)', "Copy relative path to file" },
["<leader>er"] = { ":!echo -n % | pbcopy<CR>", "Copy absolute path to file" },
["<leader>gn"] = { ":Telescope resume<CR>", "Resume telescope" },
["<leader>eu"] = { '!!python -c "import uuid; print(uuid.uuid4())"<CR>', "Drop fresh uuid4" },
["<c-c>"] = { '"+y', "Copy to OS clipboard" },
[",,"] = { ":w<CR>", "save" },
["<leader> "] = { ":w<CR>", "save" },
["<leader>n"] = { "<cmd> NvimTreeToggle <CR>", "Toggle nvimtree" },
["<leader>N"] = { "<cmd> set nu! <CR>", "Toggle line number" },
["<leader>x"] = { "<cmd>bdelete<CR>", "Close Buffer and window" },
["<leader>X"] = { "<cmd>bdelete!<CR>", "Close Buffer and window!" },
["<leader>c"] = { "<cmd>Bdelete<CR>", "Close Buffer" },
["<leader>b"] = { "<cmd> Telescope buffers <CR>", "Find buffers" },
-- ["<A-Space>"] = cmp.mapping.complete(),
["gb"] = { "<cmd>Gitsigns blame<CR>", "Git blame" },
["gB"] = { "<cmd>Gitsigns blame_line<CR>", "Git blame line" },
["gu"] = { "<cmd>diffget //2<CR>", "Select left in conflict" },
["gh"] = { "<cmd>diffget //3<CR>", "Select right in conflict" },
["ge"] = {
function()
vim.diagnostic.open_float { border = "rounded" }
end,
"Floating diagnostic",
},
[",z"] = { ":bnext<CR>", "Next buffer" },
[",v"] = { ":bprevious<CR>", "Previous buffer" },
["<leader>z"] = {
function()
require("nvchad.tabufline").tabuflineNext()
end,
"Goto next buffer",
},
["<leader>v"] = {
function()
require("nvchad.tabufline").tabuflinePrev()
end,
"Goto prev buffer",
},
["<leader>tl"] = { ":Neotest run last<CR>", "Neotest Run Last" },
["<leader>ts"] = { ":Neotest summary<CR>", "Neotest Summary" },
["<leader>to"] = { ":Neotest output<CR>", "Neotest Output" },
["<leader>ta"] = { ":Neotest output-panel<CR>", "Neotest Output Panel" },
},
v = {
[">"] = { ">gv", "indent" },
["<c-c>"] = { '"+y', "Copy to OS clipboard" },
},
}
M.crates = {
n = {
["<leader>rcu"] = {
function()
require("crates").upgrade_all_crates()
end,
"Update crates",
},
},
}
-- more keybinds!
return M

273
lua/custom/plugins.lua Normal file
View File

@@ -0,0 +1,273 @@
local overrides = require "custom.configs.overrides"
---@type NvPluginSpec[]
local plugins = {
-- Override plugin definition options
{
"neovim/nvim-lspconfig",
dependencies = {
-- format & linting
{
"jose-elias-alvarez/null-ls.nvim",
config = function()
require "custom.configs.null-ls"
end,
},
},
config = function()
require "plugins.configs.lspconfig"
require "custom.configs.lspconfig"
end, -- Override to setup mason-lspconfig
},
-- override plugin configs
{
"NvChad/nvterm",
opts = function()
return require "custom.configs.nvterm"
end,
},
{
"williamboman/mason.nvim",
opts = vim.tbl_deep_extend("force", overrides.mason, {
ensure_installed = {
"rust-analyzer",
"gopls",
},
}),
},
{
"nvim-treesitter/nvim-treesitter",
opts = overrides.treesitter,
},
{
"nvim-tree/nvim-tree.lua",
opts = overrides.nvimtree,
},
-- Install a plugin
{
"max397574/better-escape.nvim",
event = "InsertEnter",
config = function()
require("better_escape").setup()
end,
},
{
"elixir-tools/elixir-tools.nvim",
version = "*",
event = { "BufReadPre", "BufNewFile" },
config = function()
local elixir = require "elixir"
local elixirls = require "elixir.elixirls"
elixir.setup {
nextls = { enable = true },
credo = {},
elixirls = {
enable = true,
settings = elixirls.settings {
dialyzerEnabled = false,
enableTestLenses = false,
},
on_attach = function(client, bufnr)
vim.keymap.set("n", "<space>fp", ":ElixirFromPipe<cr>", { buffer = true, noremap = true })
vim.keymap.set("n", "<space>tp", ":ElixirToPipe<cr>", { buffer = true, noremap = true })
vim.keymap.set("v", "<space>em", ":ElixirExpandMacro<cr>", { buffer = true, noremap = true })
end,
},
}
end,
dependencies = {
"nvim-lua/plenary.nvim",
},
},
{
"rust-lang/rust.vim",
ft = "rust",
init = function()
vim.g.rustfmt_autosave = 1
end,
},
{
"mrcjkb/rustaceanvim",
version = "^3",
ft = { "rust" },
-- dependencies = "neovim/nvim-lspconfig",
-- opts = function()
-- return require "custom.configs.rust-tools"
-- end,
-- config = function(, opts)
-- require('rust-tools').setup(opts)
-- end
},
-- {
-- "mfussenegger/nvim-dap",
-- },
{
"saecki/crates.nvim",
dependencies = "hrsh7th/nvim-cmp",
ft = { "rust", "toml" },
config = function(_, opts)
local crates = require "crates"
crates.setup(opts)
crates.show()
end,
},
{
"hrsh7th/nvim-cmp",
opts = function()
local M = require "plugins.configs.cmp"
table.insert(M.sources, { name = "cartes" })
return M
end,
},
{
"nvim-treesitter/nvim-treesitter-context",
lazy = false,
opts = { max_lines = 6 },
},
{ "tpope/vim-surround", lazy = false },
{ "famiu/bufdelete.nvim", lazy = false },
{ "fladson/vim-kitty", ft = { "kitty" } },
-- { "tpope/vim-fugitive", lazy = false },
{
"lewis6991/gitsigns.nvim",
config = function(_, opts)
require("gitsigns").setup(opts)
end,
},
{
"lukas-reineke/indent-blankline.nvim",
enabled = false,
},
{ "rouge8/neotest-rust" },
{ "jfpedroza/neotest-elixir" },
{ "lewis6991/fileline.nvim", lazy = false },
{
"nvim-neotest/neotest",
lazy = false,
dependencies = {
"nvim-neotest/nvim-nio",
"nvim-lua/plenary.nvim",
"antoinemadec/FixCursorHold.nvim",
"nvim-treesitter/nvim-treesitter",
},
config = function()
require("neotest").setup {
adapters = {
require "neotest-rust",
require "neotest-elixir" {
-- -- The Mix task to use to run the tests
-- -- Can be a function to return a dynamic value.
-- -- Default: "test"
-- mix_task = { "my_custom_task" },
-- -- Other formatters to pass to the test command as the formatters are overridden
-- -- Can be a function to return a dynamic value.
-- -- Default: {"ExUnit.CLIFormatter"}
-- extra_formatters = { "ExUnit.CLIFormatter", "ExUnitNotifier" },
-- -- Extra test block identifiers
-- -- Can be a function to return a dynamic value.
-- -- Block identifiers "test", "feature" and "property" are always supported by default.
-- -- Default: {}
-- extra_block_identifiers = { "test_with_mock" },
-- -- Extra arguments to pass to mix test
-- -- Can be a function that receives the position, to return a dynamic value
-- -- Default: {}
-- args = { "--trace" },
-- -- Command wrapper
-- -- Must be a function that receives the mix command as a table, to return a dynamic value
-- -- Default: function(cmd) return cmd end
-- post_process_command = function(cmd)
-- return vim.tbl_flatten { { "env", "FOO=bar" }, cmd }
-- end,
-- -- Delays writes so that results are updated at most every given milliseconds
-- -- Decreasing this number improves snappiness at the cost of performance
-- -- Can be a function to return a dynamic value.
-- -- Default: 1000
-- write_delay = 1000,
},
},
}
end,
},
{
"ray-x/go.nvim",
dependencies = { -- optional packages
"ray-x/guihua.lua",
"neovim/nvim-lspconfig",
"nvim-treesitter/nvim-treesitter",
},
config = function()
require("go").setup()
end,
event = { "CmdlineEnter" },
ft = { "go", "gomod" },
build = ':lua require("go.install").update_all_sync()', -- if you need to install/update all binaries
},
{
"stevearc/conform.nvim",
config = function()
require("conform").setup {
formatters_by_ft = {
lua = { "stylua" },
-- Conform will run multiple formatters sequentially
python = { "isort", "black" },
-- You can customize some of the format options for the filetype (:help conform.format)
rust = { "rustfmt", lsp_format = "fallback" },
-- Conform will run the first available formatter
javascript = { "prettierd", "prettier", stop_after_first = true },
go = { { "gofmt" } },
},
}
end,
},
-- {
-- "rouge8/neotest-rust",
-- config = function() end,
-- },
--
-- {
-- "jfpedroza/neotest-elixir",
-- config = function() end,
-- },
-- To make a plugin not be loaded
-- {
-- "NvChad/nvim-colorizer.lua",
-- enabled = false
-- },
-- All NvChad plugins are lazy-loaded by default
-- For a plugin to be loaded, you will need to set either `ft`, `cmd`, `keys`, `event`, or set `lazy = false`
-- If you want a plugin to load on startup, add `lazy = false` to a plugin spec, for example
-- {
-- "mg979/vim-visual-multi",
-- lazy = false,
-- }
}
return plugins

View File

@@ -52,7 +52,7 @@ local options = {
window = {
completion = {
side_padding = (cmp_style ~= "atom" and cmp_style ~= "atom_colored") and 1 or 0,
winhighlight = "Normal:CmpPmenu,CursorLine:CmpSel,Search:PmenuSel",
winhighlight = "Normal:CmpPmenu,CursorLine:CmpSel,Search:None",
scrollbar = false,
},
documentation = {

View File

@@ -49,18 +49,69 @@ M.luasnip = function(opts)
})
end
-- M.gitsigns = {
-- signs = {
-- add = { text = "│" },
-- change = { text = "│" },
-- delete = { text = "󰍵" },
-- topdelete = { text = "‾" },
-- changedelete = { text = "~" },
-- untracked = { text = "│" },
-- },
-- on_attach = function(bufnr)
-- utils.load_mappings("gitsigns", { buffer = bufnr })
-- end,
-- }
M.gitsigns = {
signs = {
add = { text = "" },
change = { text = "" },
delete = { text = "󰍵" },
topdelete = { text = "" },
changedelete = { text = "~" },
untracked = { text = "" },
add = { text = '' },
change = { text = '' },
delete = { text = '_' },
topdelete = { text = '' },
changedelete = { text = '~' },
untracked = { text = '' },
},
signs_staged = {
add = { text = '' },
change = { text = '' },
delete = { text = '_' },
topdelete = { text = '' },
changedelete = { text = '~' },
untracked = { text = '' },
},
signs_staged_enable = true,
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
watch_gitdir = {
follow_files = true
},
auto_attach = true,
attach_to_untracked = false,
current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
current_line_blame_opts = {
virt_text = true,
virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align'
delay = 1000,
ignore_whitespace = false,
virt_text_priority = 100,
},
current_line_blame_formatter = '<author>, <author_time:%R> - <summary>',
sign_priority = 6,
update_debounce = 100,
status_formatter = nil, -- Use default
max_file_length = 40000, -- Disable if file is longer than this (in lines)
preview_config = {
-- Options passed to nvim_open_win
border = 'single',
style = 'minimal',
relative = 'cursor',
row = 0,
col = 1
},
on_attach = function(bufnr)
utils.load_mappings("gitsigns", { buffer = bufnr })
end,
}
return M

View File

@@ -90,22 +90,26 @@ local default_plugins = {
-- git stuff
{
"lewis6991/gitsigns.nvim",
lazy = false,
ft = { "gitcommit", "diff" },
init = function()
-- load gitsigns only when a git file is opened
vim.api.nvim_create_autocmd({ "BufRead" }, {
group = vim.api.nvim_create_augroup("GitSignsLazyLoad", { clear = true }),
callback = function()
vim.fn.system("git -C " .. '"' .. vim.fn.expand "%:p:h" .. '"' .. " rev-parse")
if vim.v.shell_error == 0 then
vim.api.nvim_del_augroup_by_name "GitSignsLazyLoad"
vim.schedule(function()
require("lazy").load { plugins = { "gitsigns.nvim" } }
end)
end
end,
})
end,
-- init = function()
-- -- load gitsigns only when a git file is opened
-- vim.api.nvim_create_autocmd({ "BufRead" }, {
-- group = vim.api.nvim_create_augroup("GitSignsLazyLoad", { clear = true }),
-- callback = function()
-- vim.fn.jobstart({ "git", "-C", vim.loop.cwd(), "rev-parse" }, {
-- on_exit = function(_, return_code)
-- if return_code == 0 then
-- vim.api.nvim_del_augroup_by_name "GitSignsLazyLoad"
-- vim.schedule(function()
-- require("lazy").load { plugins = { "gitsigns.nvim" } }
-- end)
-- end
-- end,
-- })
-- end,
-- })
-- end,
opts = function()
return require("plugins.configs.others").gitsigns
end,

13
snippets/elixir.lua Normal file
View File

@@ -0,0 +1,13 @@
-- https://github.com/L3MON4D3/LuaSnip/blob/master/DOC.md
local ls = require "luasnip"
local s = ls.snippet
local t = ls.text_node
local i = ls.insert_node
return {
s("iip", {
t '|> IO.inspect(label: "',
i(1, "label"),
t '")',
}),
}