diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e033bc6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +lazy-lock.json diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..5026131 --- /dev/null +++ b/init.lua @@ -0,0 +1,8 @@ +require("zzz.core") +require("zzz.lazy") + +-- If using Windows, +-- Set shell to Powershell +if jit.os == "Windows" then + vim.o.shell = "powershell" +end diff --git a/lua/zzz/core/init.lua b/lua/zzz/core/init.lua new file mode 100644 index 0000000..14b4b77 --- /dev/null +++ b/lua/zzz/core/init.lua @@ -0,0 +1,2 @@ +require("zzz.core.keymaps") +require("zzz.core.options") diff --git a/lua/zzz/core/keymaps.lua b/lua/zzz/core/keymaps.lua new file mode 100644 index 0000000..e620d1f --- /dev/null +++ b/lua/zzz/core/keymaps.lua @@ -0,0 +1,81 @@ +------------------ +-- Key bindings -- +------------------ +vim.g.mapleader=" " + +-- TOGGLE NETRW SIDEBAR +local nw = {} + +function ToggleVExplorer() + if nw.expl_buf_num then + local expl_win_num = vim.fn.bufwinnr(nw.expl_buf_num) + local cur_win_num = vim.fn.winnr() + + if expl_win_num ~= -1 then + while expl_win_num ~= cur_win_num do + vim.cmd('wincmd w') + cur_win_num = vim.fn.winnr() + end + vim.cmd('close') + end + + nw.expl_buf_num = nil + else + vim.cmd('Vexplore') + nw.expl_buf_num = vim.fn.bufnr('%') + end +end + +-- Map e to call ToggleVExplorer +vim.keymap.set('n', 'e', ':lua ToggleVExplorer()', { silent = true }) + +-- TOGGLE TERMINAL +local tw = {} + +function ToggleTerm() + if tw.expl_buf_num then + local expl_win_num = vim.fn.bufwinnr(tw.expl_buf_num) + local cur_win_num = vim.fn.winnr() + + if expl_win_num ~= -1 then + while expl_win_num ~= cur_win_num do + vim.cmd('wincmd w') + cur_win_num = vim.fn.winnr() + end + vim.cmd('close') + end + + tw.expl_buf_num = nil + else + vim.cmd('split') + vim.cmd('terminal') + vim.cmd('res 20_') + tw.expl_buf_num = vim.fn.bufnr('%') + end +end + +-- Map t to call ToggleTerm +vim.keymap.set('n', 't', ':lua ToggleTerm()', { silent = true }) + +-- WINDOW NAVIGATION +vim.api.nvim_set_keymap('t', '', 'h', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('t', '', 'j', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('t', '', 'k', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('t', '', 'l', { noremap = true, silent = true }) + +vim.api.nvim_set_keymap('i', '', 'h', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('i', '', 'j', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('i', '', 'k', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('i', '', 'l', { noremap = true, silent = true }) + +vim.api.nvim_set_keymap('n', '', 'h', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', 'j', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', 'k', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', 'l', { noremap = true, silent = true }) + +-- TELESCOPE +vim.keymap.set('n', 'fd', ":Telescope lsp_document_symbols", {silent = true}) +vim.keymap.set('n', 'ff', ":Telescope find_files", { silent = true }) +vim.keymap.set('n', 'fg', ":Telescope live_grep", { silent = true }) +vim.keymap.set('n', 'fb', ":Telescope buffers", { silent = true }) +vim.keymap.set('n', 'fh', ":Telescope help_tags", { silent = true }) diff --git a/lua/zzz/core/options.lua b/lua/zzz/core/options.lua new file mode 100644 index 0000000..5bf63b3 --- /dev/null +++ b/lua/zzz/core/options.lua @@ -0,0 +1,24 @@ +----------------- +-- Options -- +----------------- + +-- UI +vim.opt.termguicolors = true +vim.opt.number = true -- Shows line numbers +vim.opt.showmatch = true -- Highlights matching brace pairs +vim.opt.cursorline = true -- Highlight cursor line underneath the cursor horizontally +vim.opt.splitbelow = true -- open new vertical split bottom +vim.opt.splitright = true -- open new horizontal splits right + +-- Netrw +vim.g.netrw_banner = 0 +vim.g.netrw_winsize = -28 +vim.g.netrw_liststyle = 3 -- Set netrw to tree view +vim.g.netrw_browse_split = 4 + +-- Tab +vim.opt.tabstop = 4 -- Sets number of spaces a tab uses +vim.opt.softtabstop = 4 -- Number of spacesin tab when editing +vim.opt.shiftwidth = 4 -- Insert 4 spaces on a tab +vim.opt.expandtab = true -- Tabs are spaces, mainly because of python + diff --git a/lua/zzz/lazy.lua b/lua/zzz/lazy.lua new file mode 100644 index 0000000..cb4e270 --- /dev/null +++ b/lua/zzz/lazy.lua @@ -0,0 +1,22 @@ +-- Lazy setup +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", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +require("lazy").setup("zzz.plugins") + +-- Specify startup theme +-- Default: bamboo +vim.cmd([[colorscheme poimandres]]) + +-- Enable transparency +vim.cmd("TransparentEnable") diff --git a/lua/zzz/plugins/colorscheme.lua b/lua/zzz/plugins/colorscheme.lua new file mode 100644 index 0000000..c24928b --- /dev/null +++ b/lua/zzz/plugins/colorscheme.lua @@ -0,0 +1,26 @@ +return { + -- Nightfox + { + "EdenEast/nightfox.nvim", + }, + -- Poimandres + { + 'olivercederborg/poimandres.nvim', + lazy = false, + priority = 1000, + config = function() + require('poimandres').setup { } + end, + }, + -- Tokyonight + { + "folke/tokyonight.nvim", + --lazy = false, + --priority = 1000, + }, + -- VS Code + { + "askfiy/visual_studio_code", + }, +} + diff --git a/lua/zzz/plugins/lualine.lua b/lua/zzz/plugins/lualine.lua new file mode 100644 index 0000000..6098b15 --- /dev/null +++ b/lua/zzz/plugins/lualine.lua @@ -0,0 +1,7 @@ +return { + "nvim-lualine/lualine.nvim", + lazy = false, + config = function() + require('lualine').setup() + end, +} diff --git a/lua/zzz/plugins/mason.lua b/lua/zzz/plugins/mason.lua new file mode 100644 index 0000000..b24974d --- /dev/null +++ b/lua/zzz/plugins/mason.lua @@ -0,0 +1,54 @@ +return { + "williamboman/mason.nvim", + dependencies = { + "williamboman/mason-lspconfig.nvim", + "neovim/nvim-lspconfig", + }, + config = function() + local mason = require("mason") + local mason_lspconfig = require("mason-lspconfig") + mason.setup({ + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗" + } + } + }) + + mason_lspconfig.setup({ + -- list of servers to automatically install + ensure_installed = { + "clangd", + "cmake", + "omnisharp", + "golangci_lint_ls", + "html", + "cssls", + "lua_ls", + "jsonls" + }, + automatic_installation = true, + }) + -- Setup installed servers + mason_lspconfig.setup_handlers({ + function(server_name) + require("lspconfig")[server_name].setup {} + end, + -- Lua server config + ["lua_ls"] = function () + local lspconfig = require("lspconfig") + lspconfig.lua_ls.setup { + settings = { + Lua = { + diagnostics = { + globals = { "vim" } + } + } + } + } + end, + }) + end, +} diff --git a/lua/zzz/plugins/nvim-cmp.lua b/lua/zzz/plugins/nvim-cmp.lua new file mode 100644 index 0000000..c03d259 --- /dev/null +++ b/lua/zzz/plugins/nvim-cmp.lua @@ -0,0 +1,53 @@ +return { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "L3MON4D3/LuaSnip", + "saadparwaiz1/cmp_luasnip", + "rafamadriz/friendly-snippets", + "onsails/lspkind.nvim", + }, + config = function() + local cmp = require("cmp") + local luasnip = require("luasnip") + local lspkind = require("lspkind") + require("luasnip.loaders.from_vscode").lazy_load() + + cmp.setup({ + completion = { + completeopt = "menu,menuone,preview,noselect", + }, + snippet = { -- configure how nvim-cmp interacts with snippet engine + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_prev_item(), -- previous suggestion + [""] = cmp.mapping.select_next_item(), -- next suggestion + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), -- show completion suggestions + [""] = cmp.mapping.abort(), -- close completion window + [""] = cmp.mapping.confirm({ select = false }), + }), + -- sources for autocompletion + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, -- snippets + { name = "buffer" }, -- text within current buffer + { name = "path" }, -- file system paths + }), + -- configure lspkind for vs-code like pictograms in completion menu + formatting = { + format = lspkind.cmp_format({ + maxwidth = 50, + ellipsis_char = "...", + }), + }, + }) + end, +} diff --git a/lua/zzz/plugins/startup.lua b/lua/zzz/plugins/startup.lua new file mode 100644 index 0000000..c754cc1 --- /dev/null +++ b/lua/zzz/plugins/startup.lua @@ -0,0 +1,7 @@ +return { + "startup-nvim/startup.nvim", + requires = {"nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim"}, + config = function() + require"startup".setup() + end +} diff --git a/lua/zzz/plugins/telescope.lua b/lua/zzz/plugins/telescope.lua new file mode 100644 index 0000000..5c85eb7 --- /dev/null +++ b/lua/zzz/plugins/telescope.lua @@ -0,0 +1,12 @@ +return { + { + "nvim-telescope/telescope.nvim", + dependencies = { 'nvim-lua/plenary.nvim' }, + opts = { + defaults = { + layout_strategy = "horizontal", + sorting_strategy = "ascending", + }, + }, + }, +} diff --git a/lua/zzz/plugins/transparent.lua b/lua/zzz/plugins/transparent.lua new file mode 100644 index 0000000..42f049e --- /dev/null +++ b/lua/zzz/plugins/transparent.lua @@ -0,0 +1,3 @@ +return { + "xiyaowong/transparent.nvim", +} diff --git a/lua/zzz/plugins/trouble.lua b/lua/zzz/plugins/trouble.lua new file mode 100644 index 0000000..73683c5 --- /dev/null +++ b/lua/zzz/plugins/trouble.lua @@ -0,0 +1,4 @@ +return { + "folke/trouble.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, +}