Changed my Neovim config

This commit is contained in:
Steven Medeiros Melo
2025-03-17 17:40:37 -04:00
parent 9eae74aacc
commit 3fe3f967f6
11 changed files with 231 additions and 121 deletions

View File

@@ -2,6 +2,11 @@
# README
## - IMPORTANT NOTE -
> If one of the installed plugins don't work (i.e. Mason)
> Start by updating neovim to the newest dev build
> It should fix the issues
### Documentation on how my neovim install is configured
- The File Structure of my configuration
@@ -21,16 +26,15 @@
```text
📁 ~/.config/nvim
├── 📁 after
├── 📁 ftplugin
├── 📁 lua
── 📁 other_modules
└── ⚙ init.lua
── 📁 plugin
── ⚙ init-vim-plug.vim
├── 📁 syntax
├── 📁 TMP
├── 📁 vimplug
── 📁 stevenmm
├── 📁 lazy
│ │ └── plugin_name.lua
── ⚙ init.lua
│ ├── ⚙ lazy_init.lua
│ ├── ⚙ remap.lua
│ ├── ⚙ set.lua
│ └── ⚙ variables.lua
├── ⚙ README.md
└── ⚙ init.vim
```

View File

@@ -11,6 +11,7 @@
"fzf-lua": { "branch": "main", "commit": "9b84b53f3297d4912d7eb95b979e9b27e2e61281" },
"harpoon": { "branch": "harpoon2", "commit": "ed1f853847ffd04b2b61c314865665e1dadf22c7" },
"lazy.nvim": { "branch": "main", "commit": "e5e9bf48211a13d9ee6c1077c88327c49c1ab4a0" },
"lspkind.nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" },
"lualine.nvim": { "branch": "master", "commit": "f4f791f67e70d378a754d02da068231d2352e5bc" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "1a31f824b9cd5bc6f342fc29e9a53b60d74af245" },
"mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" },
@@ -19,12 +20,15 @@
"mini.move": { "branch": "main", "commit": "c8b30e92dd2668dd6e56a9a23cb7d4ee38c2266d" },
"mini.pairs": { "branch": "main", "commit": "1a3e73649c0eaef2f6c48ce1e761c6f0a7c11918" },
"mini.surround": { "branch": "main", "commit": "f90069c7441a5fb04c3de42eacf93e16b64dd3eb" },
"nvim-autopairs": { "branch": "master", "commit": "68f0e5c3dab23261a945272032ee6700af86227a" },
"nvim-cmp": { "branch": "main", "commit": "12509903a5723a876abd65953109f926f4634c30" },
"nvim-lspconfig": { "branch": "master", "commit": "6b63bdf2399b9bedf93297d98419550523a9ad68" },
"nvim-svelte-snippets": { "branch": "main", "commit": "0b8ceaebd528e52656303ddf66c584e9b67a52ba" },
"nvim-tree.lua": { "branch": "master", "commit": "6709463b2d18e77f7a946027917aa00d4aaed6f4" },
"nvim-treesitter": { "branch": "master", "commit": "5774e7d3da4f681296a87fcd85d17779ad362a4f" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "ad8f0a472148c3e0ae9851e26a722ee4e29b1595" },
"nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" },
"nvim-web-devicons": { "branch": "master", "commit": "1020869742ecb191f260818234517f4a1515cfe8" },
"plenary": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
"plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },

92
lua/stevenmm/lazy/cmp.lua Normal file
View File

