Last active
June 19, 2025 17:23
-
-
Save joaquinco/27dadd460d57321f1ac5a9ac75b84a47 to your computer and use it in GitHub Desktop.
Nvim Lua init script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local Plug = vim.fn['plug#'] | |
vim.call('plug#begin') | |
-- File explorer | |
Plug('nvim-tree/nvim-tree.lua') | |
-- Visualization | |
Plug('vim-airline/vim-airline') | |
Plug('vim-airline/vim-airline-themes') | |
-- Git | |
Plug('apzelos/blamer.nvim') | |
-- File/Buffer finder | |
Plug('nvim-lua/plenary.nvim') | |
Plug('nvim-telescope/telescope.nvim') | |
-- LSP | |
Plug('williamboman/mason.nvim') | |
Plug('williamboman/mason-lspconfig.nvim') | |
Plug('neovim/nvim-lspconfig') | |
-- Autocompletion | |
Plug('hrsh7th/cmp-nvim-lsp') | |
Plug('hrsh7th/cmp-buffer') | |
Plug('hrsh7th/nvim-cmp') | |
Plug('hrsh7th/cmp-vsnip') | |
Plug('hrsh7th/vim-vsnip') | |
-- Syntax | |
-- Requires tree-sitter cli | |
Plug('nvim-treesitter/nvim-treesitter') | |
vim.call('plug#end') | |
local opt = vim.opt | |
opt.tabstop = 2 | |
opt.softtabstop = 2 | |
opt.shiftwidth = 2 | |
opt.expandtab = true | |
opt.smarttab = true | |
opt.incsearch = true | |
opt.ignorecase = true | |
opt.smartcase = true | |
opt.hlsearch = true | |
opt.wildmode = { 'longest', 'list', 'full' } | |
opt.list = true | |
opt.breakindent = true | |
opt.number = true | |
opt.title = true | |
opt.scrolloff = 5 | |
opt.completeopt = { 'menu', 'menuone', 'noselect' } | |
vim.cmd('filetype plugin indent on') | |
vim.cmd('colorscheme retrobox') | |
-- Plugin Configurations | |
-- nvim-tree.lua | |
vim.g.loaded_netrw = 1 | |
vim.g.loaded_netrwPlugin = 1 | |
require("nvim-tree").setup { | |
renderer = { | |
add_trailing = true, | |
icons = { | |
-- Disable some icons for now | |
show = { | |
file = false, | |
folder = false, | |
folder_arrow = false, | |
}, | |
}, | |
}, | |
} | |
-- Blamer | |
vim.g.blamer_enabled = 0 | |
vim.g.blamer_relative_time = 1 | |
vim.g.blamer_show_in_visual_modes = 0 | |
vim.g.blamer_delay = 200 | |
-- highlight Blamer guifg=lightgray | |
-- Airline | |
-- Powerline fonts needs https://github.com/powerline/fonts | |
vim.g.airline_powerline_fonts = 0 | |
vim.g.airline_theme = 'bubblegum' | |
vim.g['airline#extensions#tabline#enabled'] = 1 | |
vim.g['airline#extensions#tabline#formatter'] = 'unique_tail' | |
-- Cmp | |
local cmp = require("cmp") | |
cmp.setup({ | |
snippet = { | |
expand = function(args) | |
vim.fn["vsnip#anonymous"](args.body) | |
end, | |
}, | |
mapping = cmp.mapping.preset.insert({ | |
-- ['<C-e>'] = cmp.mapping.scroll_docs(-4), | |
-- ['<C-y>'] = cmp.mapping.scroll_docs(4), | |
}), | |
sources = cmp.config.sources( | |
{ | |
{ name = 'nvim_lsp' }, | |
{ name = 'vsnip' }, | |
{ | |
name = 'buffer', | |
option = { | |
get_bufnrs = function() | |
return vim.api.nvim_list_bufs() | |
end | |
}, | |
}, | |
}) | |
}) | |
-- LSP | |
local language_servers = { | |
'lexical', | |
'pylsp', | |
'solargraph', | |
} | |
require("mason").setup() | |
require("mason-lspconfig").setup { | |
ensure_installed = language_servers, | |
} | |
local lspconfig = require("lspconfig") | |
local lsp_capabilities = require("cmp_nvim_lsp").default_capabilities() | |
for _, server_name in ipairs(language_servers) do | |
lspconfig[server_name].setup { | |
capabilities = lsp_capabilities | |
} | |
end | |
-- Treesitter | |
require('nvim-treesitter.configs').setup { | |
ensure_installed = { 'elixir', 'vimdoc' }, | |
sync_install = true, | |
auto_install = false, | |
highlight = { enable = true } | |
} | |
-- Telescope | |
require('telescope').setup { | |
defaults = { | |
path_display = { "filename_first" } | |
}, | |
pickers = { | |
find_files = { | |
no_ignore = true, | |
hidden = true | |
} | |
} | |
} | |
local telescope_builtin = require('telescope.builtin') | |
-- Mappings | |
local mappings = { | |
{{'n', 'v'}, '<C-n>', ':NvimTreeToggle<cr>'}, | |
{{'n', 'v'}, '<C-b>', ':NvimTreeFindFile<cr>'}, | |
-- Override C-f that I never really use | |
-- fd-find recommended | |
{{'n', 'v'}, '<A-f>', telescope_builtin.find_files}, | |
{{'n', 'v'}, '<C-f>', telescope_builtin.git_files}, | |
-- requires ripgrep | |
{{'n', 'v'}, '<C-s>', telescope_builtin.live_grep}, | |
{{'n', 'v'}, '<A-b>', telescope_builtin.buffers}, | |
{{'n', 'v'}, '<A-s>', telescope_builtin.grep_string}, | |
-- LSP | |
{{'n', 'i'}, '<leader>s', vim.diagnostic.open_float}, | |
{{'n', 'v'}, '<leader>d', vim.lsp.buf.definition}, | |
-- git | |
{{'n', 'v', 'i'}, '<leader>gb', ':BlamerToggle<cr>'}, | |
-- Other | |
{{'n', 'v'}, '<esc>', ':nohl<cr>'}, | |
} | |
for _, mapping_args in ipairs(mappings) do | |
vim.keymap.set(unpack(mapping_args)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment