diff options
Diffstat (limited to 'nvim')
-rw-r--r-- | nvim/init.vim | 44 | ||||
-rw-r--r-- | nvim/lua/evil_lualine.lua | 220 | ||||
-rw-r--r-- | nvim/lua/feline_style.lua | 299 | ||||
-rw-r--r-- | nvim/lua/lsp_conf.lua (renamed from nvim/lua/lsp.lua) | 0 |
4 files changed, 316 insertions, 247 deletions
diff --git a/nvim/init.vim b/nvim/init.vim index 2e42f7e..eb370a2 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -1,13 +1,12 @@ -autocmd! bufwritepost .vimrc source % +"autocmd! bufwritepost .vimrc source % call plug#begin('~/.vim/plugged') Plug 'rust-lang/rust.vim' Plug 'nvim-lua/plenary.nvim' +Plug 'nvim-telescope/telescope.nvim' Plug 'lewis6991/gitsigns.nvim' -"Plug 'vim-airline/vim-airline' -Plug 'nvim-lualine/lualine.nvim' +Plug 'famiu/feline.nvim' Plug 'kyazdani42/nvim-web-devicons' -Plug 'junegunn/fzf', {'dir': '~/.fzf', 'do': './install --all'} | Plug 'junegunn/fzf.vim' " fuzzy finder Plug 'luochen1990/rainbow' " color parentheses Plug 'dense-analysis/ale' " checker syntax Plug 'posva/vim-vue' @@ -16,9 +15,7 @@ Plug 'tpope/vim-fugitive' " git extension for commit logs and etc. Plug 'editorconfig/editorconfig-vim' Plug 'ap/vim-css-color' Plug 'Yggdroot/indentLine' -Plug 'jmcantrell/vim-virtualenv' - -Plug 'ryanoasis/vim-devicons' +Plug 'famiu/bufdelete.nvim' Plug 'google/vim-searchindex' @@ -82,6 +79,8 @@ set splitright " split on right side set lazyredraw set ttyfast +set noswapfile + " rust let g:rustfmt_autosave = 1 let g:rustfmt_emit_files = 1 @@ -119,11 +118,11 @@ let b:ale_fixers = { \} if has('nvim') - lua require('evil_lualine') + set termguicolors + lua require('feline_style') lua require('git') - let g:coq_settings = { 'auto_start': v:true } - lua require('lsp') + lua require('lsp_conf') colorscheme gruvbox else @@ -141,12 +140,6 @@ set nocompatible set showcmd " show commands at bottom -augroup remember_folds - autocmd! - autocmd BufWinLeave * mkview - autocmd BufWinEnter * silent! loadview -augroup END - " ------------ " MAPS " ----------- @@ -157,29 +150,26 @@ nnoremap k gk nnoremap tn :tabnew<CR> nnoremap :ve :Vexplore<CR> -nnoremap :rt :RainbowToggle<CR> +nnoremap <leader>rt :RainbowToggle<CR> " buffers nnoremap ]b :bnext<CR> nnoremap [b :bprev<CR> -nnoremap ,b :Buffers<CR> +nnoremap <leader>b :Buffers<CR> " tabs nnoremap ]t :tabn<CR> nnoremap [t :tabp<CR> -nnoremap ,t :tabs<CR> +nnoremap <leader>t :tabs<CR> " only one window -nnoremap ,o :only<CR> +nnoremap <leader>o :only<CR> -" mapping fzf commands -" ff = open files explorer -" co = open commits explorer -" gf = open git ls-files -" gs = open git status -nnoremap <leader>ff :Files .<CR> -nnoremap <leader>co :Commits<CR> +nnoremap <leader>ff <cmd>Telescope find_files<cr> +nnoremap <leader>fg <cmd>Telescope live_grep<cr> +nnoremap <leader>fb <cmd>Telescope buffers<cr> +nnoremap <leader>fh <cmd>Telescope help_tags<cr> nnoremap <leader>pa :set paste<CR> nnoremap <leader>npa :set nopaste<CR> diff --git a/nvim/lua/evil_lualine.lua b/nvim/lua/evil_lualine.lua deleted file mode 100644 index d618dc9..0000000 --- a/nvim/lua/evil_lualine.lua +++ /dev/null @@ -1,220 +0,0 @@ --- Eviline config for lualine --- Author: shadmansaleh --- Credit: glepnir -local lualine = require 'lualine' - --- Color table for highlights --- stylua: ignore -local colors = { - bg = '#202328', - 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_v = {}, - 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.red, - i = colors.green, - v = colors.blue, - [''] = colors.blue, - V = colors.blue, - c = colors.magenta, - no = colors.red, - s = colors.orange, - S = colors.orange, - [''] = colors.orange, - ic = colors.yellow, - R = colors.violet, - Rv = colors.violet, - cv = colors.red, - ce = colors.red, - r = colors.cyan, - rm = colors.cyan, - ['r?'] = colors.cyan, - ['!'] = colors.red, - t = colors.red, - } - 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_lsp' }, - 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) diff --git a/nvim/lua/feline_style.lua b/nvim/lua/feline_style.lua new file mode 100644 index 0000000..a211832 --- /dev/null +++ b/nvim/lua/feline_style.lua @@ -0,0 +1,299 @@ +if not pcall(require, "feline") then + return +end + +local colors = { + bg = '#282c34', + fg = '#abb2bf', + yellow = '#e0af68', + cyan = '#56b6c2', + darkblue = '#081633', + green = '#98c379', + orange = '#d19a66', + violet = '#a9a1e1', + magenta = '#c678dd', + blue = '#61afef', + red = '#e86671' +} + +local vi_mode_colors = { + NORMAL = colors.green, + INSERT = colors.red, + VISUAL = colors.magenta, + OP = colors.green, + BLOCK = colors.blue, + REPLACE = colors.violet, + ['V-REPLACE'] = colors.violet, + ENTER = colors.cyan, + MORE = colors.cyan, + SELECT = colors.orange, + COMMAND = colors.green, + SHELL = colors.green, + TERM = colors.green, + NONE = colors.yellow +} + +local function file_osinfo() + local os = vim.bo.fileformat:upper() + local icon + if os == 'UNIX' then + icon = ' ' + elseif os == 'MAC' then + icon = ' ' + else + icon = ' ' + end + return icon .. os +end + +local lsp = require 'feline.providers.lsp' +local vi_mode_utils = require 'feline.providers.vi_mode' + +local lsp_get_diag = function(str) + local count = vim.lsp.diagnostic.get_count(0, str) + return (count > 0) and ' '..count..' ' or '' +end + +-- LuaFormatter off + +local comps = { + vi_mode = { + left = { + provider = function() + return ' ' .. vi_mode_utils.get_vim_mode() + end, + hl = function() + local val = { + name = vi_mode_utils.get_mode_highlight_name(), + fg = vi_mode_utils.get_mode_color(), + -- fg = colors.bg + } + return val + end, + right_sep = ' ' + }, + right = { + -- provider = '▊', + provider = '' , + hl = function() + local val = { + name = vi_mode_utils.get_mode_highlight_name(), + fg = vi_mode_utils.get_mode_color() + } + return val + end, + left_sep = ' ', + right_sep = ' ' + } + }, + file = { + info = { + provider = 'file_info', + file_modified_icon = '', + hl = { + fg = colors.blue, + style = 'bold' + } + }, + encoding = { + provider = 'file_encoding', + left_sep = ' ', + hl = { + fg = colors.violet, + style = 'bold' + } + }, + type = { + provider = 'file_type' + }, + os = { + provider = file_osinfo, + left_sep = ' ', + hl = { + fg = colors.violet, + style = 'bold' + } + }, + position = { + provider = 'position', + left_sep = ' ', + hl = { + fg = colors.cyan, + -- style = 'bold' + } + }, + }, + left_end = { + provider = function() return '' end, + hl = { + fg = colors.bg, + bg = colors.blue, + } + }, + line_percentage = { + provider = 'line_percentage', + left_sep = ' ', + hl = { + style = 'bold' + } + }, + scroll_bar = { + provider = 'scroll_bar', + left_sep = ' ', + hl = { + fg = colors.blue, + style = 'bold' + } + }, + diagnos = { + err = { + -- provider = 'diagnostic_errors', + provider = function() + return '' .. lsp_get_diag("Error") + end, + -- left_sep = ' ', + enabled = function() return lsp.diagnostics_exist('Error') end, + hl = { + fg = colors.red + } + }, + warn = { + -- provider = 'diagnostic_warnings', + provider = function() + return '' .. lsp_get_diag("Warning") + end, + -- left_sep = ' ', + enabled = function() return lsp.diagnostics_exist('Warning') end, + hl = { + fg = colors.yellow + } + }, + info = { + -- provider = 'diagnostic_info', + provider = function() + return '' .. lsp_get_diag("Information") + end, + -- left_sep = ' ', + enabled = function() return lsp.diagnostics_exist('Information') end, + hl = { + fg = colors.blue + } + }, + hint = { + -- provider = 'diagnostic_hints', + provider = function() + return '' .. lsp_get_diag("Hint") + end, + -- left_sep = ' ', + enabled = function() return lsp.diagnostics_exist('Hint') end, + hl = { + fg = colors.cyan + } + }, + }, + lsp = { + name = { + provider = 'lsp_client_names', + -- left_sep = ' ', + right_sep = ' ', + icon = ' ', + hl = { + fg = colors.yellow + } + } + }, + git = { + branch = { + provider = 'git_branch', + icon = ' ', + left_sep = ' ', + hl = { + fg = colors.violet, + style = 'bold' + }, + }, + add = { + provider = 'git_diff_added', + hl = { + fg = colors.green + } + }, + change = { + provider = 'git_diff_changed', + hl = { + fg = colors.orange + } + }, + remove = { + provider = 'git_diff_removed', + hl = { + fg = colors.red + } + } + } +} + +local components = { + active = {}, + inactive = {}, +} + +table.insert(components.active, {}) +table.insert(components.active, {}) +table.insert(components.active, {}) +table.insert(components.inactive, {}) +table.insert(components.inactive, {}) + +table.insert(components.active[1], comps.vi_mode.left) +table.insert(components.active[1], comps.file.info) +table.insert(components.active[1], comps.git.branch) +table.insert(components.active[1], comps.git.add) +table.insert(components.active[1], comps.git.change) +table.insert(components.active[1], comps.git.remove) +table.insert(components.inactive[1], comps.vi_mode.left) +table.insert(components.inactive[1], comps.file.info) +table.insert(components.active[3], comps.diagnos.err) +table.insert(components.active[3], comps.diagnos.warn) +table.insert(components.active[3], comps.diagnos.hint) +table.insert(components.active[3], comps.diagnos.info) +table.insert(components.active[3], comps.lsp.name) +table.insert(components.active[3], comps.file.os) +table.insert(components.active[3], comps.file.position) +table.insert(components.active[3], comps.line_percentage) +table.insert(components.active[3], comps.scroll_bar) +table.insert(components.active[3], comps.vi_mode.right) + + +-- TreeSitter +-- local ts_utils = require("nvim-treesitter.ts_utils") +-- local ts_parsers = require("nvim-treesitter.parsers") +-- local ts_queries = require("nvim-treesitter.query") +--[[ table.insert(components.active[2], { + provider = function() + local node = require("nvim-treesitter.ts_utils").get_node_at_cursor() + return ("%d:%s [%d, %d] - [%d, %d]") + :format(node:symbol(), node:type(), node:range()) + end, + enabled = function() + local ok, ts_parsers = pcall(require, "nvim-treesitter.parsers") + return ok and ts_parsers.has_parser() + end +}) ]] + +-- require'feline'.setup {} +require'feline'.setup { + colors = { bg = colors.bg, fg = colors.fg }, + components = components, + vi_mode_colors = vi_mode_colors, + force_inactive = { + filetypes = { + 'packer', + 'NvimTree', + 'fugitive', + 'fugitiveblame' + }, + buftypes = {'terminal'}, + bufnames = {} + } +} + diff --git a/nvim/lua/lsp.lua b/nvim/lua/lsp_conf.lua index a63b761..a63b761 100644 --- a/nvim/lua/lsp.lua +++ b/nvim/lua/lsp_conf.lua |