Table of Contents
- MODERN NVIM CONFIG
-
Adding the following color highlights to the githubG.nvim our colorschme, which includes:
- LspInlayHint,
- WinSeparator,
- WinBar and WinBarNC
-
What has been added since
v.0.10
, read more neovim news-0.10- hl-FloatBorder is linked to hl-NormalFloat instead of hl-WinSeparator.
- hl-NormalFloat is not linked to hl-Pmenu.
- hl-WinBar has different background.
- hl-WinBarNC is similar to hl-WinBar but not bold.
- hl-WinSeparator is linked to hl-Normal instead of hl-VertSplit.
- This version has no issue in performance, I just included minor fixes for some libraries.
-
nvim-saga
now works flawlessly. -
ranger
now can open in new buffer, support the icons and other features. -
terminal
: Terminal now uses thesaga
package to open the new terminal. -
conform
: Added formatter for bothrust
andR
customized. -
gen.nvim
; Added AI with LLM language models support - model are locally installed.
-
- The following major realse shows a bit longer time to trigger the
nvim
.
- Working on the
nvim 0.9
modern APIs. - The current version works under
nvim
with Lazy Plugins Manager. - Startup time is under
20 milliseconds
for all the installed plugins. - Added
which-key
for mapping all the availablekeys
. - Refactoring and optimizing the workflow structure.
- Added session harboon designed for productivity.
- Added original function for launching
autoload
-netrwPlugin
- - Changed the nvim-web-devicons customized based on our requested color (Read here)
- Added a color theme plugin created from scratch namely
github.nvim
theme. - Add more support for the debugging session with
which-key
integration. Also addedvirtual-text
supprot in thedap
session to show the value of the variable check here. - adding more advanced topic here.
As nvim
has been updated to version 0.8
, which includes a stable release,
several deprecated third-party plugins and APIs have also been optimized. As a
result, the startup time has been reduced from 800 milliseconds to only 18
milliseconds. With this optimization, nvim
is now faster than light while
maintaining backwards compatibility with some outdated plugins that are
essential to my daily workflow.
The configuration files are all written in lua
using
the most modern APIs
by this time. Check for more details :h deprecated
to
see the news feature of the new release. Here, is a summary of the most wanted
upgrades to my configuration file (to name few)
-
All packages are supported for the new version of
nvim
-
Startup time up to maximum 18 milliseconds tested on my
MacBook Max M1
-
Support several programming languages, with their components such assets
- LSP configured with
mason
plugin, (also support lsp-saga, lsp-signature) - Linting support, Auto-formatter, intelligence, auto-completions,
- Go to definition, hover, references, troubles, actions.
- Debugging with
nvim-dap
support several protocols and programmings adapters. - Dap now support the
virtualenv
type, which can trigger the adapter of the virtualenv to keep consistency.
- LSP configured with
-
Fixed the
cmp-line
support thectrl+j/k
for navigation. -
Added boarders to the
lsp/cmp
elements -
Auto-trigger
packer-plugins
when the list of plugins is upated. -
packer-plugin
is now can handle mutli-jobs for themacbook
without freezing. -
Added the support of the
tabnine
with executional compatibility for thearm 64
silicon M1
this supports the also thevirtualenv
of python. -
Statusline now shows message about the
virtualenv
name, near to thelsp-type
support. -
Support for the colorscheme that can configure to show major highlights
- Highlighter for the current number-line
- Highlighter for
Statusline
- Highlighter for
tabs
- Highlighter for
git
plugin support - Highlighter for
linter
and thevirtual-text
- Highlighter for
lsp-icons
on the side gutter with different colors.
-
Added helper utilities/functions and documentation for debugging, development support
-
Upgraded the
nvim_speed_test
to gauge the speed of the startup time and evaluate the performance. -
Support the
nvim-patient
for loading and caching the plugins. -
Plugins triggered by certain types of events that will reduce the clutter and improve the speed significantly, check for example
:packer status
to see that majority of plugins are not loaded at the startup.
ContextEnable
: will give you a nice folding to your functions.DocsViewToogle
: for showing documents and tracing your cursor.SymbolsOutline
: for getting a nice jump over all coding elements.<leader> + o
: will also give us similar toSymbosOutline
.- Remember, once you are in insert mode, it will trigger other plugins to be loaded. but some of them until you open next buffer. (reason is to get speed and loading only necessary plugins on demands.)
Ctr + n/p
: to scroll faster while center.Shift + { or }
to scroll faster while centered but jump on coding elements.<F6>
: To toggle the spell checking.<F1>
: To show help<leader>ff
,<leader>fg
,<leader>fb
and<leader>fh
all are reserved tonvim-Telelscope toggler
.<leader>tt
: horizontal terminal,<leader>t
: floating terminal but slower<leader>r
: Ranger for navigating your files.<leader>u
: undo-tree toggler.
To enable the crate
plugin, you need to enter a buffer with file extension
'.rs' associated with 'rustfile' first. This can be triggered on the 'Insert'
event. It also activates 'cmp-create' and 'nvim-crate'. Later, you can use the
'keymapping: gH' on the crate name, which will display documentation about the
crate history and other considerations.
By default, the file will automatically save based on the auto-saved
plugin.
This feature is triggered as soon as we begin writing. To stop this auto-save,
we can use the keymapping leader
+ s
, which will prevent further automatic
saves.
We can use add the following to the top of the file
require("core.myInspectorFucntions")
In order to request the required custom-development functions that I have created, please refer to the following as an example:
- assume you have a file called
testing_file
at thelua
directory
local fn = require("testing_file")
P(fn.setup())
- Configuration for the dap
- install dap for rust-analyzer, integrated with rust-tools
- Adding only the
keymapping-window
. - spell-checking for nvim such as
- Spelunker.vim The current
configurations are from the needs of getting the best optimized
IDE
for the startup time.
- Major Changes in nvim 0.8
- New LSP Features in Neovim 0.8
- Deprection of lsp_installer.on_server_ready()
- Introduction mason.nvim
- How to configure LSP with mason
The following command are super handy and useful when developign lua
plugins.
:source % -- This will repload the curretn buffer (usually can be used with init.lua)
:lua <function_name()> -- How to run a function (especially the __G.) global functions (check special function file)
- Packer and packadd
packer
usually will load the required plugins and thats suppose to be for any file you will put atplugin
which where packer usually dumps its contents.
- Color-scheme
- Any color scheme (*.vim) will be put at
colors
directory inside thenvim
will be loaded to the color-scheme, which can be checked using:colorscheme <tab>
- RUNTIME PATH
- You can use
:set rtp+=/path/to/emmet
to add any directory which will be loaded to therun-path
lists.
- Getting some useful Info
:lua print(vim.opt.columns:get()) -- will print the number of columns you have (set/get are main functions to retervie or setting info)
- Since 0.8 we can now create
vim.cmd [[
autocmd BufEnter,CursorHold,InsertLeave,BufWritePost *.rs silent! lua vim.lsp.codelens.refresh()
]]
Now, it becomes as:
vim.api.nvim_create_autocmd({ "BufWritePost", "BufEnter", "CursorHold", "InsertLeave" }, {
pattern = { "*.rs" },
callback = function()
vim.lsp.codelens.refresh()
end
})
-
undotree hint Since we allow
undotree
to be triggered only when we call the undotree kepmapping, then you should always hit at least once theundotree
to trigger it for the curretn buffer, which can keep tracking the changes. -
otree hint To ensure that undotree is triggered for the current buffer, you should always hit it at least once. This will allow undotree to track your changes efficiently.
Read more here:
- vim-easymotion, vim-sneak, hop.nvim, lightspeed.nvim, pounce.nvim, vim-searchx
- Use the color-scheme form
NVChad
. - optimized with the
lazy loading
based on packer configuration . - remove the unnecessary packages form loading that comes with
nvim
. - Adding the lsp compatibility configuraition skippers for regualr
lsp
vsrust-tools
. - Adding the virtual text lsp configruration.
- Refactoring all the crrent lsp files into more moduels follow the other way of writing.
- Using Nvim v.0.8
- Adding symboles inspector for the right corner.
-
cmd
and/:
should works - Spelling completion.
-
LSP
configurations advanced, including highlighting and other optimizations - Rust-tools and analyzer for complete configurations.
check :h deprecated
- Need to change vim.highlight.create into vim.create.hl.
-
compatibility
changed tocompatibility_vim
. : read more about this refactoring later. -
vim.lsp.buf.format()
now replaces thevim.lsp.buf.formatting()
vim.pretty_print("")
there are two apis
- got it from the telescope
- telescope configuration
local map = function(op, outer)
outer = outer or { silent = true, noremap = true }
return function(lhs, rhs, opts)
if type(lhs) ~= "table" then
lhs = { lhs }
end
opts = vim.tbl_extend("force",
outer,
opts or {}
)
for _, v in pairs(lhs) do
vim.keymap.set(op or "n", v, rhs, opts)
end
end
end
vim.g.nmap = map("n")
vim.g.imap = map("i")
vim.g.vmap = map("v")
vim.g.tmap = map("t")
which means using vim.keymap.set()
- Using reqular nvim
vim.api.nvim_set_keymap("i", "<c-j>", '("<C-n>")', {
noremap = true,
silent = true,
expr = true,
})
In the cmd
you can use
:Telescope keymaps, registers, vim_options, jumplist, loclist, filetypes ..etc.
There are several ways to manage the events
such as VimEnter, BufEnter ... etc. Read more here
local function status_line()
local mode = "%-5{%v:lua.string.upper(v:lua.vim.fn.mode())%}"
local file_name = "%-.16t"
local buf_nr = "[%n]"
local modified = " %-m"
local file_type = " %y"
local right_align = "%="
local line_no = "%10([%l/%L%)]"
local pct_thru_file = "%5p%%"
vim.cmd([[hi StatusLine ctermbg=red ctermfg=yellow ]])
return string.format(
"%s%s%s%s%s%s%s%s",
mode,
file_name,
buf_nr,
modified,
file_type,
right_align,
line_no,
pct_thru_file
)
end
vim.opt.statusline = status_line()
- To add color to
status-line
we can use the following, Go to theone-darker
configuration file and add the following which can alter the group color of thestatusline
-- StatusLine
StatusLine = { fg = '#DADFF7' ,bg = '#008DD5' },
-- StatusLineTerm = {},
-- StatusLineNC = {},
-- StatusLineTermNC = {},
In command line prompt for nvim
you can print the tables using one of the following.
:lua vim.pretty_print(packer_plugins)
:lua print(vim.inspect(packer_plugins))
Anything you put inside the plugin
(without a trailing 's'), which is located
in the same directory as where nvim-packer
stores its startup
, will be used
to load the nvim configuration
. It's useful to understand the directory order
for placing your configurations files to improve startup speed.
- Create a
test.lua
file at the plugin directory for automatic sourcing. - You can put any code inside this
test.lua
that will be loaded and executed after all Lua files are sourced. - Note that the
packer-plugins
global variable is established after sourcing thepacker_compiled.lua
. It checks for a plugin calledundotree
(same as from the GitHub repository). This will automatically get loaded when you open theinit.lua
file.
if packer_plugins["undotree"] and packer_plugins["undotree"].loaded then
print("Vim undotree is loaded")
-- other custom logic
end
print("wow")
├── LICENSE
├── README.md
└── VSCode_setting/
│ ├──── README.md
│ ├──── SS-01.png
│ └──── init.vim
└── assets/
│ ├──── SS-01.old
│ ├──── SS-01.png
│ ├──── SS-02.png
│ ├──── SS-03.png
│ ├──── SS-04.png
│ └──── current_loaded_programming_langauge_servers.png
├── init.lua
└── lua/
│ └──── core/
│ │ ├──── global.lua
│ │ ├──── init.lua
│ │ └──── keymappings.lua
│ └──── plugins/
│ │ └──── configs/
│ │ │ ├──── init.lua
│ │ │ ├──── myFzf.lua
│ │ │ ├──── myImpatient.lua
│ │ │ ├──── myNvimTree.lua
│ │ │ ├──── myTelescope.lua
│ │ │ ├──── myUndoTreeConfig.lua
│ │ │ └──── onedark_config.lua
│ │ ├──── init.lua
│ │ ├──── packerPluginsManager.lua
│ │ └──── packerPluginsManagerLoader.lua
│ └──── settings/
│ │ ├──── init.lua
│ │ └──── options.lua
└── plugin/
│ ├──── packer_compiled.lua
│ └──── test.lua
Read more here
-- This will work if you add to (common) for the color scheme. -- Defing first the synatx group by linking them to existed on using: -- highlight def link <you_custom_group_name> guifg= -- Then assign to the specific pattern that you want to highlight
vim.cmd([[
hi def link GGX Title
syn match GGX /[A-Z]+/
syn match GGX /[A-Z]\{2,\}/ "two words or more
syn match GGX "\v<[A-Z]+>"
]])
You can also specify some highlight using:
vim.cmd([[highlight Visual cterm=bold ctermbg=Blue ctermfg=NONE]])
There are three ways to highlight custom group (group created by user) these are
- Using direct nvim syntax
highlight GGX guifg=#EEEDBF
- Adding to the
one-dark-config.lua
file at the defined highlights like: Here we will addGGX
highlights = {
-- Common
Visual = { bg = '$bright_orange', fmt = 'bold'},
Normal = { fg = '$beautiful_black' ,bg = '$beautiful_black' }, -- backgorund default color
Terminal= { fg = '$beautiful_black' ,bg = '$beautiful_black' }, -- terminal color for nvim
EndOfBuffer = { fg = '$beautiful_black' ,bg = '$beautiful_black' }, -- End of buffer color
VertSplit = { fg = '$light_green' ,bg = '$beautiful_black' }, -- when using vertical split
SignColumn = { fg = '$beautiful_black' ,bg = '$beautiful_black' }, -- SignColumn control the edge of nvim buffer
-- Syntax
String = {fg ='$light_green'}, -- For only string in nvim
-- nvim-tree
NvimTreeVertSplit = { fg = '$light_green' ,bg = '$beautiful_black' }, -- When you split inside nvim-tree the fg will be activited
NvimTreeNormal = { fg = '$light_green' ,bg = '$beautiful_black' }, -- fg means files names, folder names ..etc.
NvimTreeEndOfBuffer = { fg = '$light_green' ,bg = '$beautiful_black' },
NvimTreeGitNew = {fg ='$light_green' }, -- This will change only the
-- GGX = {fg = '#EEEDBF'}
- This is native to nvim which we can use
vim.highlight.create('GGX', {guifg="#EEEDBF"}, true)
We are using now Global
function to source all the current files
-- Function used to color (yellow) the upper cases words
_G.highlight_upper_letter_cases = function()
-- The following
-- This will work if you add to (common) for the color scheme.
-- Defing first the synatx group by linking them to existed on using:
-- highlight def link <you_custom_group_name> guifg=<hash-color-name>
-- Then assign to the specific pattern that you want to highlight
-- You can link from other group using:
-- vim.api.nvim_command([[hi def link GGX Title]])
-- Or create a new group
--vim.highlight.create('GGX', {guifg="#EEEDBF"}, true)
--vim.api.nvim_command([[highlight GGX guifg=#EEEDBF]])
vim.api.nvim_command([[syn match GGX /[A-Z]+/]])
vim.api.nvim_command([[syn match GGX /[A-Z]\{2,\}/]])
vim.api.nvim_command([[syn match GGX "\v<[A-Z]+>"]])
-- this will be executed only when open vim on event VimEnter (then source
-- all nvim files), should not be used (affecting the markdown)
vim.cmd([[autocmd VimEnter ~/.config/nvim/* source %]])
end
In nvim-lua
configurations, there are essentially three layers that control
the color
of each group
. Group colors refer to those defined for specific
actions in nvim
, such as digits, tabs, normal mode, and backgrounds, among
others. These layers include:
-
A. Default Layer (this will be native to the color-scheme that you select. (mostly the tree-sitter parser colors are included)
-
B. Tree-Sitter Color-Groups which used once you install the
nvim-treesitter
-
C. Component of the
plugins
that alter the colors (e.g., statuline, bufferline, nvim-tree and lsp configurations) -
D. The user custom individual colors defined.
Configurations
: to change the color, you need to consider to which level you
want to alter the color.