feat: Adding config files
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
-- lua/plugins/cmp.lua
|
||||
return {
|
||||
"hrsh7th/nvim-cmp",
|
||||
event = "InsertEnter",
|
||||
dependencies = {
|
||||
-- Fuente para autocompletado de LSP
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
-- Fuente para autocompletado de buffers
|
||||
"hrsh7th/cmp-buffer",
|
||||
-- Fuente para autocompletado de rutas
|
||||
"hrsh7th/cmp-path",
|
||||
-- Motor de snippets
|
||||
"L3MON4D3/LuaSnip",
|
||||
-- Fuente de snippets para nvim-cmp
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
},
|
||||
config = function()
|
||||
local cmp = require("cmp")
|
||||
local luasnip = require("luasnip")
|
||||
|
||||
cmp.setup({
|
||||
-- Configura el motor de snippets
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
-- Fuentes de autocompletado
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" },
|
||||
{ name = "buffer" },
|
||||
{ name = "path" },
|
||||
}),
|
||||
-- Atajos de teclado para el menú de autocompletado
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-k>"] = cmp.mapping.select_prev_item(), -- Moverse hacia arriba
|
||||
["<C-j>"] = cmp.mapping.select_next_item(), -- Moverse hacia abajo
|
||||
["<C-b>"] = cmp.mapping.scroll_docs(-4), -- Scroll en la documentación
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete(), -- Mostrar sugerencias
|
||||
["<C-e>"] = cmp.mapping.abort(), -- Cerrar menú
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Aceptar sugerencia
|
||||
}),
|
||||
})
|
||||
end,
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
return {
|
||||
-- LSP Config
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
event = { "BufReadPost", "BufNewFile", "FileType" },
|
||||
dependencies = {
|
||||
"hrsh7th/nvim-cmp", -- Completion framework
|
||||
"hrsh7th/cmp-nvim-lsp", -- LSP source for nvim-cmp
|
||||
"hrsh7th/cmp-buffer", -- Buffer source for nvim-cmp
|
||||
"hrsh7th/cmp-path", -- Path source for nvim-cmp
|
||||
"L3MON4D3/LuaSnip", -- Snippet engine
|
||||
"saadparwaiz1/cmp_luasnip", -- Snippet completion
|
||||
"rafamadriz/friendly-snippets", -- Snippet collection
|
||||
"hrsh7th/cmp-nvim-lsp-signature-help", -- LSP signature help source
|
||||
},
|
||||
config = function()
|
||||
-- Diagnostic options with signs configured
|
||||
vim.diagnostic.config({
|
||||
-- virtual_text = false, -- Disable virtual text (optional)
|
||||
virtual_text = {
|
||||
spacing = 4,
|
||||
source = "if_many",
|
||||
prefix = "●",
|
||||
-- this will set set the prefix to a function that returns the diagnostics icon based on the severity
|
||||
-- this only works on a recent 0.10.0 build. Will be set to "●" when not supported
|
||||
-- prefix = "icons",
|
||||
},
|
||||
signs = {
|
||||
text = {
|
||||
[vim.diagnostic.severity.ERROR] = icons.diagnostics.Error, -- Error icon
|
||||
[vim.diagnostic.severity.WARN] = icons.diagnostics.Warn, -- Warning icon
|
||||
[vim.diagnostic.severity.HINT] = icons.diagnostics.Hint, -- Hint icon
|
||||
[vim.diagnostic.severity.INFO] = icons.diagnostics.Info, -- Info icon
|
||||
},
|
||||
},
|
||||
update_in_insert = false,
|
||||
severity_sort = true,
|
||||
})
|
||||
|
||||
-- Key mappings for diagnostic navigation
|
||||
vim.api.nvim_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>',
|
||||
{ noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>',
|
||||
{ noremap = true, silent = true })
|
||||
-- vim.api.nvim_set_keymap('n', '<leader>e', '<cmd>lua vim.diagnostic.open_float()<CR>',
|
||||
-- { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('n', '<leader>q', '<cmd>lua vim.diagnostic.setloclist()<CR>',
|
||||
{ noremap = true, silent = true })
|
||||
|
||||
-- Show floating diagnostics automatically on hover
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
callback = function()
|
||||
vim.diagnostic.open_float(nil, { focusable = false })
|
||||
end,
|
||||
})
|
||||
|
||||
-- Autocompletion configuration
|
||||
local cmp = require('cmp')
|
||||
local luasnip = require('luasnip')
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body) -- For `luasnip` users.
|
||||
end,
|
||||
},
|
||||
mapping = {
|
||||
['<Down>'] = cmp.mapping.select_next_item(),
|
||||
['<Up>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||
},
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' }, -- For luasnip users.
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
{ name = 'path' },
|
||||
}),
|
||||
completion = {
|
||||
completeopt = "menu,menuone,noinsert" .. (true and "" or ",noselect"),
|
||||
},
|
||||
experimental = {
|
||||
ghost_text = true
|
||||
},
|
||||
formatting = {
|
||||
format = function(entry, item)
|
||||
local icons = icons.kinds
|
||||
if icons[item.kind] then
|
||||
item.kind = icons[item.kind] .. item.kind
|
||||
end
|
||||
|
||||
local widths = {
|
||||
abbr = vim.g.cmp_widths and vim.g.cmp_widths.abbr or 40,
|
||||
menu = vim.g.cmp_widths and vim.g.cmp_widths.menu or 30,
|
||||
}
|
||||
|
||||
for key, width in pairs(widths) do
|
||||
if item[key] and vim.fn.strdisplaywidth(item[key]) > width then
|
||||
item[key] = vim.fn.strcharpart(item[key], 0, width - 1) .. "…"
|
||||
end
|
||||
end
|
||||
|
||||
return item
|
||||
end,
|
||||
},
|
||||
})
|
||||
|
||||
-- Use buffer source for `/` in command mode
|
||||
cmp.setup.cmdline('/', {
|
||||
sources = {
|
||||
{ name = 'buffer' }
|
||||
}
|
||||
})
|
||||
|
||||
-- Use cmdline & path source for `:` in command mode
|
||||
cmp.setup.cmdline(':', {
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }
|
||||
}, {
|
||||
{ name = 'cmdline' }
|
||||
})
|
||||
})
|
||||
|
||||
-- Load snippets from friendly-snippets
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
end,
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
return {
|
||||
"L3MON4D3/LuaSnip",
|
||||
-- follow latest release.
|
||||
version = "v2.*", -- Replace <CurrentMajor> by the latest released major (first number of latest release)
|
||||
-- install jsregexp (optional!).
|
||||
build = "make install_jsregexp",
|
||||
|
||||
dependencies = { "rafamadriz/friendly-snippets" },
|
||||
|
||||
config = function()
|
||||
local ls = require("luasnip")
|
||||
ls.filetype_extend("javascript", { "jsdoc" })
|
||||
ls.filetype_extend("java", { "javadoc" })
|
||||
local s = ls.snippet
|
||||
local i = ls.insert_node
|
||||
local t = ls.text_node
|
||||
|
||||
-- these are my custom snippets for cpp problem solving
|
||||
ls.add_snippets("cpp", {
|
||||
-- GCD Function
|
||||
s("gcd", {
|
||||
t("long long gcd(long long a, long long b) { // NOLINT(misc-no-recursion)"), t({ "", "\t" }),
|
||||
t("if (b == 0) return a;"), t({ "", "\t" }),
|
||||
t("return gcd(b, a % b);"), t({ "", "}" }),
|
||||
}),
|
||||
|
||||
-- LCM Function
|
||||
s("lcm", {
|
||||
t("long long lcm(long long a, long long b) {"), t({ "", "\t" }),
|
||||
t("return (a * b) / gcd(a, b);"), t({ "", "}" }),
|
||||
}),
|
||||
|
||||
-- isPrime Function
|
||||
s("isPrime", {
|
||||
t("bool isPrime(long long number) {"), t({ "", "\t" }),
|
||||
t("if (number <= 1) return false;"), t({ "", "\t" }),
|
||||
t("for (int i = 2; i * i <= number; ++i) {"), t({ "", "\t\t" }),
|
||||
t("if (number % i == 0) return false;"), t({ "", "\t" }),
|
||||
t("}"), t({ "", "\t" }),
|
||||
t("return true;"), t({ "", "}" }),
|
||||
}),
|
||||
|
||||
-- for loop
|
||||
s("fori", {
|
||||
t("for (int i = "), i(1), t("; i < "), i(2), t("; ++i) {"),
|
||||
t({ "", "\t" }), i(0),
|
||||
t({ "", "}" })
|
||||
}),
|
||||
|
||||
-- for each
|
||||
s("forin", {
|
||||
t("for ("), i(1), t(" : "), i(2), t(" ){"),
|
||||
t({ "", "\t" }), i(0),
|
||||
t({ "", "}" })
|
||||
}),
|
||||
|
||||
-- convertToBinaryString Function
|
||||
s("convertToBinaryString", {
|
||||
t("string convertToBinaryString(long long k) {"), t({ "", "\t" }),
|
||||
t("string binaryString;"), t({ "", "" }),
|
||||
t("\tif (k == 0) {"), t({ "", "\t\t" }),
|
||||
t('binaryString = "0";'), t({ "", "\t" }),
|
||||
t("} else {"), t({ "", "\t\t" }),
|
||||
t("while (k > 0) {"), t({ "", "\t\t\t" }),
|
||||
t("long long bit = k & 1;"), t({ "", "\t\t\t" }),
|
||||
t('binaryString.insert(0, std::to_string(bit));'), t({ "", "\t\t\t" }),
|
||||
t("k >>= 1;"), t({ "", "\t\t" }),
|
||||
t("}"), t({ "", "\t" }),
|
||||
t("}"), t({ "", "\t" }),
|
||||
t("return binaryString;"), t({ "", "}" })
|
||||
}),
|
||||
|
||||
-- nCr Function
|
||||
s("nCr", {
|
||||
t("long long nCr(long long n, long long r) {"), t({ "", "\t" }),
|
||||
t("long long ans = 1;"), t({ "", "\t" }),
|
||||
t("long long div = 1;"), t({ "", "\t" }),
|
||||
t("for (long long i = r + 1; i <= n; i++) {"), t({ "", "\t\t" }),
|
||||
t("ans = ans * i;"), t({ "", "\t\t" }),
|
||||
t("ans /= div;"), t({ "", "\t\t" }),
|
||||
t("div++;"), t({ "", "\t" }),
|
||||
t("}"), t({ "", "\t" }),
|
||||
t("return ans;"), t({ "", "}" })
|
||||
}),
|
||||
|
||||
-- nPr Function
|
||||
s("nPr", {
|
||||
t("long long nPr(long long n, long long r) {"), t({ "", "\t" }),
|
||||
t("long long ans = 1;"), t({ "", "\t" }),
|
||||
t("for (long long i = (n - r) + 1; i <= n; i++) {"), t({ "", "\t\t" }),
|
||||
t("ans *= i;"), t({ "", "\t\t" }),
|
||||
t("ans %= mod;"), t({ "", "\t" }),
|
||||
t("}"), t({ "", "\t" }),
|
||||
t("return ans;"), t({ "", "}" })
|
||||
}),
|
||||
|
||||
-- fact Function
|
||||
s("fact", {
|
||||
t("long long fact(long long n) { // NOLINT(misc-no-recursion)"), t({ "", "\t" }),
|
||||
t("if (n <= 1) return 1;"), t({ "", "\t" }),
|
||||
t("return (n % mod * fact(n - 1) % mod) % mod;"), t({ "", "}" })
|
||||
}),
|
||||
|
||||
-- convertToBaseK Function
|
||||
s("convertToBaseK", {
|
||||
t("string convertToBaseK(long long n, int k) {"), t({ "", "\t" }),
|
||||
t("string result;"), t({ "", "\t" }),
|
||||
t("while (n > 0) {"), t({ "", "\t\t" }),
|
||||
t("long long remainder = n % k;"), t({ "", "\t\t" }),
|
||||
t("result.insert(0, to_string(remainder));"), t({ "", "\t\t" }),
|
||||
t("n /= k;"), t({ "", "\t" }),
|
||||
t("}"), t({ "", "\t" }),
|
||||
t("return result;"), t({ "", "}" })
|
||||
}),
|
||||
|
||||
-- sieve function
|
||||
s("sieve", {
|
||||
t({
|
||||
"void sieve(ll n) {",
|
||||
" low.assign(n + 1, 0);",
|
||||
"",
|
||||
" for (int i = 2; i <= n; ++i) {",
|
||||
" if (!low[i]) {",
|
||||
" low[i] = i;",
|
||||
" pr.push_back(i);",
|
||||
" }",
|
||||
"",
|
||||
" for (int &j: pr) {",
|
||||
" if (j > low[i] || i * j > n) break;",
|
||||
" low[j * i] = j;",
|
||||
" }",
|
||||
" }",
|
||||
"}",
|
||||
}),
|
||||
}),
|
||||
})
|
||||
|
||||
ls.add_snippets("c", {
|
||||
s("get_current_time_ms", {
|
||||
t({
|
||||
"long long get_current_time_ms() {",
|
||||
" struct timeval tv;",
|
||||
" gettimeofday(&tv, NULL);",
|
||||
" return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);",
|
||||
"}",
|
||||
}),
|
||||
}),
|
||||
})
|
||||
end,
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
return {
|
||||
-- Mason for managing LSP servers
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
config = function()
|
||||
require("mason").setup()
|
||||
end,
|
||||
},
|
||||
{
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
dependencies = { "neovim/nvim-lspconfig" },
|
||||
config = function()
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = { "gopls"}, -- Add more LSP servers you need
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
return {
|
||||
"nvim-mini/mini.animate",
|
||||
event = "VeryLazy",
|
||||
cond = vim.g.neovide == nil,
|
||||
opts = function(_, opts)
|
||||
-- don't use animate when scrolling with the mouse
|
||||
local mouse_scrolled = false
|
||||
for _, scroll in ipairs({ "Up", "Down" }) do
|
||||
local key = "<ScrollWheel" .. scroll .. ">"
|
||||
vim.keymap.set({ "", "i" }, key, function()
|
||||
mouse_scrolled = true
|
||||
return key
|
||||
end, { expr = true })
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "grug-far",
|
||||
callback = function()
|
||||
vim.b.minianimate_disable = true
|
||||
end,
|
||||
})
|
||||
|
||||
Snacks.toggle({
|
||||
name = "Mini Animate",
|
||||
get = function()
|
||||
return not vim.g.minianimate_disable
|
||||
end,
|
||||
set = function(state)
|
||||
vim.g.minianimate_disable = not state
|
||||
end,
|
||||
}):map("<leader>ua")
|
||||
|
||||
local animate = require("mini.animate")
|
||||
return vim.tbl_deep_extend("force", opts, {
|
||||
resize = {
|
||||
timing = animate.gen_timing.linear({ duration = 50, unit = "total" }),
|
||||
},
|
||||
scroll = {
|
||||
timing = animate.gen_timing.linear({ duration = 150, unit = "total" }),
|
||||
subscroll = animate.gen_subscroll.equal({
|
||||
predicate = function(total_scroll)
|
||||
if mouse_scrolled then
|
||||
mouse_scrolled = false
|
||||
return false
|
||||
end
|
||||
return total_scroll > 1
|
||||
end,
|
||||
}),
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
return { "nvim-tree/nvim-web-devicons", opts = {} }
|
||||
@@ -0,0 +1 @@
|
||||
return { "folke/snacks.nvim", opts = { dashboard = { enabled = false } } }
|
||||
@@ -0,0 +1,55 @@
|
||||
return {
|
||||
{
|
||||
'nvim-telescope/telescope.nvim',
|
||||
tag = '0.1.8',
|
||||
dependencies = { 'nvim-lua/plenary.nvim' },
|
||||
config = function()
|
||||
require('telescope').setup({
|
||||
defaults = {
|
||||
vimgrep_arguments = {
|
||||
'rg',
|
||||
'--color=never',
|
||||
'--no-heading',
|
||||
'--with-filename',
|
||||
'--line-number',
|
||||
'--column',
|
||||
'--smart-case',
|
||||
'--no-ignore', -- Include files ignored by .gitignore
|
||||
'--hidden', -- Include hidden files
|
||||
'--glob', '!target/', -- Exclude the `target/` directory
|
||||
'--binary', -- Ignore all binary files
|
||||
},
|
||||
},
|
||||
pickers = {
|
||||
find_files = {
|
||||
find_command = { 'rg', '--files', '--hidden', '--no-ignore', '--glob', '!target/', '--binary' },
|
||||
},
|
||||
},
|
||||
extensions = {
|
||||
themes = require('telescope.themes').get_dropdown({}),
|
||||
},
|
||||
})
|
||||
|
||||
-- Keymap to bring up the colorscheme picker
|
||||
vim.keymap.set('n', '<leader>uC', function()
|
||||
require('telescope.builtin').colorscheme({
|
||||
enable_preview = true, -- Shows preview of the colorschemes
|
||||
})
|
||||
end, { noremap = true, silent = true })
|
||||
end,
|
||||
},
|
||||
{
|
||||
'nvim-telescope/telescope-ui-select.nvim',
|
||||
config = function()
|
||||
require("telescope").setup({
|
||||
extensions = {
|
||||
["ui-select"] = {
|
||||
require("telescope.themes").get_dropdown {
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
require("telescope").load_extension("ui-select")
|
||||
end
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
return {
|
||||
"ficcdaf/ashen.nvim",
|
||||
-- optional but recommended,
|
||||
-- pin to the latest stable release:
|
||||
--tag = "*",
|
||||
lazy = false,
|
||||
priority = 1000,
|
||||
-- configuration is optional!
|
||||
opts = {
|
||||
-- your settings here
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
return {
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
build = ':TSUpdate', -- Automatically update parsers on update
|
||||
config = function()
|
||||
require('nvim-treesitter.configs').setup {
|
||||
ensure_installed = { "lua", "javascript", "python", "bash", "java", "c", "markdown", "go" }, -- Add other languages as needed
|
||||
highlight = { enable = true }, -- Enable syntax highlighting using Tree-sitter
|
||||
indent = { enable = true }, -- Enable indentation based on Tree-sitter
|
||||
-- You can add other Tree-sitter modules here as needed
|
||||
}
|
||||
end
|
||||
}
|
||||
Reference in New Issue
Block a user