Skip to content

Commit

Permalink
Title: Added autocompletion & other improvements.
Browse files Browse the repository at this point in the history
Description:
Added autocompletion feature using nvim-cmp
plugin and customised it with better aesthetics.
Reorganised the file structures and rice it even
further. Improved calls with protections.
Optimised the code and added some other
improvements.

CID: #7
  • Loading branch information
HacksPloiter committed Dec 9, 2023
1 parent e9f2cb1 commit 80d73f1
Show file tree
Hide file tree
Showing 12 changed files with 512 additions and 365 deletions.
32 changes: 32 additions & 0 deletions NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Notes
This file will contain some useful information about Nvim and Lua!


## Protected calls
You would have seen below code snippet.
```
local status_ok, configs = pcall(require, "pluginname")
if not status_ok then
return
else
-- Do something
end
```

How do you get this 'pluginname' if you didn't it from the documentation?
Remember it is not always the directory name or the git repo name.

Ok, so here is how to get it in case where repo name or directory name doesn't
work. Inside nvim, type
```
: set rtp?
```

It will show the runtime path of all the plugins. These can be used for those
protected calls.


## Pretty cool websites
https://github.com/rockerBOO/awesome-neovim
https://neovimcraft.com
https://dotfyle.com
47 changes: 32 additions & 15 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,40 @@
--================================-> START <-=================================--
-- File Imports --
--------------------------------------------------------------------------------
require('keyconfig') -- NVIM keymaps congis
require('optconfig') -- NVIM options configs
require('lazyconfig') -- NVIM Lazy configs
require('themeplugconfig') -- Installed theme and plugin configs
-- Core Config Imports
require('keyconfig') -- NVIM keymaps congis
require('optconfig') -- NVIM options configs
-- Lazy Config Imports
require('lazyconfig') -- NVIM Lazy configs
-- Theme Config Imports
require('draculaconfig') -- Theme Dracula configs
require('lunarconfig') -- Theme Lunar configs
require('onedarkproconfig') -- Theme Onedarkpro configs
-- Plugin Config Imports
require('lualineconfig') -- Plugin Lualine configs
require('nvimcmpconfig') -- Plugin nvim-cmp configs
require('nvimdashboardconfig') -- Plugin nvim-dashboard configs
require('nvimtreeconfig') -- Plugin nvim-tree configs
require('nvimtreesitterconfig') -- Plugin nvim-treesitter configs
--================================-> END <-===================================--


