diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 7f9f05f..4b86f2d 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -7,10 +7,8 @@ require('blake.settings') -- TODO: -- Plugins to install: --- status line -- lightspeed.nvim -- lightbulb? --- shade.nvim -- telescope -- - trouble.nvim diff --git a/.config/nvim/lua/blake/other.lua b/.config/nvim/lua/blake/other.lua index b480838..b931111 100644 --- a/.config/nvim/lua/blake/other.lua +++ b/.config/nvim/lua/blake/other.lua @@ -189,6 +189,233 @@ M.autosession = function() vim.cmd 'command! SessionRestore RestoreSession' end -- <<< +-- Lualine >>> +M.lualine = function() + -- From https://github.com/nvim-lualine/lualine.nvim/blob/master/examples/evil_lualine.lua + -- Eviline config for lualine + -- Author: shadmansaleh + -- Credit: glepnir + -- Example: + -- ▊  20.2k .zshrc 320:1 56%  LSP: bashls UTF-8 UNIX ▊ + local lualine = require 'lualine' + + -- Color table for highlights + -- stylua: ignore + local colors = { + bg = '#21242B', + fg = '#bbc2cf', + yellow = '#ECBE7B', + cyan = '#008080', + darkblue = '#081633', + green = '#98be65', + orange = '#FF8800', + violet = '#a9a1e1', + magenta = '#c678dd', + blue = '#51afef', + red = '#ec5f67', + } + + local conditions = { + buffer_not_empty = function() + return vim.fn.empty(vim.fn.expand '%:t') ~= 1 + end, + hide_in_width = function() + return vim.fn.winwidth(0) > 80 + end, + check_git_workspace = function() + local filepath = vim.fn.expand '%:p:h' + local gitdir = vim.fn.finddir('.git', filepath .. ';') + return gitdir and #gitdir > 0 and #gitdir < #filepath + end, + } + + -- Config + local config = { + options = { + -- Disable sections and component separators + component_separators = '', + section_separators = '', + theme = { + -- We are going to use lualine_c an lualine_x as left and + -- right section. Both are highlighted by c theme . So we + -- are just setting default looks o statusline + normal = { c = { fg = colors.fg, bg = colors.bg } }, + inactive = { c = { fg = colors.fg, bg = colors.bg } }, + }, + }, + sections = { + -- these are to remove the defaults + lualine_a = {}, + lualine_b = {}, + lualine_y = {}, + lualine_z = {}, + -- These will be filled later + lualine_c = {}, + lualine_x = {}, + }, + inactive_sections = { + -- these are to remove the defaults + lualine_a = {}, + lualine_b = {}, + lualine_y = {}, + lualine_z = {}, + lualine_c = {}, + lualine_x = {}, + }, + } + + -- Inserts a component in lualine_c at left section + local function ins_left(component) + table.insert(config.sections.lualine_c, component) + end + + -- Inserts a component in lualine_x ot right section + local function ins_right(component) + table.insert(config.sections.lualine_x, component) + end + + ins_left { + function() + return '▊' + end, + color = { fg = colors.blue }, -- Sets highlighting of component + padding = { left = 0, right = 1 }, -- We don't need space before this + } + + ins_left { + -- mode component + function() + -- auto change color according to neovims mode + local mode_color = { + n = colors.green, + i = colors.blue, + v = colors.magenta, + [''] = colors.magenta, + V = colors.magenta, + c = colors.violet, + no = colors.green, + s = colors.orange, + S = colors.orange, + [''] = colors.orange, + ic = colors.yellow, + R = colors.red, + Rv = colors.red, + cv = colors.green, + ce = colors.green, + r = colors.cyan, + rm = colors.cyan, + ['r?'] = colors.cyan, + ['!'] = colors.green, + t = colors.green, + } + vim.api.nvim_command('hi! LualineMode guifg=' .. mode_color[vim.fn.mode()] .. ' guibg=' .. colors.bg) + return '' + end, + color = 'LualineMode', + padding = { right = 1 }, + } + + ins_left { + -- filesize component + 'filesize', + cond = conditions.buffer_not_empty, + } + + ins_left { + 'filename', + cond = conditions.buffer_not_empty, + color = { fg = colors.magenta, gui = 'bold' }, + } + + ins_left { 'location' } + + ins_left { 'progress', color = { fg = colors.fg, gui = 'bold' } } + + ins_left { + 'diagnostics', + sources = { 'nvim_diagnostic' }, + symbols = { error = ' ', warn = ' ', info = ' ' }, + diagnostics_color = { + color_error = { fg = colors.red }, + color_warn = { fg = colors.yellow }, + color_info = { fg = colors.cyan }, + }, + } + + -- Insert mid section. You can make any number of sections in neovim :) + -- for lualine it's any number greater then 2 + ins_left { + function() + return '%=' + end, + } + + ins_left { + -- Lsp server name . + function() + local msg = 'No Active Lsp' + local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype') + local clients = vim.lsp.get_active_clients() + if next(clients) == nil then + return msg + end + for _, client in ipairs(clients) do + local filetypes = client.config.filetypes + if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then + return client.name + end + end + return msg + end, + icon = ' LSP:', + color = { fg = '#ffffff', gui = 'bold' }, + } + + -- Add components to right sections + ins_right { + 'o:encoding', -- option component same as &encoding in viml + fmt = string.upper, -- I'm not sure why it's upper case either ;) + cond = conditions.hide_in_width, + color = { fg = colors.green, gui = 'bold' }, + } + + ins_right { + 'fileformat', + fmt = string.upper, + icons_enabled = false, -- I think icons are cool but Eviline doesn't have them. sigh + color = { fg = colors.green, gui = 'bold' }, + } + + ins_right { + 'branch', + icon = '', + color = { fg = colors.violet, gui = 'bold' }, + } + + ins_right { + 'diff', + -- Is it me or the symbol for modified us really weird + symbols = { added = ' ', modified = '柳 ', removed = ' ' }, + diff_color = { + added = { fg = colors.green }, + modified = { fg = colors.orange }, + removed = { fg = colors.red }, + }, + cond = conditions.hide_in_width, + } + + ins_right { + function() + return '▊' + end, + color = { fg = colors.blue }, + padding = { left = 1 }, + } + + -- Now don't forget to initialize lualine + lualine.setup(config) +end -- <<< + return M -- vim:fdm=marker:fmr=>>>,<<<:expandtab:tabstop=3:sw=3 diff --git a/.config/nvim/lua/blake/plugins.lua b/.config/nvim/lua/blake/plugins.lua index 51db058..bef9d00 100644 --- a/.config/nvim/lua/blake/plugins.lua +++ b/.config/nvim/lua/blake/plugins.lua @@ -41,7 +41,32 @@ return require('packer').startup({function() 'navarasu/onedark.nvim', config = function() -- vim.g.onedark_transparent_background = true - require('onedark').setup() + vim.cmd [[ + au ColorScheme onedark hi TabLine gui=none guibg='#282C34' guifg='#5C6370' " all tabs color + au ColorScheme onedark hi TabLineSel guibg='#282C34' guifg='#B5BBC7' " Highlighted tab color + au ColorScheme onedark hi TabLineFill guibg='#282C34' " tabline portion without tabs (right-hand side) + colorscheme onedark + ]] + end + } + use { -- statusline: lualine + 'nvim-lualine/lualine.nvim', + requires = {'kyazdani42/nvim-web-devicons', opt = true}, + config = function() + require('blake.other').lualine() + end, + } + use { -- tabline + 'alvarosevilla95/luatab.nvim', + requires = 'kyazdani42/nvim-web-devicons', + config = function() + -- vim.cmd [[ + -- exec('au ColorScheme gruvbox hi TabLine gui=none guibg=' . $color01 . ' guifg=' . $color03) + -- exec('au ColorScheme gruvbox hi TabLineSel guibg=' . $color01 . ' guifg=' . $color06) + -- exec('au ColorScheme gruvbox hi TabLineFill guibg=' . $color01) + -- ]] + + require('luatab').setup {} end } use { -- css color tag highlighter (ex: #FFB13B) @@ -50,9 +75,6 @@ return require('packer').startup({function() vim.cmd 'command! COL ColorizerToggle' end, } - use { -- tabline - 'alvarosevilla95/luatab.nvim' - } -- IDE features ---- LSP (document analysis) @@ -66,6 +88,18 @@ return require('packer').startup({function() require('blake.lsp').lspconfig() end } + use { -- commentstring based on context from treesitter + 'JoosepAlviste/nvim-ts-context-commentstring', + requires = 'nvim-treesitter/nvim-treesitter', + config = function() + require'nvim-treesitter.configs'.setup { + context_commentstring = { + enable = true, + enable_autocmd = false, + } + } + end, + } use { -- compe 'hrsh7th/nvim-cmp', config = function() @@ -141,13 +175,13 @@ return require('packer').startup({function() require('blake.other').gitsigns() end, } - use { -- file manager - 'kyazdani42/nvim-tree.lua', - requires = 'kyazdani42/nvim-web-devicons', - config = function() - require('blake.other').nvimtree() - end - } + -- use { -- file manager + -- 'kyazdani42/nvim-tree.lua', + -- requires = 'kyazdani42/nvim-web-devicons', + -- config = function() + -- require('blake.other').nvimtree() + -- end + -- } use { -- terminal 'akinsho/toggleterm.nvim', config = function() @@ -218,6 +252,20 @@ return require('packer').startup({function() vim.api.nvim_set_keymap('n', '', 'UndotreeToggle', { noremap = true, silent = true, }) end } +-- use { -- Dim inactive window +-- 'sunjon/shade.nvim', +-- config = function() +-- require'shade'.setup({ +-- overlay_opacity = 50, +-- opacity_step = 1, +-- keys = { +-- brightness_up = '', +-- brightness_down = '', +-- toggle = 's', +-- } +-- }) +-- end +-- } use { -- Quote pairing 'windwp/nvim-autopairs', config = function() @@ -230,12 +278,28 @@ return require('packer').startup({function() use { -- cheat.sh integration 'dbeniamine/cheat.sh-vim', } - use { -- Comments (gb and gc) - 'numToStr/Comment.nvim', - config = function() - require('Comment').setup() - end - } + -- use { -- Comments (gb and gc) + -- 'numToStr/Comment.nvim', + -- config = function() + -- require('Comment').setup { + -- pre_hook = function(ctx) + -- local U = require 'Comment.utils' + -- + -- local location = nil + -- if ctx.ctype == U.ctype.block then + -- location = require('ts_context_commentstring.utils').get_cursor_location() + -- elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then + -- location = require('ts_context_commentstring.utils').get_visual_start_location() + -- end + -- + -- return require('ts_context_commentstring.internal').calculate_commentstring { + -- key = ctx.ctype == U.ctype.line and '__default' or '__multiline', + -- location = location, + -- } + -- end, + -- } + -- end + -- } -- use { -- lewis6991: spellsitter: Spell checking in treesitter files -- 'lewis6991/spellsitter.nvim', -- config = function() @@ -254,6 +318,9 @@ return require('packer').startup({function() require('foldsigns').setup() end, } + use { -- tpope: commentary + 'tpope/vim-commentary', + } use { -- tpope: surround 'tpope/vim-surround' } diff --git a/.config/nvim/lua/blake/settings.lua b/.config/nvim/lua/blake/settings.lua index 3de8ea0..69cc943 100644 --- a/.config/nvim/lua/blake/settings.lua +++ b/.config/nvim/lua/blake/settings.lua @@ -16,6 +16,7 @@ set.hidden = true set.backspace = 'indent,eol,start' set.ignorecase = true set.smartcase = true +set.showmode = false set.wrap = false set.linebreak = true set.redrawtime = 200