commit 38e29f01ecb410eda6c51d21c065c04a8ec9695e Author: Arkaprabha Chakraborty Date: Sun Mar 5 06:47:18 2023 +0530 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d7ad043 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +plugin/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..b37d22a --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +![neolite.png](blob/neolite.png) + +# Neolite + +## About + +Neolite is a fast and lightweight configuration of Neovim. + +## Installation + +- Clone the repository + +`git clone https://github.com/arkorty/Neolite.git` + +- Run the Install Script + +`./install.sh` + +- Close Neovim after Packer has installed all the required plugins + +- Run Neovim with Mason command + +`nvim +Mason` diff --git a/blob/neolite.png b/blob/neolite.png new file mode 100644 index 0000000..b6ff6c4 Binary files /dev/null and b/blob/neolite.png differ diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..5b38017 --- /dev/null +++ b/init.lua @@ -0,0 +1,13 @@ +require("plugins") +require("options") +require("keybinds") +require("statusline") +require("completions") +require("colorschemes") +require("file-tree") +require("terminal") +require("buffer-tabs") +require("fuzzy-finder") +require("syntax-highlight") +require("lsp-config") +require("lsp-format") diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..8ab44a2 --- /dev/null +++ b/install.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +git clone --depth 1 https://github.com/wbthomason/packer.nvim\ + ~/.local/share/nvim/site/pack/packer/start/packer.nvim + +[ -d "~/.config/nvim" ] && mv ~/.config/nvim ~/.config/nvim.bak + +[ ! -d "~/.config/nvim" ] && mkdir -p ~/.config/nvim + +cp -r init.lua lua ~/.config/nvim + +nvim +PackerSync diff --git a/lua/buffer-tabs.lua b/lua/buffer-tabs.lua new file mode 100644 index 0000000..3240452 --- /dev/null +++ b/lua/buffer-tabs.lua @@ -0,0 +1,13 @@ +-- set termguicolors to enable highlight groups +vim.opt.termguicolors = true + +local ok, bufferline = pcall(require, "bufferline") +if not ok then + return +end + +bufferline.setup({ + options = { + mode = "tabs", -- set to "buffers" to only show buffers instead + }, +}) diff --git a/lua/colorschemes.lua b/lua/colorschemes.lua new file mode 100644 index 0000000..f70505f --- /dev/null +++ b/lua/colorschemes.lua @@ -0,0 +1,130 @@ +local colorscheme = "onedark" + +if colorscheme == "onedark" then + -- Onedark Default Configuration + local ok, onedark = pcall(require, "onedark") + if not ok then + return + end + onedark.setup({ + -- Main options -- + style = "darker", -- Default theme style. Choose between 'dark', 'darker', 'cool', 'deep', 'warm', 'warmer' and 'light' + transparent = false, -- Show/hide background + term_colors = true, -- Change terminal color as per the selected theme style + ending_tildes = false, -- Show the end-of-buffer tildes. By default they are hidden + cmp_itemkind_reverse = false, -- reverse item kind highlights in cmp menu + -- toggle theme style --- + toggle_style_key = nil, -- keybind to toggle theme style. Leave it nil to disable it, or set it to a string, for example 'ts' + toggle_style_list = { "dark", "darker", "cool", "deep", "warm", "warmer", "light" }, -- List of styles to toggle between + -- Change code style --- + -- Options are italic, bold, underline, none + -- You can configure multiple style with comma seperated, For e.g., keywords = 'italic,bold' + code_style = { + comments = "italic", + keywords = "none", + functions = "none", + strings = "none", + variables = "none", + }, + -- Lualine options -- + lualine = { + transparent = false, -- lualine center bar transparency + }, + -- Custom Highlights -- + colors = {}, -- Override default colors + highlights = {}, -- Override highlight groups + -- Plugins Config -- + diagnostics = { + darker = true, -- darker colors for diagnostic + undercurl = true, -- use undercurl instead of underline for diagnostics + background = true, -- use background color for virtual text + }, + }) + + -- Load One Dark + require("onedark").load() +end + +if colorscheme == "catppuccin" then + -- Catppuccin + local ok, catppuccin = pcall(require, "catppuccin") + if not ok then + return + end + catppuccin.setup({ + flavour = "mocha", -- latte, frappe, macchiato, mocha + background = { + -- :h background + light = "latte", + dark = "mocha", + }, + transparent_background = false, + show_end_of_buffer = false, -- show the '~' characters after the end of buffers + term_colors = false, + dim_inactive = { + enabled = false, + shade = "dark", + percentage = 0.15, + }, + no_italic = false, -- Force no italic + no_bold = false, -- Force no bold + styles = { + comments = { "italic" }, + conditionals = { "italic" }, + loops = {}, + functions = {}, + keywords = {}, + strings = {}, + variables = {}, + numbers = {}, + booleans = {}, + properties = {}, + types = {}, + operators = {}, + }, + color_overrides = {}, + custom_highlights = {}, + integrations = { + cmp = true, + gitsigns = true, + nvimtree = true, + telescope = true, + notify = false, + mini = false, + -- For more plugins integrations please scroll down (https://github.com/catppuccin/nvim#integrations) + }, + }) + + -- Load Catppuccin + require("catppuccin").load() +end + +if colorscheme == "gruvbox" then + -- setup must be called before loading the colorscheme + -- Default options: + local ok, gruvbox = pcall(require, "gruvbox") + if not ok then + return + end + + gruvbox.setup({ + undercurl = true, + underline = true, + bold = true, + italic = true, + strikethrough = true, + invert_selection = false, + invert_signs = false, + invert_tabline = false, + invert_intend_guides = false, + inverse = true, -- invert background for search, diffs, statuslines and errors + contrast = "", -- can be "hard", "soft" or empty string + palette_overrides = {}, + overrides = {}, + dim_inactive = false, + transparent_mode = false, + }) + + -- Load Gruvbox + require("gruvbox").load() +end diff --git a/lua/completions.lua b/lua/completions.lua new file mode 100644 index 0000000..1f7151b --- /dev/null +++ b/lua/completions.lua @@ -0,0 +1,82 @@ +local ok, cmp = pcall(require, "cmp") +if not ok then + return +end + +local luasnip_ok, luasnip = pcall(require, "luasnip") +if not luasnip_ok then + return +end + +local luasnip_vscode_ok, luasnip_vscode = pcall(require, "luasnip/loaders/from_vscode") +if not luasnip_vscode_ok then + return +end + +local has_words_before = function() + unpack = unpack or table.unpack + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil +end + +luasnip_vscode.lazy_load() + +cmp.setup({ + view = { + --entries = { name = "custom", selection_order = "near_cursor" }, + }, + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) -- For `luasnip` users. + end, + }, + mapping = { + [""] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() + -- they way you will only jump inside the snippet region + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + }, + formatting = { + fields = { "kind", "abbr", "menu" }, + format = function(entry, vim_item) + local kind = require("lspkind").cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, vim_item) + local strings = vim.split(kind.kind, "%s", { trimempty = true }) + kind.kind = " " .. (strings[1] or "") .. " " + kind.menu = " (" .. (strings[2] or "") .. ")" + + return kind + end, + }, + sources = { + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "path" }, + }, + confirm_opts = { + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }, + experimental = { + ghost_text = false, + }, +}) diff --git a/lua/file-tree.lua b/lua/file-tree.lua new file mode 100644 index 0000000..3610a47 --- /dev/null +++ b/lua/file-tree.lua @@ -0,0 +1,67 @@ +-- disable netrw +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + +-- set termguicolors to enable highlight groups +vim.opt.termguicolors = true + +local ok, nvim_tree = pcall(require, "nvim-tree") +if not ok then + return +end + +-- file tree options +nvim_tree.setup({ + sort_by = "case_sensitive", + update_cwd = true, + renderer = { + group_empty = true, + root_folder_label = ":~:s?$?/..?", + }, + filters = { + dotfiles = true, + }, + view = { + side = "left", + width = 30, + hide_root_folder = false, + }, + actions = { + open_file = { + resize_window = true, + }, + }, + update_focused_file = { + enable = true, + update_cwd = true, + ignore_list = {}, + }, +}) + +-- open file tree at startup +local function open_nvim_tree(data) + -- buffer is a directory + local directory = vim.fn.isdirectory(data.file) == 1 + + if not directory then + return + end + + -- create a new, empty buffer + vim.cmd.enew() + + -- wipe the directory buffer + vim.cmd.bw(data.buf) + + -- change to the directory + vim.cmd.cd(data.file) + + -- open the tree + local api_ok, api = pcall(require, "nvim-tree.api") + if not api_ok then + return + end + api.tree.open() +end + +vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree }) diff --git a/lua/fuzzy-finder.lua b/lua/fuzzy-finder.lua new file mode 100644 index 0000000..0820942 --- /dev/null +++ b/lua/fuzzy-finder.lua @@ -0,0 +1,38 @@ +local status_ok, telescope = pcall(require, "telescope") +if not status_ok then + return +end + +telescope.setup({ + defaults = { + -- Default configuration for telescope goes here: + -- config_key = value, + mappings = { + i = { + -- map actions.which_key to (default: ) + -- actions.which_key shows the mappings for your picker, + -- e.g. git_{create, delete, ...}_branch for the git_branches picker + [""] = "which_key", + }, + }, + }, + pickers = { + -- Default configuration for builtin pickers goes here: + -- picker_name = { + -- picker_config_key = value, + -- ... + -- } + -- Now the picker_config_key will be applied every time you call this + -- builtin picker + find_files = { + hidden = false, + }, + }, + extensions = { + -- Your extension configuration goes here: + -- extension_name = { + -- extension_config_key = value, + -- } + -- please take a look at the readme of the extension you want to configure + }, +}) diff --git a/lua/keybinds.lua b/lua/keybinds.lua new file mode 100644 index 0000000..33122c8 --- /dev/null +++ b/lua/keybinds.lua @@ -0,0 +1,75 @@ +local opts = { noremap = true, silent = true } + +--local term_opts = { silent = true } +local bind = vim.api.nvim_set_keymap +local set = vim.keymap.set + +-- bind a leader key +bind("", ";", "", opts) -- undo any previous bind +vim.g.mapleader = ";" +vim.g.maplocalleader = ";" + +-- Modes +-- Normal Mode = 'n', +-- Insert Mode = 'i', +-- Visual Mode = 'v', +-- Visual Block Mode = 'x', +-- Terminal Mode = 't', +-- Command Mode = 'c', + +-- Normal mode -- +-- Basic functions +bind("n", "w", ":w", opts) +bind("n", "e", ":q", opts) +bind("n", "q", ":qa", opts) + +-- Nvim tree +bind("n", "", ":NvimTreeToggle", opts) + +-- Fuzzy finder +local telescope_status_ok, telescope = pcall(require, "telescope.builtin") +if telescope_status_ok then + set("n", "ff", telescope.find_files, {}) + set("n", "fg", telescope.live_grep, {}) + set("n", "fb", telescope.buffers, {}) + set("n", "fh", telescope.help_tags, {}) +end + +-- Better tabs +--bind("n", "n", ":tabnew", opts) +--bind("n", "c", ":tabclose", opts) +--bind("n", "l", ":tabnext", opts) +--bind("n", "h", ":tabprev", opts) + +-- Better window navigation +bind("n", "", "h", opts) +bind("n", "", "j", opts) +bind("n", "", "k", opts) +bind("n", "", "l", opts) + +-- Resize with arrows +bind("n", "", ":resize -2", opts) +bind("n", "", ":resize +2", opts) +bind("n", "", ":vertical resize -2", opts) +bind("n", "", ":vertical resize +2", opts) + +-- Navigate tabs +bind("n", "", ":tabnew", opts) +bind("n", "", ":tabclose", opts) +bind("n", "", ":tabp", opts) +bind("n", "", ":tabn", opts) + +-- Visual -- +-- Stay in indent mode +bind("v", "<", "", ">gv", opts) + +-- Move text up and down +bind("v", "", ":m .+1==", opts) +bind("v", "", ":m .-2==", opts) +bind("v", "p", '"_dP', opts) + +-- Visual Block -- +-- Move text up and down +bind("x", "J", ":move '>+1gv-gv", opts) +bind("x", "K", ":move '<-2gv-gv", opts) diff --git a/lua/lsp-config.lua b/lua/lsp-config.lua new file mode 100644 index 0000000..239f559 --- /dev/null +++ b/lua/lsp-config.lua @@ -0,0 +1,45 @@ +local lspconfig_status_ok, lspconfig = pcall(require, "lspconfig") +if not lspconfig_status_ok then + return +end + +local mason_status_ok, mason = pcall(require, "mason") +if not mason_status_ok then + return +end + +local mason_lspconfig_status_ok, mason_lspconfig = pcall(require, "mason-lspconfig") +if not mason_lspconfig_status_ok then + return +end + +mason.setup({}) + +mason_lspconfig.setup({ + ensure_installed = { "lua_ls", "rust_analyzer", "clangd" }, +}) + +local capabilities = require("cmp_nvim_lsp").default_capabilities() + +mason_lspconfig.setup_handlers({ + function(server) + lspconfig[server].setup({ capabilities = capabilities }) + lspconfig.lua_ls.setup({ + capabilities = capabilities, + settings = { + Lua = { + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = { "vim" }, + }, + }, + }, + }) + end, + ["rust_analyzer"] = function() + local rt_ok, rust_tools = pcall(require, "rust-tools") + if rt_ok then + rust_tools.setup({}) + end + end +}) diff --git a/lua/lsp-format.lua b/lua/lsp-format.lua new file mode 100644 index 0000000..0ec2dec --- /dev/null +++ b/lua/lsp-format.lua @@ -0,0 +1,29 @@ +local ok, null_ls = pcall(require, "null-ls") +if not ok then + return +end + +local formatting = null_ls.builtins.formatting + +local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) +null_ls.setup({ + sources = { + formatting.rustfmt, + formatting.stylua, + formatting.black, + formatting.prettier, + }, -- you can reuse a shared lspconfig on_attach callback here + on_attach = function(client, bufnr) + if client.supports_method("textDocument/formatting") then + vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + -- on 0.8, you should use vim.lsp.buf.format({ bufnr = bufnr }) instead + vim.lsp.buf.format({ bufnr = bufnr }) + end, + }) + end + end, +}) diff --git a/lua/options.lua b/lua/options.lua new file mode 100644 index 0000000..fb247f9 --- /dev/null +++ b/lua/options.lua @@ -0,0 +1,8 @@ +vim.o.tabstop = 4 +vim.o.shiftwidth = 4 +vim.o.expandtab = true +vim.o.relativenumber = true +vim.o.smartindent = true +vim.o.syntax = true +vim.o.cursorline = true +vim.o.signcolumn = "number" diff --git a/lua/plugins.lua b/lua/plugins.lua new file mode 100644 index 0000000..4a28c17 --- /dev/null +++ b/lua/plugins.lua @@ -0,0 +1,82 @@ +local ok, packer = pcall(require, "packer") +if not ok then + return +end + +packer.startup(function(use) + -- Onedark colorscheme + use({ "navarasu/onedark.nvim" }) + + -- Gruvbox colorscheme + use({ "ellisonleao/gruvbox.nvim" }) + + -- Catppuccin colorscheme + use({ "catppuccin/nvim", as = "catppuccin" }) + + -- Plugin manager + use({ "wbthomason/packer.nvim" }) + + -- Terminal + use({ "akinsho/toggleterm.nvim", tag = "*" }) + + -- File tree + use({ + "nvim-tree/nvim-tree.lua", + requires = { + "nvim-tree/nvim-web-devicons", -- optional, for file icons + }, + tag = "nightly", -- optional, updated every week. (see issue #1193) + }) + + -- Statusline + use({ + "nvim-lualine/lualine.nvim", + requires = { "kyazdani42/nvim-web-devicons", opt = true }, + }) + + -- Buffer tabs + use({ "akinsho/bufferline.nvim", tag = "v3.*", requires = "nvim-tree/nvim-web-devicons" }) + + use({ + "nvim-telescope/telescope.nvim", + tag = "0.1.1", + -- or , branch = '0.1.x', + requires = { { "nvim-lua/plenary.nvim" } }, + }) + + -- LSP manager + use({ "williamboman/mason.nvim" }) + use({ "williamboman/mason-lspconfig.nvim" }) + use({ "neovim/nvim-lspconfig" }) + + use({ "jose-elias-alvarez/null-ls.nvim" }) + + -- Completions + use("hrsh7th/nvim-cmp") -- The completion plugin + use("hrsh7th/cmp-buffer") -- buffer completions + use("hrsh7th/cmp-path") -- path completions + use("saadparwaiz1/cmp_luasnip") -- snippet completions + + use("onsails/lspkind.nvim") + use("windwp/nvim-autopairs") + use("hrsh7th/cmp-nvim-lsp") + + -- Snippets + use("L3MON4D3/LuaSnip") --snippet engine + use("rafamadriz/friendly-snippets") -- a bunch of snippets to use + + use({ + "nvim-treesitter/nvim-treesitter", + run = function() + local ts_update = require("nvim-treesitter.install").update({ with_sync = true }) + ts_update() + end, + }) + + --use 'neovim/nvim-lspconfig' + use 'simrat39/rust-tools.nvim' + + -- Debugging + --use 'nvim-lua/plenary.nvim' + use 'mfussenegger/nvim-dap' +end) diff --git a/lua/statusline.lua b/lua/statusline.lua new file mode 100644 index 0000000..515443d --- /dev/null +++ b/lua/statusline.lua @@ -0,0 +1,45 @@ +local ok, lualine = pcall(require, "lualine") +if not ok then + return +end + +lualine.setup({ + options = { + icons_enabled = true, + theme = "auto", + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = true, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + }, + }, + sections = { + lualine_a = { "mode" }, + lualine_b = { "branch", "diff", "diagnostics" }, + lualine_c = { "filename" }, + lualine_x = { "encoding", "fileformat", "filetype" }, + lualine_y = { "progress" }, + lualine_z = { "location" }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { "filename" }, + lualine_x = { "location" }, + lualine_y = {}, + lualine_z = {}, + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = {}, +}) diff --git a/lua/syntax-highlight.lua b/lua/syntax-highlight.lua new file mode 100644 index 0000000..00a8a30 --- /dev/null +++ b/lua/syntax-highlight.lua @@ -0,0 +1,42 @@ +local ok, nvim_treesitter = pcall(require, "nvim-treesitter.configs") +if not ok then + return +end + +nvim_treesitter.setup({ + -- A list of parser names, or "all" (the four listed parsers should always be installed) + ensure_installed = { "c", "help", "lua", "vim", "cpp", "rust" }, + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, + -- Automatically install missing parsers when entering buffer + -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally + auto_install = true, + -- List of parsers to ignore installing (for "all") + ignore_install = { "javascript" }, + ---- If you need to change the installation directory of the parsers (see -> Advanced Setup) + -- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")! + + highlight = { + enable = true, + -- NOTE: these are the names of the parsers and not the filetype. (for example if you want to + -- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is + -- the name of the parser) + -- list of language that will be disabled + disable = { "" }, + -- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files + --disable = function(lang, buf) + -- local max_filesize = 100 * 1024 -- 100 KB + -- local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) + -- if ok and stats and stats.size > max_filesize then + -- return true + -- end + --end, + + -- Setting this to true will run `:h syntax` and tree-sitter at the same time. + -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). + -- Using this option may slow down your editor, and you may see some duplicate highlights. + -- Instead of true it can also be a list of languages + additional_vim_regex_highlighting = true, + }, + indent = { enable = true, disable = { "yaml" } }, +}) diff --git a/lua/terminal.lua b/lua/terminal.lua new file mode 100644 index 0000000..5fb7c49 --- /dev/null +++ b/lua/terminal.lua @@ -0,0 +1,16 @@ +local ok, toggleterm = pcall(require, "toggleterm") +if not ok then + return +end + +toggleterm.setup({ + open_mapping = [[]], + hide_numbers = true, + start_in_insert = true, + direction = "float", + close_on_exit = true, + shell = vim.o.shell, + float_opts = { + border = "curved", + }, +})