Changes to be committed:

renamed:    nvim/init.lua -> init.lua
  renamed:    install.sh -> install
  renamed:    nvim/lua/buffer-tabs.lua -> lua/buffer-tabs.lua
  renamed:    nvim/lua/colorschemes.lua -> lua/colorschemes.lua
  renamed:    nvim/lua/completions.lua -> lua/completions.lua
  renamed:    nvim/lua/file-tree.lua -> lua/file-tree.lua
  renamed:    nvim/lua/fuzzy-finder.lua -> lua/fuzzy-finder.lua
  renamed:    nvim/lua/keybinds.lua -> lua/keybinds.lua
  renamed:    nvim/lua/lsp-config.lua -> lua/lsp-config.lua
  renamed:    nvim/lua/lsp-format.lua -> lua/lsp-format.lua
  renamed:    nvim/lua/options.lua -> lua/options.lua
  renamed:    nvim/lua/plugins.lua -> lua/plugins.lua
  renamed:    nvim/lua/statusline.lua -> lua/statusline.lua
  renamed:    nvim/lua/syntax-highlight.lua -> lua/syntax-highlight.lua
  renamed:    nvim/lua/terminal.lua -> lua/terminal.lua
This commit is contained in:
Arkaprabha Chakraborty
2023-03-08 15:14:47 +05:30
parent 6f4821c527
commit 91c4cfbdd8
15 changed files with 6 additions and 2 deletions

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

140
lua/colorschemes.lua Normal file
View File

@@ -0,0 +1,140 @@
local colorscheme = "nord"
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
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
vim.cmd.colorscheme("catppuccin")
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
vim.o.background = "dark" -- or "light" for light mode
vim.cmd([[colorscheme gruvbox]])
end
if colorscheme == "nord" then
local ok, nord = pcall(require, "nord")
if not ok then
return
end
vim.cmd([[colorscheme nord]])
end

86
lua/completions.lua Normal file
View File

@@ -0,0 +1,86 @@
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" }),
},
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "path" },
},
confirm_opts = {
behavior = cmp.ConfirmBehavior.Replace,
select = false,
},
experimental = {
ghost_text = false,
},
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
local lk_ok, lspkind = pcall(require, "lspkind")
if not lk_ok then
return
end
local kind = 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,
},
})

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

@@ -0,0 +1,73 @@
-- 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 = ":t",
indent_width = 2,
},
filters = {
dotfiles = false,
git_clean = false,
no_buffer = false,
exclude = {},
},
actions = {
open_file = {
resize_window = true,
},
},
update_focused_file = {
enable = true,
update_cwd = false,
ignore_list = {},
},
git = {
enable = true,
ignore = false,
show_on_dirs = true,
show_on_open_dirs = true,
timeout = 200,
},
})
-- 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
},
})

54
lua/keybinds.lua Normal file
View File

@@ -0,0 +1,54 @@
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 commands
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", "<S-t>", ":tabnew<CR>", opts)
bind("n", "<S-c>", ":tabclose<CR>", opts)
bind("n", "<S-n>", ":tabprev<CR>", opts)
bind("n", "<S-m>", ":tabnext<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)

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

@@ -0,0 +1,52 @@
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", "pyright", "marksman" },
})
local cnl_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
if not cnl_ok then
return
end
local capabilities = 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,
})

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

@@ -0,0 +1,33 @@
local ok, null_ls = pcall(require, "null-ls")
if not ok then
return
end
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
require("null-ls").setup({
sources = {
null_ls.builtins.formatting.rustfmt,
null_ls.builtins.formatting.stylua,
null_ls.builtins.formatting.black,
null_ls.builtins.formatting.prettier,
null_ls.builtins.formatting.clang_format,
},
-- 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()
vim.lsp.buf.format({
bufnr = bufnr,
filter = function()
return client.name == "null-ls"
end,
})
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"

61
lua/plugins.lua Normal file
View File

@@ -0,0 +1,61 @@
local ok, packer = pcall(require, "packer")
if not ok then
return
end
packer.startup(function(use)
-- Nord colorscheme
use("shaunsingh/nord.nvim")
-- 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" }, tag = "nightly" })
-- 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.x", requires = { { "nvim-lua/plenary.nvim" } } })
-- LSP manager
use("williamboman/mason.nvim")
use("williamboman/mason-lspconfig.nvim")
use("neovim/nvim-lspconfig")
-- Formatting
use("jose-elias-alvarez/null-ls.nvim")
-- Snippets
use("L3MON4D3/LuaSnip") --snippet engine
use("rafamadriz/friendly-snippets") -- a bunch of snippets to use
-- 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("hrsh7th/cmp-nvim-lsp")
-- Syntax highlighting
use("nvim-treesitter/nvim-treesitter")
-- Rust tools
--use("simrat39/rust-tools.nvim")
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",
},
})