diff --git a/init.lua b/init.lua index 651860b8..b30a74e3 100644 --- a/init.lua +++ b/init.lua @@ -9,7 +9,7 @@ require "statusline" require("colorizer").setup() require("neoscroll").setup() -- smooth scroll --- lsp +-- lsp stuff require "nvim-lspconfig" require "compe-completion" @@ -20,12 +20,13 @@ g.mapleader = " " g.auto_save = 0 -- colorscheme related stuff - cmd "syntax on" local base16 = require "base16" base16(base16.themes["onedark"], true) +require "custom_highlights" + -- blankline local indent = 2 @@ -33,8 +34,6 @@ local indent = 2 g.indentLine_enabled = 1 g.indent_blankline_char = "▏" -cmd "hi IndentBlanklineChar guifg=#2a2e36" - g.indent_blankline_filetype_exclude = {"help", "terminal"} g.indent_blankline_buftype_exclude = {"terminal"} @@ -44,15 +43,6 @@ g.indent_blankline_show_first_indent_level = false require "treesitter-nvim" require "mappings" --- highlights -- -cmd "hi LineNr guifg=#42464e" -cmd "hi Comment guifg=#42464e" - -cmd "hi VertSplit guifg=#2a2e36" -cmd "hi EndOfBuffer guifg=#1e222a" -cmd "hi PmenuSel guibg=#98c379" -cmd "hi Pmenu guibg=#282c34" - require "telescope-nvim" require "nvimTree" @@ -66,11 +56,5 @@ vim.api.nvim_exec([[ au BufEnter term://* setlocal nonumber ]], false) --- inactive statuslines as thin splitlines -cmd("highlight! StatusLineNC gui=underline guifg=#383c44") - -cmd "hi clear CursorLine" -cmd "hi cursorlinenr guifg=#abb2bf" - -- setup for TrueZen.nvim require "zenmode" diff --git a/lua/custom_highlights.lua b/lua/custom_highlights.lua new file mode 100644 index 00000000..34a70174 --- /dev/null +++ b/lua/custom_highlights.lua @@ -0,0 +1,59 @@ +local cmd = vim.cmd +-- blankline + +cmd "hi IndentBlanklineChar guifg=#383c44" + +-- misc -- +cmd "hi LineNr guifg=#42464e" +cmd "hi Comment guifg=#42464e" +cmd "hi NvimInternalError guifg=#f9929b" +cmd "hi VertSplit guifg=#2a2e36" +cmd "hi EndOfBuffer guifg=#1e222a" + +-- Pmenu +cmd "hi PmenuSel guibg=#98c379" +cmd "hi Pmenu guibg=#282c34" +cmd "hi PmenuSbar guibg =#353b45" +cmd "hi PmenuThumb guibg =#81A1C1" + +-- inactive statuslines as thin splitlines +cmd("highlight! StatusLineNC gui=underline guifg=#383c44") + +-- line n.o +cmd "hi clear CursorLine" +cmd "hi cursorlinenr guifg=#abb2bf" + +-- git signs --- +cmd "hi DiffAdd guifg=#81A1C1 guibg = none" +cmd "hi DiffChange guifg =#3A3E44 guibg = none" +cmd "hi DiffModified guifg = #81A1C1 guibg = none" + +-- NvimTree +cmd "hi NvimTreeFolderIcon guifg = #61afef" +cmd "hi NvimTreeFolderName guifg = #61afef" +cmd "hi NvimTreeIndentMarker guifg=#383c44" +cmd "hi NvimTreeNormal guibg=#1b1f27" +cmd "hi NvimTreeVertSplit guifg=#1e222a" +cmd "hi NvimTreeRootFolder guifg=#f9929b" + +-- telescope +cmd "hi TelescopeBorder guifg=#2a2e36" +cmd "hi TelescopePromptBorder guifg=#2a2e36" +cmd "hi TelescopeResultsBorder guifg=#2a2e36" +cmd "hi TelescopePreviewBorder guifg=#525865" + +-- LspDiagnostics --- + +-- error / warnings +cmd "hi LspDiagnosticsSignError guifg=#f9929b" +cmd "hi LspDiagnosticsVirtualTextError guifg=#BF616A" +cmd "hi LspDiagnosticsSignWarning guifg=#EBCB8B" +cmd "hi LspDiagnosticsVirtualTextWarning guifg=#EBCB8B" + +-- info +cmd "hi LspDiagnosticsSignInformation guifg=#A3BE8C" +cmd "hi LspDiagnosticsVirtualTextInformation guifg=#A3BE8C" + +-- hint +cmd "hi LspDiagnosticsSignHint guifg=#b6bdca" +cmd "hi LspDiagnosticsVirtualTextHint guifg=#b6bdca" diff --git a/lua/gitsigns-nvim.lua b/lua/gitsigns-nvim.lua index 83bf7d7b..1fa43255 100644 --- a/lua/gitsigns-nvim.lua +++ b/lua/gitsigns-nvim.lua @@ -25,9 +25,3 @@ require("gitsigns").setup { sign_priority = 5, status_formatter = nil -- Use default } - -local cmd = vim.cmd - -cmd "hi DiffAdd guifg=#81A1C1 guibg = none" -cmd "hi DiffChange guifg =#3A3E44 guibg = none" -cmd "hi DiffModified guifg = #81A1C1 guibg = none" diff --git a/lua/nvim-lspconfig.lua b/lua/nvim-lspconfig.lua index 3c5faa9d..01655aba 100644 --- a/lua/nvim-lspconfig.lua +++ b/lua/nvim-lspconfig.lua @@ -1,8 +1,7 @@ function on_attach(client) - local function map(...) + local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end - local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end @@ -10,44 +9,48 @@ function on_attach(client) buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc") -- Mappings. - local opts = {noremap = true, silent = true, normal = true} - map("gD", "lua vim.lsp.buf.declaration()", opts) - map("gd", "lua vim.lsp.buf.definition()", opts) - map("K", "lua vim.lsp.buf.hover()", opts) - map("gi", "lua vim.lsp.buf.implementation()", opts) - map("", "lua vim.lsp.buf.signature_help()", opts) - map("wa", "lua vim.lsp.buf.add_workspace_folder()", opts) - map("wr", "lua vim.lsp.buf.remove_workspace_folder()", opts) - map("wl", "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))", opts) - map("D", "lua vim.lsp.buf.type_definition()", opts) - map("rn", "lua vim.lsp.buf.rename()", opts) - map("gr", "lua vim.lsp.buf.references()", opts) - map("e", "lua vim.lsp.diagnostic.show_line_diagnostics()", opts) - map("[d", "lua vim.lsp.diagnostic.goto_prev()", opts) - map("]d", "lua vim.lsp.diagnostic.goto_next()", opts) - map("q", "lua vim.lsp.diagnostic.set_loclist()", opts) + local opts = {noremap = true, silent = true} + + buf_set_keymap("n", "gD", "lua vim.lsp.buf.declaration()", opts) + buf_set_keymap("n", "gd", "lua vim.lsp.buf.definition()", opts) + buf_set_keymap("n", "K", "lua vim.lsp.buf.hover()", opts) + buf_set_keymap("n", "gi", "lua vim.lsp.buf.implementation()", opts) + buf_set_keymap("n", "", "lua vim.lsp.buf.signature_help()", opts) + buf_set_keymap("n", "wa", "lua vim.lsp.buf.add_workspace_folder()", opts) + buf_set_keymap("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()", opts) + buf_set_keymap("n", "wl", "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))", opts) + buf_set_keymap("n", "D", "lua vim.lsp.buf.type_definition()", opts) + buf_set_keymap("n", "rn", "lua vim.lsp.buf.rename()", opts) + buf_set_keymap("n", "gr", "lua vim.lsp.buf.references()", opts) + buf_set_keymap("n", "e", "lua vim.lsp.diagnostic.show_line_diagnostics()", opts) + buf_set_keymap("n", "[d", "lua vim.lsp.diagnostic.goto_prev()", opts) + buf_set_keymap("n", "]d", "lua vim.lsp.diagnostic.goto_next()", opts) + buf_set_keymap("n", "q", "lua vim.lsp.diagnostic.set_loclist()", opts) -- Set some keybinds conditional on server capabilities if client.resolved_capabilities.document_formatting then - map("f", "lua vim.lsp.buf.formatting()", opts) + buf_set_keymap("n", "f", "lua vim.lsp.buf.formatting()", opts) elseif client.resolved_capabilities.document_range_formatting then - map("f", "lua vim.lsp.buf.range_formatting()", opts) + buf_set_keymap("n", "f", "lua vim.lsp.buf.range_formatting()", opts) end end -local lspconf = require "lspconfig" -local servers = {"html", "cssls", "tsserver", "pyright", "bashls", "vls", "clangd", "ccls"} +local lspconf = require("lspconfig") -for k, lang in pairs(servers) do +-- these langs require same lspconfig so put em all in a table and loop through! +local servers = {"html", "cssls", "tsserver", "pyright", "bashls", "clangd", "ccls"} + +for _, lang in ipairs(servers) do lspconf[lang].setup { + on_attach = on_attach, root_dir = vim.loop.cwd } end --- remove the lsp servers with their configs you don want -local vls_binary = '/usr/local/bin/vls' -require'lspconfig'.vls.setup { - cmd = {vls_binary}, +-- vls conf example +local vls_binary = "/usr/local/bin/vls" +lspconf.vls.setup { + cmd = {vls_binary} } -- lua lsp settings @@ -56,7 +59,7 @@ USER = "/home/" .. vim.fn.expand("$USER") local sumneko_root_path = USER .. "/.config/lua-language-server" local sumneko_binary = USER .. "/.config/lua-language-server/bin/Linux/lua-language-server" -require "lspconfig".sumneko_lua.setup { +lspconf.sumneko_lua.setup { cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"}, root_dir = function() return vim.loop.cwd() @@ -88,19 +91,3 @@ vim.fn.sign_define("LspDiagnosticsSignError", {text = "", numhl = "LspDiagnos vim.fn.sign_define("LspDiagnosticsSignWarning", {text = "", numhl = "LspDiagnosticsDefaultWarning"}) vim.fn.sign_define("LspDiagnosticsSignInformation", {text = "", numhl = "LspDiagnosticsDefaultInformation"}) vim.fn.sign_define("LspDiagnosticsSignHint", {text = "", numhl = "LspDiagnosticsDefaultHint"}) - --- diagnostics highlights - -local cmd = vim.cmd - -cmd "hi LspDiagnosticsSignError guifg=#f9929b" -cmd "hi LspDiagnosticsVirtualTextError guifg=#BF616A" - -cmd "hi LspDiagnosticsSignWarning guifg=#EBCB8B" -cmd "hi LspDiagnosticsVirtualTextWarning guifg=#EBCB8B" - -cmd "hi LspDiagnosticsSignInformation guifg=#A3BE8C" -cmd "hi LspDiagnosticsVirtualTextInformation guifg=#A3BE8C" - -cmd "hi LspDiagnosticsSignHint guifg=#b6bdca" -cmd "hi LspDiagnosticsVirtualTextHint guifg=#b6bdca" diff --git a/lua/nvimTree.lua b/lua/nvimTree.lua index 19a4ed47..137b9868 100644 --- a/lua/nvimTree.lua +++ b/lua/nvimTree.lua @@ -1,10 +1,9 @@ -local cmd = vim.cmd local g = vim.g vim.o.termguicolors = true g.nvim_tree_side = "left" -g.nvim_tree_width = 25 +g.nvim_tree_width = 26 g.nvim_tree_ignore = {".git", "node_modules", ".cache"} g.nvim_tree_auto_open = 0 g.nvim_tree_auto_close = 0 @@ -13,8 +12,8 @@ g.nvim_tree_follow = 1 g.nvim_tree_indent_markers = 1 g.nvim_tree_hide_dotfiles = 1 g.nvim_tree_git_hl = 1 -g.nvim_tree_root_folder_modifier = ":~" -g.nvim_tree_tab_open = 1 +g.nvim_tree_root_folder_modifier = ":t" +g.nvim_tree_tab_open = 0 g.nvim_tree_allow_resize = 1 g.nvim_tree_show_icons = { @@ -83,9 +82,3 @@ g.nvim_tree_bindings = { ["-"] = get_lua_cb("dir_up"), ["q"] = get_lua_cb("close") } - -cmd "hi NvimTreeFolderIcon guifg = #61afef" -cmd "hi NvimTreeFolderName guifg = #61afef" -cmd "hi NvimTreeIndentMarker guifg=#383c44" -cmd "hi NvimTreeNormal guibg=#1b1f27" -cmd "hi NvimTreeVertSplit guifg=#1e222a" diff --git a/lua/statusline.lua b/lua/statusline.lua index ad3d9df4..6d3013bf 100644 --- a/lua/statusline.lua +++ b/lua/statusline.lua @@ -7,15 +7,8 @@ local colors = { bg = "#1e222a", line_bg = "#1e222a", fg = "#D8DEE9", - fg_green = "#65a380", - yellow = "#A3BE8C", - cyan = "#22262C", - darkblue = "#61afef", green = "#BBE67E", orange = "#FF8800", - purple = "#252930", - magenta = "#c678dd", - blue = "#22262C", red = "#DF8890", lightbg = "#282c34", nord = "#81A1C1", @@ -135,7 +128,7 @@ gls.left[12] = { DiagnosticWarn = { provider = "DiagnosticWarn", icon = "  ", - highlight = {colors.blue, colors.bg} + highlight = {colors.red, colors.bg} } } diff --git a/lua/telescope-nvim.lua b/lua/telescope-nvim.lua index 744cb7b0..b3389357 100644 --- a/lua/telescope-nvim.lua +++ b/lua/telescope-nvim.lua @@ -73,12 +73,3 @@ vim.api.nvim_set_keymap("n", "fb", [[lua require('telescope.builtin vim.api.nvim_set_keymap("n", "fh", [[lua require('telescope.builtin').help_tags()]], opt) vim.api.nvim_set_keymap("n", "fo", [[lua require('telescope.builtin').oldfiles()]], opt) vim.api.nvim_set_keymap("n", "fm", [[ Neoformat]], opt) - --- highlights - -local cmd = vim.cmd - -cmd "hi TelescopeBorder guifg=#2a2e36" -cmd "hi TelescopePromptBorder guifg=#2a2e36" -cmd "hi TelescopeResultsBorder guifg=#2a2e36" -cmd "hi TelescopePreviewBorder guifg=#525865"