--================================-> START <-=================================--
-- BACKUP INFO - WHAT TO BACKUP --
-- FILE STRUCTURES & BACKUP INFO - WHAT TO BACKUP --
--------------------------------------------------------------------------------
-- $HOME/.config/nvim
-- |
-- |-- init.lua (✓)
-- |
-- |-- lua ---------
-- |------ keyconfig.lua (✓)
-- |------ optconfig.lua (✓)
-- |------ lazyconfig.lua (✓)
-- |------ themeplugconfig.lua (✓)
--
-- $HOME/.config/nvim
-- ├── 📂 init.lua (✓)
-- └── lua
-- └── config
-- ├── 📂 keyconfig.lua (✓)
-- ├── 📂 optconfig.lua (✓)
-- ├── 📂 lazyconfig.lua (✓)
-- ├── 📂 draculaconfig.lua (✓)
-- ├── 📂 lunarconfig.lua (✓)
-- ├── 📂 onedarkproconfig.lua (✓)
-- ├── 📂 lualineconfig.lua (✓)
-- ├── 📂 nvimcmpconfig.lua (✓)
-- ├── 📂 nvimdashboardconfig.lua (✓)
-- ├── 📂 nvimtreeconfig.lua (✓)
-- └── 📂 nvimtreesitterconfig.lua (✓)
--================================-> END <-===================================--
20 changes: 20 additions & 0 deletions lua/draculaconfig.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--****************************************************************************--
--* [draculaconfig.lua] *--
--* [THEME DRACULA CONFIG FILE] *--
--* [Author/Credit - Tanweer Ashif] *--
--* [LinkedIn/tanweerashif | GitHub/HacksPloiter | https://tanweerashif.com] *--
--****************************************************************************--


--================================-> START <-=================================--
-- Theme Dracula Configs --
--------------------------------------------------------------------------------
local status_ok, configs = pcall(require, "dracula")
if not status_ok then
return
else
-- vim.opt.syntax = "ON"
-- vim.opt.termguicolors = true
-- vim.cmd 'colorscheme dracula'
end
--================================-> END <-===================================--
80 changes: 43 additions & 37 deletions lua/lazyconfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ vim.opt.rtp:prepend(lazypath)
vim.cmd([[
augroup lazy_user_config
autocmd!
autocmd BufWritePost lazyconfig.lua lua vim.cmd("Lazy install")
autocmd BufWritePost lazyconfig.lua lua vim.cmd("Lazy clean")
autocmd BufWritePost lazyconfig.lua lua vim.cmd("Lazy sync")
augroup end
]])
Expand All @@ -38,46 +40,50 @@ vim.cmd([[

--================================-> START <-=================================--
-- Install themes and plugins here. --
-- Use a protected call so we don't error out on first use --
--------------------------------------------------------------------------------
local status_ok, configs = pcall(require, "lazy")
if not status_ok then
return
else
return configs.setup({
-- Plugins Start --
{'nvim-telescope/telescope.nvim',
branch = '0.1.x',
dependencies = {'nvim-lua/plenary.nvim'},
},
{'nvim-tree/nvim-tree.lua',
dependencies = {'nvim-tree/nvim-web-devicons'}
},
{'nvim-treesitter/nvim-treesitter', build = ':TSUpdate'},
{'hrsh7th/nvim-cmp', --> Completion engine
dependencies = {'L3MON4D3/LuaSnip', --> Snippet Engine
dependencies = {'saadparwaiz1/cmp_luasnip',} --> Snippet source
},
},
{'hrsh7th/cmp-buffer'},
{'hrsh7th/cmp-path'},
{'hrsh7th/cmp-cmdline'},
{'lewis6991/gitsigns.nvim'},
{'akinsho/toggleterm.nvim', version = "*", config = true},
{'folke/trouble.nvim',
dependencies = {'nvim-tree/nvim-web-devicons'}
},
{'ggandor/leap.nvim'},
{'chentoast/marks.nvim'},
{'echasnovski/mini.nvim', branch = 'stable'},
{'nvim-lualine/lualine.nvim',
dependencies = {'nvim-tree/nvim-web-devicons', opt = true}
},
{'nvimdev/dashboard-nvim',
event = 'VimEnter',
dependencies = {{'nvim-tree/nvim-web-devicons'}}
},
-- Plugins End --
-- Themes Start --
{"olimorris/onedarkpro.nvim"}, --> Closest to Onedark Pro VSC
{"lunarvim/lunar.nvim"}, --> Lunar Vim theme
{'maxmx03/dracula.nvim'}, --> Similar to Dracula VSC
-- Themes End --
})
end
return configs.setup({

-- Plugins Start --
{'nvim-telescope/telescope.nvim',
branch = '0.1.x',
dependencies = {'nvim-lua/plenary.nvim'}
},
{'nvim-tree/nvim-tree.lua',
dependencies = {'nvim-tree/nvim-web-devicons'}
},
{'nvim-treesitter/nvim-treesitter', build = ':TSUpdate'},
{'lewis6991/gitsigns.nvim'},
{'akinsho/toggleterm.nvim', version = "*", config = true},
{'folke/trouble.nvim',
dependencies = {'nvim-tree/nvim-web-devicons'}
},
{'ggandor/leap.nvim'},
{'chentoast/marks.nvim'},
{'echasnovski/mini.indentscope'},
{'echasnovski/mini.nvim', branch = 'stable' },
{'nvim-lualine/lualine.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons', opt = true }
},
{'nvimdev/dashboard-nvim',
event = 'VimEnter',
dependencies = {{'nvim-tree/nvim-web-devicons'}}
},
-- Plugins End --

-- Themes Start --
-- {'dracula/vim', as = 'dracula'}, --> Official Dracula
{"olimorris/onedarkpro.nvim"}, --> Closest to Onedark Pro VSC
-- {'maxmx03/dracula.nvim'}, --> Similar to Dracula VSC
-- Themes End --

})
--================================-> END <-===================================--
93 changes: 93 additions & 0 deletions lua/lualineconfig.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
--****************************************************************************--
--* [lualineconfig.lua] *--
--* [PLUGIN LUALINE CONFIG FILE] *--
--* [Author/Credit - Tanweer Ashif] *--
--* [LinkedIn/tanweerashif | GitHub/HacksPloiter | https://tanweerashif.com] *--
--****************************************************************************--


--================================-> START <-=================================--
-- Plugin Lualine Configs --
--------------------------------------------------------------------------------
local status_ok, configs = pcall(require, "lualine")
if not status_ok then
return
else
--[==[
-- Filename colour changes based on edits.
local custom_fname = require('lualine.components.filename'):extend()
--custom_fname.apply_icon = require('lualine.components.filetype').apply_icon
local highlight = require'lualine.highlight'
local default_status_colors = { saved = 'none', modified = 'white' }
function custom_fname:init(options)
custom_fname.super.init(self, options)
self.status_colors = {
saved = highlight.create_component_highlight_group({
bg = default_status_colors.saved},
'filename_status_saved', self.options),
modified = highlight.create_component_highlight_group({
bg = default_status_colors.modified},
'filename_status_modified', self.options),
}
if self.options.color == nil then self.options.color = '' end
end
function custom_fname:update_status()
local data = custom_fname.super.update_status(self)
data = highlight.component_format_highlight(
vim.bo.modified and
self.status_colors.modified or
self.status_colors.saved) .. data
return data
end
]==]
configs.setup {
options = {
icons_enabled = true,
theme = 'molokai',
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 = {custom_fname},
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 = {
lualine_a = {'filename'},
lualine_b = {},
lualine_c = {},
lualine_x = {},
lualine_y = {},
lualine_z = {},
},
winbar = {},
inactive_winbar = {},
extensions = {},
}
end
--================================-> END <-===================================--
18 changes: 18 additions & 0 deletions lua/lunarconfig.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--****************************************************************************--
--* [lunarconfig.lua] *--
--* [THEME LUNAR CONFIG FILE] *--
--* [Author/Credit - Tanweer Ashif] *--
--* [LinkedIn/tanweerashif | GitHub/HacksPloiter | https://tanweerashif.com] *--
--****************************************************************************--


--================================-> START <-=================================--
-- Theme LunarVim Configs --
--------------------------------------------------------------------------------
local status_ok, configs = pcall(require, "lunar")
if not status_ok then
return
else
-- vim.cmd 'colorscheme lunar'
end
--================================-> END <-===================================--
Loading

0 comments on commit 80d73f1

Please sign in to comment.