@@ -0,0 +1,92 @@
return {
"hrsh7th/nvim-cmp",
dependencies = {
"windwp/nvim-autopairs",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
"onsails/lspkind.nvim",
},
config = function ()
print("cmp.lua")
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
local cmp = require('cmp')
local cmp_select = { behavior = cmp.SelectBehavior.Select }
local lspkind = require("lspkind")
cmp.event:on(
'confirm_done',
cmp_autopairs.on_confirm_done()
)
cmp.setup({
enabled = function()
-- disable completion in comments
local context = require('cmp.config.context')
-- keep command mode completion enabled when cursor is in a comment
if vim.api.nvim_get_mode().mode == 'c' then
return true
else
return not context.in_treesitter_capture("comment") and not context.in_syntax_group("Comment")
end
end,
formatting = {
format = lspkind.cmp_format({
mode = 'symbol_text',
max_width = {
menu = 50,
abbr = 50,
},
show_labelDetails = true
}),
},
-- preselect = { cmp.PreselectMode.Item },
performance = {
max_view_entries = 10,
},
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
-- require('nvim-svelte-snippets').
end,
},
mapping = cmp.mapping.preset.insert({
['<Down>'] = cmp.mapping.select_next_item(cmp_select),
['<Up>'] = cmp.mapping.select_prev_item(cmp_select),
['<C-j>'] = cmp.mapping.select_next_item(cmp_select),
['<C-k>'] = cmp.mapping.select_prev_item(cmp_select),
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }),
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }),
['<C-Space>'] = cmp.mapping.complete({
config = {
sources = {
{ name = 'luasnip' }
}
}
}),
['<C-e>'] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
--['<C-y>'] = cmp.mapping.confirm({ select = true }),
['<CR>'] = cmp.mapping.confirm({ select = true }),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
}, {
{ name = 'buffer' },
}),
})
end
}

View File

@@ -0,0 +1,8 @@
return {
'JoosepAlviste/nvim-ts-context-commentstring',
config = function ()
require('ts_context_commentstring').setup({
enable_autocmd = false,
})
end
}

View File

@@ -1,112 +1,34 @@
return {
"neovim/nvim-lspconfig",
-- Load each package config using the dependencies order
dependencies = {
-- mason configs:
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
-- cmp configs:
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"hrsh7th/nvim-cmp",
-- LuaSnip config:
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
"nvim-svelte/nvim-svelte-snippets",
-- fidget config:
"j-hui/fidget.nvim",
},
config = function()
local cmp = require('cmp')
local cmp_lsp = require("cmp_nvim_lsp")
local capabilities = vim.tbl_deep_extend(
"force",
{},
vim.lsp.protocol.make_client_capabilities(),
cmp_lsp.default_capabilities())
print("lsp.lua")
require("fidget").setup({})
require("mason").setup()
require("mason-lspconfig").setup({
ensure_installed = {
"gopls",
"clangd",
"lua_ls",
"rust_analyzer",
-- "php"
-- "tsserver",
},
handlers = {
function(server_name) -- default handler (optional)
require("lspconfig")[server_name].setup {
capabilities = capabilities
}
end,
["lua_ls"] = function()
local lspconfig = require("lspconfig")
lspconfig.lua_ls.setup {
capabilities = capabilities,
settings = {
Lua = {
diagnostics = {
globals = { "vim", "it", "describe", "before_each", "after_each" },
}
}
}
}
end,
["clangd"] = function ()
local lspconfig = require("lspconfig")
lspconfig.clangd.setup({
capabilities = capabilities,
})
end,
["gopls"] = function ()
local lspconfig = require("lspconfig")
lspconfig.gopls.setup {
capabilities = capabilities,
}
end
}
})
local cmp_select = { behavior = cmp.SelectBehavior.Select }
cmp.setup({
-- completion = { autocomplete = true },
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
end,
},
mapping = cmp.mapping.preset.insert({
['<Down>'] = cmp.mapping.select_next_item(cmp_select),
['<Up>'] = cmp.mapping.select_prev_item(cmp_select),
['<C-j>'] = cmp.mapping.select_next_item(cmp_select),
['<C-k>'] = cmp.mapping.select_prev_item(cmp_select),
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }),
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }),
['<C-Space>'] = cmp.mapping.complete({
config = {
sources = {
{ name = 'luasnip' }
}
}
}),
['<C-e>'] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
--['<C-y>'] = cmp.mapping.confirm({ select = true }),
['<CR>'] = cmp.mapping.confirm({ select = true }),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
}, {
{ name = 'buffer' },
}),
})
vim.diagnostic.config({
-- virtual_text = false,

View File

@@ -0,0 +1,62 @@
return {
"williamboman/mason.nvim",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"williamboman/mason-lspconfig.nvim",
},
config = function ()
print('mason.lua')
local capabilities = vim.tbl_deep_extend(
"force",
{},
vim.lsp.protocol.make_client_capabilities(),
require('cmp_nvim_lsp').default_capabilities()
)
require('mason').setup({})
require('mason-lspconfig').setup({
ensure_installed = {
"gopls",
"clangd",
"lua_ls",
"rust_analyzer",
-- "php"
-- "tsserver",
},
handlers = {
function(server_name) -- default handler (optional)
require("lspconfig")[server_name].setup {
capabilities = capabilities
}
end,
["lua_ls"] = function()
local lspconfig = require("lspconfig")
lspconfig.lua_ls.setup {
capabilities = capabilities,
settings = {
Lua = {
diagnostics = {
globals = { "vim", "it", "describe", "before_each", "after_each" },
}
}
}
}
end,
["clangd"] = function ()
local lspconfig = require("lspconfig")
lspconfig.clangd.setup({
capabilities = capabilities,
})
end,
["gopls"] = function ()
local lspconfig = require("lspconfig")
lspconfig.gopls.setup {
capabilities = capabilities,
}
end
}
})
end
}

View File

@@ -1,7 +1,13 @@
return {
'echasnovski/mini.comment',
version = false,
config = function ()
require('mini.comment').setup()
config = function()
require('mini.comment').setup({
options = {
custom_commentstring = function()
return require('ts_context_commentstring').calculate_commentstring() or vim.bo.commentstring
end
},
})
end
}

View File

@@ -0,0 +1,5 @@
return {
"windwp/nvim-autopairs",
event = "InsertEnter",
config = true
}

View File

@@ -14,5 +14,6 @@ vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
spec = "stevenmm.lazy",
change_detection = { notify = false },
'JoosepAlviste/nvim-ts-context-commentstring',
-- "nvim-lua/plenary.nvim"
})

