Initial commit

This commit is contained in:
Arkaprabha Chakraborty
2023-03-05 06:47:18 +05:30
commit 38e29f01ec
18 changed files with 721 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
plugin/

23
README.md Normal file
View File

@@ -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`

BIN
blob/neolite.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

13
init.lua Normal file
View File

@@ -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")

12
install.sh Executable file
View File

@@ -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

13
lua/buffer-tabs.lua Normal file
View File

@@ -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
},
})

130
lua/colorschemes.lua Normal file
View File

@@ -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 '<leader>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

82
lua/completions.lua Normal file
View File

@@ -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 = {
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = 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" }),
["<S-Tab>"] = 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,
},
})

67
lua/file-tree.lua Normal file
View File

@@ -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 })

38
lua/fuzzy-finder.lua Normal file
View File

@@ -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 <C-h> (default: <C-/>)
-- actions.which_key shows the mappings for your picker,
-- e.g. git_{create, delete, ...}_branch for the git_branches picker
["<C-h>"] = "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
},
})

75
lua/keybinds.lua Normal file
View File

@@ -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("", ";", "<Nop>", 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", "<Leader>w", ":w<CR>", opts)
bind("n", "<Leader>e", ":q<CR>", opts)
bind("n", "<Leader>q", ":qa<CR>", opts)
-- Nvim tree
bind("n", "<C-f>", ":NvimTreeToggle<CR>", opts)
-- Fuzzy finder
local telescope_status_ok, telescope = pcall(require, "telescope.builtin")
if telescope_status_ok then
set("n", "<Leader>ff", telescope.find_files, {})
set("n", "<Leader>fg", telescope.live_grep, {})
set("n", "<Leader>fb", telescope.buffers, {})
set("n", "<Leader>fh", telescope.help_tags, {})
end
-- Better tabs
--bind("n", "<Leader>n", ":tabnew<CR>", opts)
--bind("n", "<Leader>c", ":tabclose<CR>", opts)
--bind("n", "<Leader>l", ":tabnext<CR>", opts)
--bind("n", "<Leader>h", ":tabprev<CR>", opts)
-- Better window navigation
bind("n", "<C-Left>", "<C-w>h", opts)
bind("n", "<C-Down>", "<C-w>j", opts)
bind("n", "<C-Up>", "<C-w>k", opts)
bind("n", "<C-Right>", "<C-w>l", opts)
-- Resize with arrows
bind("n", "<C-k>", ":resize -2<CR>", opts)
bind("n", "<C-j>", ":resize +2<CR>", opts)
bind("n", "<C-l>", ":vertical resize -2<CR>", opts)
bind("n", "<C-h>", ":vertical resize +2<CR>", opts)
-- Navigate tabs
bind("n", "<S-t>", ":tabnew<CR>", opts)
bind("n", "<S-c>", ":tabclose<CR>", opts)
bind("n", "<S-n>", ":tabp<CR>", opts)
bind("n", "<S-m>", ":tabn<CR>", opts)
-- Visual --
-- Stay in indent mode
bind("v", "<", "<gv", opts)
bind("v", ">", ">gv", opts)
-- Move text up and down
bind("v", "<S-k>", ":m .+1<CR>==", opts)
bind("v", "<S-j>", ":m .-2<CR>==", opts)
bind("v", "p", '"_dP', opts)
-- Visual Block --
-- Move text up and down
bind("x", "J", ":move '>+1<CR>gv-gv", opts)
bind("x", "K", ":move '<-2<CR>gv-gv", opts)

45
lua/lsp-config.lua Normal file
View File

@@ -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
})

29
lua/lsp-format.lua Normal file
View File

@@ -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,
})

8
lua/options.lua Normal file
View File

@@ -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"

82
lua/plugins.lua Normal file
View File

@@ -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)

45
lua/statusline.lua Normal file
View File

@@ -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 = {},
})

42
lua/syntax-highlight.lua Normal file
View File

@@ -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" } },
})

16
lua/terminal.lua Normal file
View File

@@ -0,0 +1,16 @@
local ok, toggleterm = pcall(require, "toggleterm")
if not ok then
return
end
toggleterm.setup({
open_mapping = [[<C-\>]],
hide_numbers = true,
start_in_insert = true,
direction = "float",
close_on_exit = true,
shell = vim.o.shell,
float_opts = {
border = "curved",
},
})