From 9c17b2d83718b6e045aedf69cef37b5dac556031 Mon Sep 17 00:00:00 2001 From: Jeusel Guillaume Date: Mon, 21 Jun 2021 22:55:31 +0200 Subject: [PATCH] [WIP] nvim integrate with iterm2 profile name Problem: - official nord theme repo for vim, the guy seems reticent to implement it of neovim - the fork of nord theme (https://github.com/arcticicestudio/nord/issues/157) is ugly --- dotfiles/.config/nvim/lua/wax/plugins.lua | 1 + .../nvim/lua/wax/plugins/lightline.lua | 2 +- dotfiles/.config/nvim/lua/wax/themes.lua | 47 ++++++++++++------- dotfiles/.config/nvim/lua/wax/utils/os.lua | 7 +++ 4 files changed, 40 insertions(+), 17 deletions(-) diff --git a/dotfiles/.config/nvim/lua/wax/plugins.lua b/dotfiles/.config/nvim/lua/wax/plugins.lua index 13265151..5ce3789a 100644 --- a/dotfiles/.config/nvim/lua/wax/plugins.lua +++ b/dotfiles/.config/nvim/lua/wax/plugins.lua @@ -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() diff --git a/dotfiles/.config/nvim/lua/wax/plugins/lightline.lua b/dotfiles/.config/nvim/lua/wax/plugins/lightline.lua index 7e6f28f3..42e6fb7a 100644 --- a/dotfiles/.config/nvim/lua/wax/plugins/lightline.lua +++ b/dotfiles/.config/nvim/lua/wax/plugins/lightline.lua @@ -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 -- }, diff --git a/dotfiles/.config/nvim/lua/wax/themes.lua b/dotfiles/.config/nvim/lua/wax/themes.lua index c3522717..39443fee 100644 --- a/dotfiles/.config/nvim/lua/wax/themes.lua +++ b/dotfiles/.config/nvim/lua/wax/themes.lua @@ -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 @@ -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 @@ -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 diff --git a/dotfiles/.config/nvim/lua/wax/utils/os.lua b/dotfiles/.config/nvim/lua/wax/utils/os.lua index 657c5471..46a4bcaa 100644 --- a/dotfiles/.config/nvim/lua/wax/utils/os.lua +++ b/dotfiles/.config/nvim/lua/wax/utils/os.lua @@ -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