From e813a072dac487344ac07f9566a057d87ad3bc0e Mon Sep 17 00:00:00 2001 From: RhiobeT Date: Fri, 10 Jun 2022 15:48:14 +0200 Subject: [PATCH] NeoVim clean and updated config --- .config/nvim/.gitignore | 1 + .config/nvim/coc-settings.json | 59 --------- .config/nvim/init.lua | 132 +++++++++++++++++++++ .config/nvim/init.vim | 151 ------------------------ .config/nvim/lua/feline/solarized.lua | 19 +++ .config/nvim/lua/lspconfig/settings.lua | 46 ++++++++ .config/nvim/lua/plugins.lua | 37 ++++++ .config/nvim/solarized.nvim | 1 + .gitmodules | 3 + 9 files changed, 239 insertions(+), 210 deletions(-) create mode 100644 .config/nvim/.gitignore delete mode 100644 .config/nvim/coc-settings.json create mode 100644 .config/nvim/init.lua delete mode 100644 .config/nvim/init.vim create mode 100644 .config/nvim/lua/feline/solarized.lua create mode 100644 .config/nvim/lua/lspconfig/settings.lua create mode 100644 .config/nvim/lua/plugins.lua create mode 160000 .config/nvim/solarized.nvim create mode 100644 .gitmodules diff --git a/.config/nvim/.gitignore b/.config/nvim/.gitignore new file mode 100644 index 0000000..c84aa4a --- /dev/null +++ b/.config/nvim/.gitignore @@ -0,0 +1 @@ +plugin/packer_compiled.lua diff --git a/.config/nvim/coc-settings.json b/.config/nvim/coc-settings.json deleted file mode 100644 index f133007..0000000 --- a/.config/nvim/coc-settings.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "explorer.keyMappings": { - "k": "nodePrev", - "j": "nodeNext", - - "*": "toggleSelection", - "": "actionMenu", - - "": "collapse", - "": "expand", - "J": ["toggleSelection", "normal:j"], - "K": ["toggleSelection", "normal:k"], - "gl": "expandRecursive", - "gh": "collapseRecursive", - "o": "expandOrCollapse", - "": "open", - "e": "open", - "E": "openInVsplit", - "t": "openInTab", - "": "gotoParent", - - "y": "copyFilepath", - "Y": "copyFilename", - "c": "copyFile", - "x": "cutFile", - "p": "pasteFile", - "d": "delete", - "D": "deleteForever", - - "a": "addFile", - "A": "addDirectory", - "r": "rename", - - ".": "toggleHidden", - "R": "refresh", - - "?": "help", - "q": "quit", - "X": "systemExecute", - "gd": "listDrive", - - "f": "search", - "F": "searchRecursive", - - "gf": "gotoSource:file", - "gb": "gotoSource:buffer", - - "[[": "sourcePrev", - "]]": "sourceNext", - - "[d": "diagnosticPrev", - "]d": "diagnosticNext", - - "[c": "gitPrev", - "]c": "gitNext", - "<<": "gitStage", - ">>": "gitUnstage" - } -} diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..a53ea25 --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1,132 @@ +require 'plugins' + + +require 'popup' + + +vim.g.solarized_italic_comments = true +vim.g.solarized_italic_keywords = true +vim.g.solarized_italic_functions = true +vim.g.solarized_italic_variables = false +vim.g.solarized_contrast = true +vim.g.solarized_borders = false +vim.g.solarized_disable_background = false +require('solarized').set() + + +require('nvim-treesitter.configs').setup { + ensure_installed = { "c", "lua", "rust", "java", "python", "javascript", "typescript" }, + sync_install = false, + ignore_install = { }, + + highlight = { + enable = true, + disable = { }, + additional_vim_regex_highlighting = false, + }, +} + + +require('feline').setup { + theme = require('feline.solarized'), + force_inactive = { + filetypes = { + '^neo\\-tree$', + '^packer$', + '^startify$', + '^fugitive$', + '^fugitiveblame$', + '^qf$', + '^help$' + }, + buftypes = { + '^terminal$' + }, + bufnames = { + 'neo\\-.*', + } + } +} + + +require('nvim-lsp-installer').setup {} +require('lspconfig/settings') + + +require('window-picker').setup({ + autoselect_one = false +}) + autoselect_one = true, + + +vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]]) +require('neo-tree').setup({ + window = { + width = 30, + mappings = { + [""] = "open_with_window_picker", + } + }, + filesystem = { + filtered_items = { + visible = true + } + } +}) + + +require('smart-splits') +vim.keymap.set("n", "", require('smart-splits').move_cursor_left) +vim.keymap.set("n", "", require('smart-splits').move_cursor_down) +vim.keymap.set("n", "", require('smart-splits').move_cursor_up) +vim.keymap.set("n", "", require('smart-splits').move_cursor_right) +vim.keymap.set("n", "", require('smart-splits').resize_up) +vim.keymap.set("n", "", require('smart-splits').resize_down) +vim.keymap.set("n", "", require('smart-splits').resize_left) +vim.keymap.set("n", "", require('smart-splits').resize_right) + + +local colors = require('solarized.colors') +require('bufferline').setup{ + options = { + offsets = {{filetype = "neo-tree", text = "File Explorer", padding = 1}}, + enforce_regular_tabs = true, + separator_style = 'slant' + }, + highlights = { + separator = { + guifg = colors.bg_alt + }, + separator_visible = { + guifg = colors.bg_alt + }, + separator_selected = { + guifg = colors.bg_alt + } + } +} +vim.keymap.set("n", "", "bnext", opts) +vim.keymap.set("n", "", "bprevious", opts) + + +require('nvim-autopairs').setup{} + + +require('gitsigns').setup() + + +vim.o.clipboard = 'unnamedplus' +vim.o.expandtab = true +vim.o.fileencoding = 'utf-8' +vim.o.ignorecase = true +vim.o.mouse = 'a' +vim.o.showmode = false +vim.o.number = true +vim.o.shiftwidth = 2 +vim.o.signcolumn = 'yes' +vim.o.smartcase = true +vim.o.spelllang = 'en' +vim.o.tabstop = 2 + + +require("neo-tree.command")._command(vim.fn.getcwd()) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim deleted file mode 100644 index 28bce60..0000000 --- a/.config/nvim/init.vim +++ /dev/null @@ -1,151 +0,0 @@ -tnoremap - -set termguicolors -"set colorcolumn=88 -set background=dark -set number -match Error /\%>88c/ - -highlight Pmenu ctermbg=gray guibg=gray - -" if hidden is not set, TextEdit might fail. -set hidden - -" Some servers have issues with backup files, see #649 -set nobackup -set nowritebackup - -" Better display for messages -set cmdheight=2 - -" You will have bad experience for diagnostic messages when it's default 4000. -set updatetime=300 - -" don't give |ins-completion-menu| messages. -set shortmess+=c - -" always show signcolumns -set signcolumn=yes - -" Use tab for trigger completion with characters ahead and navigate. -" Use command ':verbose imap ' to make sure tab is not mapped by other plugin. -inoremap - \ pumvisible() ? "\" : - \ check_back_space() ? "\" : - \ coc#refresh() -inoremap pumvisible() ? "\" : "\" - -function! s:check_back_space() abort - let col = col('.') - 1 - return !col || getline('.')[col - 1] =~# '\s' -endfunction - -" Use to trigger completion. -inoremap coc#refresh() - -" Use to confirm completion, `u` means break undo chain at current position. -" Coc only does snippet and additional edit on confirm. -inoremap pumvisible() ? "\" : "\u\" -" Or use `complete_info` if your vim support it, like: -" inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" - -" Use `[g` and `]g` to navigate diagnostics -nmap [g (coc-diagnostic-prev) -nmap ]g (coc-diagnostic-next) - -" Remap keys for gotos -nmap gd (coc-definition) -nmap gy (coc-type-definition) -nmap gi (coc-implementation) -nmap gr (coc-references) - -" Use K to show documentation in preview window -nnoremap K :call show_documentation() - -function! s:show_documentation() - if (index(['vim','help'], &filetype) >= 0) - execute 'h '.expand('') - else - call CocAction('doHover') - endif -endfunction - -" Highlight symbol under cursor on CursorHold -autocmd CursorHold * silent call CocActionAsync('highlight') - -" Remap for rename current word -nmap rn (coc-rename) - -augroup mygroup - autocmd! - " Setup formatexpr specified filetype(s). - autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') - " Update signature help on jump placeholder - autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') -augroup end - -" Remap for do codeAction of selected region, ex: `aap` for current paragraph -xmap a (coc-codeaction-selected) -nmap a (coc-codeaction-selected) - -" Remap for do codeAction of current line -nmap ac (coc-codeaction) -" Fix autofix problem of current line -nmap qf (coc-fix-current) - -" Create mappings for function text object, requires document symbols feature of -" languageserver. -xmap if (coc-funcobj-i) -xmap af (coc-funcobj-a) -omap if (coc-funcobj-i) -omap af (coc-funcobj-a) - -" Use for select selections ranges, needs server support, like: coc-tsserver, -" coc-python -nmap (coc-range-select) -xmap (coc-range-select) - -" Use `:Format` to format current buffer -command! -nargs=0 Format :call CocAction('format') - -" Use `:Fold` to fold current buffer -command! -nargs=? Fold :call CocAction('fold', ) - -" use `:OR` for organize import of current buffer -command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') - -" Add status line support, for integration with other plugin, checkout `:h coc-status` -set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} - -" Using CocList -" Show all diagnostics -nnoremap a :CocList diagnostics -" Manage extensions -nnoremap e :CocList extensions -" Show commands -nnoremap c :CocList commands -" Find symbol of current document -nnoremap o :CocList outline -" Search workspace symbols -nnoremap s :CocList -I symbols -" Do default action for next item. -nnoremap j :CocNext -" Do default action for previous item. -nnoremap k :CocPrev -" Resume latest coc list -nnoremap p :CocListResume - -" coc-explorer -nmap e :CocCommand explorer - -call plug#begin() -Plug 'rbgrouleff/bclose.vim' -Plug 'francoiscabrol/ranger.vim' -Plug 'neoclide/coc.nvim', {'branch': 'release'} -Plug 'lervag/vimtex' -Plug 'iCyMind/NeoSolarized' -call plug#end() - -colorscheme NeoSolarized - -set clipboard=unnamedplus diff --git a/.config/nvim/lua/feline/solarized.lua b/.config/nvim/lua/feline/solarized.lua new file mode 100644 index 0000000..a6c4263 --- /dev/null +++ b/.config/nvim/lua/feline/solarized.lua @@ -0,0 +1,19 @@ +local colors = require('solarized.colors') + +local solarized = { + fg = colors.fg, + bg = colors.bg_alt, + black = colors.black, + skyblue = colors.paleblue, + cyan = colors.cyan, + green = colors.green, + oceanblue = colors.blue, + magenta = colors.magenta, + orange = colors.orange, + red = colors.red, + violet = colors.purple, + white = colors.white, + yellow = colors.yellow +} + +return solarized diff --git a/.config/nvim/lua/lspconfig/settings.lua b/.config/nvim/lua/lspconfig/settings.lua new file mode 100644 index 0000000..81ea519 --- /dev/null +++ b/.config/nvim/lua/lspconfig/settings.lua @@ -0,0 +1,46 @@ +-- Mappings. +-- See `:help vim.diagnostic.*` for documentation on any of the below functions +local opts = { noremap=true, silent=true } +vim.keymap.set('n', 'e', vim.diagnostic.open_float, opts) +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, opts) + +-- Use an on_attach function to only map the following keys +-- after the language server attaches to the current buffer +local on_attach = function(client, bufnr) + -- Enable completion triggered by + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + + -- Mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local bufopts = { noremap=true, silent=true, buffer=bufnr } + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) + vim.keymap.set('n', '', vim.lsp.buf.signature_help, bufopts) + vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, bufopts) + vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, bufopts) + vim.keymap.set('n', 'wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, bufopts) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, bufopts) + vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) + vim.keymap.set('n', 'f', vim.lsp.buf.formatting, bufopts) +end + +-- Use a loop to conveniently call 'setup' on multiple servers and +-- map buffer local keybindings when the language server attaches +local servers = { 'pyright', 'sumneko_lua' } +for _, lsp in pairs(servers) do + require('lspconfig')[lsp].setup { + on_attach = on_attach, + flags = { + -- This will be the default in neovim 0.7+ + debounce_text_changes = 150, + } + } +end diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua new file mode 100644 index 0000000..e1e6208 --- /dev/null +++ b/.config/nvim/lua/plugins.lua @@ -0,0 +1,37 @@ +return require('packer').startup(function() + use 'wbthomason/packer.nvim' + + use 'nvim-lua/popup.nvim' + + use { + 'nvim-treesitter/nvim-treesitter', + run = ':TSUpdate' + } + + use {'feline-nvim/feline.nvim', requires = 'kyazdani42/nvim-web-devicons'} + + use { + "williamboman/nvim-lsp-installer", + "neovim/nvim-lspconfig", + } + + use { + "nvim-neo-tree/neo-tree.nvim", + branch = "v2.x", + requires = { + "nvim-lua/plenary.nvim", + "kyazdani42/nvim-web-devicons", + "MunifTanjim/nui.nvim", + 's1n7ax/nvim-window-picker' + } + } + + use('mrjones2014/smart-splits.nvim') + + use {'akinsho/bufferline.nvim', tag = "v2.*", requires = 'kyazdani42/nvim-web-devicons'} + + use('windwp/nvim-autopairs') + + use('lewis6991/gitsigns.nvim') + +end) diff --git a/.config/nvim/solarized.nvim b/.config/nvim/solarized.nvim new file mode 160000 index 0000000..e145551 --- /dev/null +++ b/.config/nvim/solarized.nvim @@ -0,0 +1 @@ +Subproject commit e14555132db1204c1feed0d6441a2ff170bf761f diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..82ccd2a --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule ".config/nvim/solarized.nvim"] + path = .config/nvim/solarized.nvim + url = ssh://git@git.rhiobet.sh:42424/rhiobet/solarized.nvim.git