View File

@@ -5,6 +5,7 @@ local keyset = vim.keymap.set
keyset("", "<Caps_lock>", "<Esc>")
keyset("n", "<leader>ma", ":Mason<CR>", { silent = true })
keyset("n", "<leader>na", ":NvimTreeToggle<CR>", { silent = true })
keyset('n', '<leader>la', ":Lazy<CR>", { silent = true })
keyset("n", "<leader>fb", ":Telescope file_browser path=%:p:h<CR>", { noremap = true, silent = true })
keyset("n", "<leader>ha", ":Telescope harpoon marks<CR>", { noremap = true, silent = true })
keyset('n', '<leader>se', ":Telescope emoji<CR>", { desc = '[S]earch [E]moji' })
keyset('n', '<leader>se', ":Telescope emoji<cr>", { desc = '[S]earch [E]moji' })

View File

@@ -6,23 +6,30 @@ vim.opt.relativenumber = true
vim.opt.encoding = 'UTF-8'
vim.opt.guifont = 'NotoSansM Nerd Font Mono'
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.softtabstop = -1
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4
vim.opt.smarttab = false
vim.opt.expandtab = false
vim.opt.expandtab = true
vim.opt.smartindent = false
vim.opt.wrap = false
vim.opt.linebreak = false
-- vim.opt.textwidth = 80
vim.opt.colorcolumn = "80"
-- vim.opt.formatoptions = "t"
-- vim.opt_local.columns = 80
vim.opt.swapfile = false
vim.opt.backup = false
if vim.fn.has('win32') or vim.fn.has('win64') then
vim.opt.undodir = os.getenv("XDG_CONFIG_HOME") .. "/.vim/undodir"
vim.opt.shell = 'powershell.exe'
else
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
vim.opt.shell = 'bash'
end
vim.opt.undofile = true
@@ -37,5 +44,3 @@ vim.opt.signcolumn = "yes"
vim.opt.isfname:append("@-@")
vim.opt.updatetime = 50
vim.opt.colorcolumn = "80"