-- Bootstrap lazy.nvim if it's not installed 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", lazypath, }) end vim.opt.rtp:prepend(lazypath) -- Plugin setup using lazy.nvim require("lazy").setup({ { "voldikss/vim-floaterm", lazy = false, }, { "preservim/nerdtree", lazy = false, }, { "junegunn/vim-easy-align", lazy = false, }, {'akinsho/toggleterm.nvim', version = "*", config = true}, { "folke/tokyonight.nvim", lazy = false, -- load immediately priority = 1000, -- make sure it loads first config = function() require("tokyonight").setup({ style = "night", transparent = true, }) vim.cmd("colorscheme tokyonight") end }, { "neovim/nvim-lspconfig", config = function() -- Basic on_attach function for keybindings local on_attach = function(_, bufnr) local opts = { noremap = true, silent = true, buffer = bufnr } local keymap = vim.keymap.set keymap("n", "gd", vim.lsp.buf.definition, opts) keymap("n", "K", vim.lsp.buf.hover, opts) keymap("n", "rn", vim.lsp.buf.rename, opts) keymap("n", "ca", vim.lsp.buf.code_action, opts) keymap("n", "gr", vim.lsp.buf.references, opts) end -- Basic LSP servers setup local lspconfig = require("lspconfig") -- Example: Python (pyright) lspconfig.pyright.setup { on_attach = on_attach, } -- Example: TypeScript/JavaScript (tsserver) lspconfig.ts_ls.setup { on_attach = on_attach, } -- Example: Lua (for Neovim config dev) lspconfig.lua_ls.setup { on_attach = on_attach, settings = { Lua = { diagnostics = { globals = { "vim" }, }, }, }, } lspconfig.dockerls.setup { on_attach = on_attach, } lspconfig.terraformls.setup { on_attach = on_attach, } lspconfig.phpactor.setup { on_attach = on_attach, cmd = { "phpactor", "language-server" }, filetypes = { "php" }, root_dir = lspconfig.util.root_pattern("composer.json", ".git"), } end }, { "hrsh7th/nvim-cmp", dependencies = { "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-buffer", "hrsh7th/cmp-path", "L3MON4D3/LuaSnip", -- snippet engine "saadparwaiz1/cmp_luasnip", -- snippet completions }, config = function() local cmp = require("cmp") local luasnip = require("luasnip") cmp.setup({ snippet = { expand = function(args) luasnip.lsp_expand(args.body) end, }, mapping = { -- Confirm selection (only if one is explicitly selected) [''] = cmp.mapping(function(fallback) if cmp.visible() and cmp.get_selected_entry() then cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }) else fallback() end end, { 'i', 's' }), -- Navigate the menu [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() else fallback() end end, { 'i', 's' }), [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() else fallback() end end, { 'i', 's' }), }, -- Avoid auto-selecting the first item completion = { completeopt = 'menu,menuone,noinsert', }, sources = cmp.config.sources({ { name = "nvim_lsp" }, { name = "luasnip" }, { name = "buffer" }, { name = "path" }, }), }) end }, { "williamboman/mason.nvim", config = true }, { "williamboman/mason-lspconfig.nvim", dependencies = { "mason.nvim", "neovim/nvim-lspconfig" }, config = function() require("mason").setup() require("mason-lspconfig").setup({ ensure_installed = { "lua_ls", "pyright", "tsserver", "dockerls", "terraformls", "phpactor", }, automatic_installation = true, }) end, }, { 'lewis6991/gitsigns.nvim', config = function() require('gitsigns').setup({ current_line_blame = true, current_line_blame_opts = { delay = 300, virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align' }, current_line_blame_formatter = ', - ', }) end, } }) -- Set key vim.g.mapleader = " " -- Floaterm appearance (optional) vim.g.floaterm_width = 0.9 vim.g.floaterm_height = 0.85 vim.g.floaterm_borderchars = '─│─│╭╮╯╰' -- g: open Floaterm running lazygit vim.keymap.set("n", "g", function() vim.cmd("FloatermNew --name=lazygit --autoclose=2 lazygit") end, { noremap = true, silent = true }) -- : toggle NERDTree in current window vim.keymap.set("n", "", ":NERDTreeToggle", { noremap = true, silent = true }) -- EasyAlign key mappings vim.keymap.set("x", "ga", ":EasyAlign", { noremap = true, silent = true }) vim.keymap.set("n", "ga", "(EasyAlign)") require("toggleterm").setup { open_mapping = [[]], direction = "horizontal", -- or "float" or "vertical" start_in_insert = true, insert_mappings = true, terminal_mappings = true, close_on_exit = true, shell = vim.o.shell -- use your default shell } -- Set 2 spaces and no tabs for Terraform files vim.api.nvim_create_autocmd("FileType", { pattern = "terraform", callback = function() vim.bo.expandtab = true -- use spaces instead of tabs vim.bo.shiftwidth = 2 -- size of an indent vim.bo.softtabstop = 2 -- number of spaces per end, }) vim.opt.clipboard = "unnamedplus" vim.opt.termguicolors = true vim.opt.signcolumn = "yes" vim.opt.number = true -- Enable absolute line numbers vim.opt.relativenumber = false -- Disable relative line numbers vim.opt.colorcolumn = "80"