Last active
September 1, 2025 05:13
-
-
Save oNddleo/f09be990e1be7db2385bf183ff549676 to your computer and use it in GitHub Desktop.
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
| -- ~/.config/nvim/init.lua | |
| -- Neovim configuration with snacks.nvim terminal and transparent background | |
| -- Basic settings | |
| vim.opt.number = true | |
| vim.opt.relativenumber = true | |
| vim.opt.tabstop = 2 | |
| vim.opt.shiftwidth = 2 | |
| vim.opt.expandtab = true | |
| vim.opt.smartindent = true | |
| vim.opt.wrap = false | |
| vim.opt.cursorline = true | |
| vim.opt.termguicolors = true | |
| vim.opt.signcolumn = "yes" | |
| vim.opt.updatetime = 50 | |
| vim.opt.colorcolumn = "80" | |
| -- Transparent background | |
| vim.cmd([[ | |
| highlight Normal guibg=NONE ctermbg=NONE | |
| highlight NonText guibg=NONE ctermbg=NONE | |
| highlight LineNr guibg=NONE ctermbg=NONE | |
| highlight Folded guibg=NONE ctermbg=NONE | |
| highlight EndOfBuffer guibg=NONE ctermbg=NONE | |
| highlight SignColumn guibg=NONE ctermbg=NONE | |
| ]]) | |
| -- Plugin manager setup (lazy.nvim) | |
| local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" | |
| if not vim.loop.fs_stat(lazypath) then | |
| vim.fn.system({ | |
| "git", | |
| "clone", | |
| "--filter=blob:none", | |
| "https://github.com/folke/lazy.nvim.git", | |
| "--branch=stable", | |
| lazypath, | |
| }) | |
| end | |
| vim.opt.rtp:prepend(lazypath) | |
| -- Plugins | |
| require("lazy").setup({ | |
| -- Colorscheme | |
| { | |
| "folke/tokyonight.nvim", | |
| lazy = false, | |
| priority = 1000, | |
| config = function() | |
| require("tokyonight").setup({ | |
| style = "night", | |
| transparent = true, | |
| terminal_colors = true, | |
| styles = { | |
| comments = { italic = true }, | |
| keywords = { italic = true }, | |
| functions = {}, | |
| variables = {}, | |
| sidebars = "transparent", | |
| floats = "transparent", | |
| }, | |
| }) | |
| vim.cmd([[colorscheme tokyonight]]) | |
| end, | |
| }, | |
| -- Snacks.nvim - Modern UI components including terminal | |
| { | |
| "folke/snacks.nvim", | |
| priority = 1000, | |
| lazy = false, | |
| opts = { | |
| -- Enable different snacks components | |
| bigfile = { enabled = true }, | |
| dashboard = { enabled = true }, | |
| indent = { enabled = true }, | |
| input = { enabled = true }, | |
| notifier = { enabled = true }, | |
| quickfile = { enabled = true }, | |
| scroll = { enabled = true }, | |
| statuscolumn = { enabled = true }, | |
| words = { enabled = true }, | |
| styles = { | |
| notification = { | |
| wo = { wrap = true } -- Wrap notifications | |
| } | |
| }, | |
| -- Terminal configuration | |
| terminal = { | |
| win = { | |
| position = "bottom", | |
| height = 0.3, | |
| width = 1.0, | |
| border = "none", | |
| }, | |
| -- Override terminal highlights for transparency | |
| highlights = { | |
| Normal = { bg = "NONE" }, | |
| NormalFloat = { bg = "NONE" }, | |
| FloatBorder = { bg = "NONE" }, | |
| }, | |
| }, | |
| }, | |
| keys = { | |
| { "<leader>t", function() Snacks.terminal() end, desc = "Toggle Terminal" }, | |
| { "<leader>.", function() Snacks.scratch() end, desc = "Toggle Scratch Buffer" }, | |
| { "<leader>S", function() Snacks.scratch.select() end, desc = "Select Scratch Buffer" }, | |
| { "<leader>n", function() Snacks.notifier.show_history() end, desc = "Notification History" }, | |
| { "<leader>bd", function() Snacks.bufdelete() end, desc = "Delete Buffer" }, | |
| { "<leader>cR", function() Snacks.rename.rename_file() end, desc = "Rename File" }, | |
| { "<leader>gB", function() Snacks.gitbrowse() end, desc = "Git Browse" }, | |
| { "<leader>gb", function() Snacks.git.blame_line() end, desc = "Git Blame Line" }, | |
| { "<leader>gf", function() Snacks.lazygit.log_file() end, desc = "Lazygit Current File History" }, | |
| { "<leader>gg", function() Snacks.lazygit() end, desc = "Lazygit" }, | |
| { "<leader>gl", function() Snacks.lazygit.log() end, desc = "Lazygit Log (cwd)" }, | |
| { "<leader>un", function() Snacks.notifier.hide() end, desc = "Dismiss All Notifications" }, | |
| { "<c-/>", function() Snacks.terminal() end, desc = "Toggle Terminal" }, | |
| { "<c-_>", function() Snacks.terminal() end, desc = "Toggle Terminal" }, | |
| }, | |
| init = function() | |
| vim.api.nvim_create_autocmd("User", { | |
| pattern = "VeryLazy", | |
| callback = function() | |
| -- Setup some globals for easier access | |
| _G.dd = function(...) | |
| Snacks.debug.inspect(...) | |
| end | |
| _G.bt = function() | |
| Snacks.debug.backtrace() | |
| end | |
| vim.print = _G.dd -- Override print to use snacks for `:=` command | |
| end, | |
| }) | |
| end, | |
| }, | |
| -- File explorer | |
| { | |
| "nvim-tree/nvim-tree.lua", | |
| dependencies = { | |
| "nvim-tree/nvim-web-devicons", | |
| }, | |
| config = function() | |
| require("nvim-tree").setup({ | |
| view = { | |
| width = 30, | |
| }, | |
| renderer = { | |
| group_empty = true, | |
| highlight_git = true, | |
| }, | |
| filters = { | |
| dotfiles = false, | |
| }, | |
| git = { | |
| enable = true, | |
| }, | |
| }) | |
| end, | |
| }, | |
| -- Status line | |
| { | |
| "nvim-lualine/lualine.nvim", | |
| dependencies = { "nvim-tree/nvim-web-devicons" }, | |
| config = function() | |
| require("lualine").setup({ | |
| options = { | |
| theme = "tokyonight", | |
| globalstatus = true, | |
| component_separators = { left = '', right = '' }, | |
| section_separators = { left = '', right = '' }, | |
| }, | |
| sections = { | |
| lualine_a = {'mode'}, | |
| lualine_b = {'branch', 'diff', 'diagnostics'}, | |
| lualine_c = {'filename'}, | |
| lualine_x = {'encoding', 'fileformat', 'filetype'}, | |
| lualine_y = {'progress'}, | |
| lualine_z = {'location'} | |
| }, | |
| }) | |
| end, | |
| }, | |
| -- Fuzzy finder | |
| { | |
| "nvim-telescope/telescope.nvim", | |
| tag = "0.1.4", | |
| dependencies = { | |
| "nvim-lua/plenary.nvim", | |
| "nvim-tree/nvim-web-devicons", | |
| }, | |
| config = function() | |
| require("telescope").setup({ | |
| defaults = { | |
| winblend = 0, | |
| layout_config = { | |
| horizontal = { | |
| preview_width = 0.6, | |
| }, | |
| }, | |
| }, | |
| pickers = { | |
| find_files = { | |
| theme = "dropdown", | |
| previewer = false, | |
| }, | |
| }, | |
| }) | |
| end, | |
| }, | |
| -- Syntax highlighting | |
| { | |
| "nvim-treesitter/nvim-treesitter", | |
| build = ":TSUpdate", | |
| config = function() | |
| require("nvim-treesitter.configs").setup({ | |
| ensure_installed = { | |
| "lua", "vim", "vimdoc", "query", "python", "javascript", | |
| "typescript", "html", "css", "json", "yaml", "markdown" | |
| }, | |
| sync_install = false, | |
| highlight = { | |
| enable = true, | |
| additional_vim_regex_highlighting = false, | |
| }, | |
| indent = { enable = true }, | |
| }) | |
| end, | |
| }, | |
| -- LSP Support | |
| { | |
| "neovim/nvim-lspconfig", | |
| dependencies = { | |
| "williamboman/mason.nvim", | |
| "williamboman/mason-lspconfig.nvim", | |
| }, | |
| config = function() | |
| require("mason").setup() | |
| require("mason-lspconfig").setup({ | |
| ensure_installed = { "lua_ls", "pyright", "tsserver" }, | |
| }) | |
| local lspconfig = require("lspconfig") | |
| -- Lua LSP | |
| lspconfig.lua_ls.setup({ | |
| settings = { | |
| Lua = { | |
| diagnostics = { | |
| globals = { "vim" }, | |
| }, | |
| }, | |
| }, | |
| }) | |
| -- Python LSP | |
| lspconfig.pyright.setup({}) | |
| -- TypeScript/JavaScript LSP | |
| lspconfig.tsserver.setup({}) | |
| end, | |
| }, | |
| -- Auto completion | |
| { | |
| "hrsh7th/nvim-cmp", | |
| dependencies = { | |
| "hrsh7th/cmp-nvim-lsp", | |
| "hrsh7th/cmp-buffer", | |
| "hrsh7th/cmp-path", | |
| "hrsh7th/cmp-cmdline", | |
| "L3MON4D3/LuaSnip", | |
| "saadparwaiz1/cmp_luasnip", | |
| }, | |
| config = function() | |
| local cmp = require("cmp") | |
| local luasnip = require("luasnip") | |
| cmp.setup({ | |
| snippet = { | |
| expand = function(args) | |
| luasnip.lsp_expand(args.body) | |
| end, | |
| }, | |
| mapping = cmp.mapping.preset.insert({ | |
| ["<C-b>"] = cmp.mapping.scroll_docs(-4), | |
| ["<C-f>"] = cmp.mapping.scroll_docs(4), | |
| ["<C-Space>"] = cmp.mapping.complete(), | |
| ["<C-e>"] = cmp.mapping.abort(), | |
| ["<CR>"] = cmp.mapping.confirm({ select = true }), | |
| ["<Tab>"] = cmp.mapping(function(fallback) | |
| if cmp.visible() then | |
| cmp.select_next_item() | |
| elseif luasnip.expand_or_jumpable() then | |
| luasnip.expand_or_jump() | |
| else | |
| fallback() | |
| end | |
| end, { "i", "s" }), | |
| }), | |
| sources = cmp.config.sources({ | |
| { name = "nvim_lsp" }, | |
| { name = "luasnip" }, | |
| }, { | |
| { name = "buffer" }, | |
| }), | |
| }) | |
| end, | |
| }, | |
| }) | |
| -- Key mappings | |
| vim.g.mapleader = " " | |
| -- Basic mappings | |
| vim.keymap.set("n", "<leader>e", ":NvimTreeToggle<CR>", { desc = "Toggle File Explorer" }) | |
| vim.keymap.set("n", "<leader>ff", ":Telescope find_files<CR>", { desc = "Find Files" }) | |
| vim.keymap.set("n", "<leader>fg", ":Telescope live_grep<CR>", { desc = "Live Grep" }) | |
| vim.keymap.set("n", "<leader>fb", ":Telescope buffers<CR>", { desc = "Find Buffers" }) | |
| vim.keymap.set("n", "<leader>fh", ":Telescope help_tags<CR>", { desc = "Help Tags" }) | |
| -- Window navigation | |
| vim.keymap.set("n", "<C-h>", "<C-w>h", { desc = "Go to left window" }) | |
| vim.keymap.set("n", "<C-j>", "<C-w>j", { desc = "Go to lower window" }) | |
| vim.keymap.set("n", "<C-k>", "<C-w>k", { desc = "Go to upper window" }) | |
| vim.keymap.set("n", "<C-l>", "<C-w>l", { desc = "Go to right window" }) | |
| -- Buffer management | |
| vim.keymap.set("n", "<S-h>", ":bprevious<CR>", { desc = "Previous buffer" }) | |
| vim.keymap.set("n", "<S-l>", ":bnext<CR>", { desc = "Next buffer" }) | |
| -- Terminal specific mappings | |
| vim.keymap.set("t", "<Esc>", "<C-\\><C-n>", { desc = "Exit terminal mode" }) | |
| vim.keymap.set("t", "<C-h>", "<C-\\><C-n><C-w>h", { desc = "Go to left window" }) | |
| vim.keymap.set("t", "<C-j>", "<C-\\><C-n><C-w>j", { desc = "Go to lower window" }) | |
| vim.keymap.set("t", "<C-k>", "<C-\\><C-n><C-w>k", { desc = "Go to upper window" }) | |
| vim.keymap.set("t", "<C-l>", "<C-\\><C-n><C-w>l", { desc = "Go to right window" }) | |
| -- LSP mappings | |
| vim.keymap.set("n", "gd", vim.lsp.buf.definition, { desc = "Go to definition" }) | |
| vim.keymap.set("n", "gr", vim.lsp.buf.references, { desc = "Go to references" }) | |
| vim.keymap.set("n", "K", vim.lsp.buf.hover, { desc = "Hover documentation" }) | |
| vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, { desc = "Code action" }) | |
| vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, { desc = "Rename" }) | |
| -- Auto-commands for transparency | |
| vim.api.nvim_create_autocmd("ColorScheme", { | |
| pattern = "*", | |
| callback = function() | |
| vim.cmd([[ | |
| highlight Normal guibg=NONE ctermbg=NONE | |
| highlight NonText guibg=NONE ctermbg=NONE | |
| highlight LineNr guibg=NONE ctermbg=NONE | |
| highlight Folded guibg=NONE ctermbg=NONE | |
| highlight EndOfBuffer guibg=NONE ctermbg=NONE | |
| highlight SignColumn guibg=NONE ctermbg=NONE | |
| highlight NvimTreeNormal guibg=NONE ctermbg=NONE | |
| highlight NvimTreeNormalNC guibg=NONE ctermbg=NONE | |
| highlight TelescopeNormal guibg=NONE ctermbg=NONE | |
| highlight TelescopeBorder guibg=NONE ctermbg=NONE | |
| highlight FloatBorder guibg=NONE ctermbg=NONE | |
| highlight NormalFloat guibg=NONE ctermbg=NONE | |
| ]]) | |
| end, | |
| }) | |
| -- Terminal auto-commands | |
| vim.api.nvim_create_autocmd("TermOpen", { | |
| pattern = "*", | |
| callback = function() | |
| -- Set terminal-specific options | |
| vim.opt_local.number = false | |
| vim.opt_local.relativenumber = false | |
| vim.opt_local.signcolumn = "no" | |
| -- Apply transparency to terminal | |
| vim.cmd([[ | |
| highlight TermCursor guibg=NONE ctermbg=NONE | |
| highlight TermCursorNC guibg=NONE ctermbg=NONE | |
| ]]) | |
| end, | |
| }) | |
| -- Startup message | |
| vim.api.nvim_create_autocmd("VimEnter", { | |
| callback = function() | |
| Snacks.notify("🍿 Snacks Neovim loaded! Press <leader>t or <C-/> for terminal", { | |
| title = "Welcome", | |
| timeout = 3000, | |
| }) | |
| end, | |
| }) | |
| -- Make sure transparent background is applied | |
| vim.defer_fn(function() | |
| vim.cmd([[ | |
| highlight Normal guibg=NONE ctermbg=NONE | |
| highlight NonText guibg=NONE ctermbg=NONE | |
| highlight LineNr guibg=NONE ctermbg=NONE | |
| highlight SignColumn guibg=NONE ctermbg=NONE | |
| highlight FloatBorder guibg=NONE ctermbg=NONE | |
| highlight NormalFloat guibg=NONE ctermbg=NONE | |
| ]]) | |
| end, 100) | |
| -- Custom terminal commands | |
| vim.api.nvim_create_user_command("Term", function(opts) | |
| Snacks.terminal(opts.args) | |
| end, { nargs = "*", desc = "Open terminal with command" }) | |
| vim.api.nvim_create_user_command("TermFloat", function(opts) | |
| Snacks.terminal(opts.args, { win = { position = "float" } }) | |
| end, { nargs = "*", desc = "Open floating terminal with command" }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment