Skip to content

Commit

Permalink
[WIP] nvim integrate with iterm2 profile name
Browse files Browse the repository at this point in the history
Problem:
- official nord theme repo for vim, the guy seems reticent to implement
  it of neovim
- the fork of nord theme (nordtheme/nord#157) is ugly
  • Loading branch information
gjeusel committed Jun 21, 2021
1 parent 29a6246 commit 9c17b2d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 17 deletions.
1 change: 1 addition & 0 deletions dotfiles/.config/nvim/lua/wax/plugins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ return require("packer").startup({

--------- User Interface ---------
use("morhetz/gruvbox")
use("shaunsingh/nord.nvim")
use({
"itchyny/lightline.vim", -- light status line
config = function()
Expand Down
2 changes: 1 addition & 1 deletion dotfiles/.config/nvim/lua/wax/plugins/lightline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ local ligthline_layout = {
}

vim.g.lightline = {
colorscheme = "gruvbox",
colorscheme = iterm_colorscheme,
component_function = { gitbranch = "FugitiveHead", lspstatus = "LspStatus" },
-- component_expand = { -- custom components
-- },
Expand Down
47 changes: 31 additions & 16 deletions dotfiles/.config/nvim/lua/wax/themes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,34 @@ vim.o.background = "dark"
vim.g.gruvbox_invert_selection = 0
vim.g.gruvbox_improved_warnings = 1

vim.cmd("silent! colorscheme gruvbox")
vim.g.nord_disable_background = true

-- Highlight API is still a wip in nvim: https://github.com/nanotee/nvim-lua-guide#defining-syntaxhighlights

vim.api.nvim_exec(
[[
" Base interface
highlight Normal ctermbg=none
highlight SignColumn ctermbg=none
highlight VertSplit ctermbg=none
highlight CursorLineNr ctermbg=none
highlight ColorColumn ctermbg=236
highlight SignColumn ctermbg=none
" Better diff views
highlight DiffAdd cterm=none ctermfg=Green ctermbg=none
highlight DiffChange cterm=none ctermfg=Yellow ctermbg=none
highlight DiffDelete cterm=bold ctermfg=Red ctermbg=none
highlight DiffText cterm=none ctermfg=Blue ctermbg=none
]],
false
)

-- Gruvbox Specific
local apply_gruvbox_theme = function()
vim.api.nvim_exec(
[[
" Statusline
hi! link Statusline GruvboxFg3
" barbar
Expand All @@ -36,31 +54,22 @@ hi! link BufferTabpageFill GruvboxBg0
highlight Folded cterm=bold ctermbg=none
hi! link Folded GruvboxFg3
" Better Sign Column
highlight SignColumn ctermbg=none
" Lsp
hi! link LspDiagnosticsDefaultError GruvboxRed
hi! link LspDiagnosticsDefaultWarning GruvboxYellow
hi! link LspDiagnosticsDefaultInformation GruvboxFg3
hi! link LspDiagnosticsDefaultHint GruvboxBlue
" LSP colors
highlight LspReferenceRead cterm=bold ctermbg=red guibg=#464646
highlight LspReferenceText cterm=bold ctermbg=red guibg=#464646
highlight LspReferenceWrite cterm=bold ctermbg=red guibg=#464646
"" LSP colors
"highlight LspReferenceRead cterm=bold ctermbg=red guibg=#464646
"highlight LspReferenceText cterm=bold ctermbg=red guibg=#464646
"highlight LspReferenceWrite cterm=bold ctermbg=red guibg=#464646
" gitsigns
hi! link GitSignsDelete GruvboxRed
hi! link GitSignsChange GruvboxYellow
hi! link GitSignsAdd GruvboxAqua
" Better diff views
highlight DiffAdd cterm=none ctermfg=Green ctermbg=none
highlight DiffChange cterm=none ctermfg=Yellow ctermbg=none
highlight DiffDelete cterm=bold ctermfg=Red ctermbg=none
highlight DiffText cterm=none ctermfg=Blue ctermbg=none
" TreeSitter for TypeScript and Vue
hi! link TSProperty white
Expand All @@ -82,5 +91,11 @@ hi! link TSPunctSpecial GruvboxFg3
hi! link TSPunctBracket GruvboxFg3
hi! link TSPunctDelimiter white
]],
false
)
false
)
end

if iterm_colorscheme == "gruvbox" then
vim.cmd("silent! colorscheme gruvbox")
apply_gruvbox_theme()
end
7 changes: 7 additions & 0 deletions dotfiles/.config/nvim/lua/wax/utils/os.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,10 @@ else
-- TODO: mock it
file = ""
end

local known_colorschemes = { "gruvbox", "nord" }
if vim.tbl_contains(known_colorschemes, os.getenv("ITERM_PROFILE")) then
iterm_colorscheme = os.getenv("ITERM_PROFILE")
else
iterm_colorscheme = "default"
end

0 comments on commit 9c17b2d

Please sign in to comment.