" dotfiles -- nvim.init.vim.experimental " author: johannst let mapleader=" " " ----------------- " Plugins. " ----------------- " Install vim-plug for neivom " sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' call plug#begin('~/.nvim/plugged') " Colors. Plug 'chriskempson/base16-vim' " vsnip manager. Plug 'hrsh7th/vim-vsnip' " LSP. Plug 'neovim/nvim-lspconfig' " Completion framework. Plug 'hrsh7th/nvim-cmp' " Completion sources. Plug 'hrsh7th/cmp-vsnip' Plug 'hrsh7th/cmp-nvim-lsp' Plug 'hrsh7th/cmp-nvim-lsp-signature-help' Plug 'hrsh7th/cmp-buffer' Plug 'hrsh7th/cmp-path' Plug 'hrsh7th/cmp-cmdline' " Telescope. Plug 'nvim-lua/plenary.nvim' Plug 'nvim-telescope/telescope.nvim' Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'make' } " Treesitter Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} Plug 'nvim-treesitter/nvim-treesitter-context' call plug#end() " ----------------- " Setters. " ----------------- "set termguicolors set background=dark "colorscheme base16-default-dark "colorscheme base16-onedark highlight Pmenu ctermbg=DarkGray guibg=DarkGrey highlight PmenuSel ctermfg=Black guifg=Black ctermbg=LightGray guibg=LightGray set relativenumber set number set signcolumn=yes set mouse=a set scrolloff=8 set tabstop=4 set softtabstop=4 set shiftwidth=4 set smartindent set expandtab set list set listchars=tab:>-,trail:- set hidden set nobackup set noswapfile set hlsearch set incsearch set nowrap if executable('rg') set grepprg=rg\ --vimgrep endif " ----------------- " LSP & Complete. " ----------------- set completeopt=menuone,noselect lua << EOF -- Setup nvim-cmp. local cmp = require'cmp' cmp.setup({ snippet = { -- REQUIRED - you must specify a snippet engine expand = function(args) vim.fn["vsnip#anonymous"](args.body) end, }, mapping = cmp.mapping.preset.insert({ [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.complete(), [''] = cmp.mapping.abort(), [''] = cmp.mapping.confirm({ select = false }), }), sources = cmp.config.sources({ { name = 'nvim_lsp' }, { name = 'nvim_lsp_signature_help' }, }, { { name = 'vsnip' }, { name = 'buffer' }, { name = 'path' } }) }) -- Setup lspconfig. local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()) -- Disable LSP snippet completion. capabilities.textDocument.completion.completionItem.snippetSupport = false --print(vim.inspect(capabilities)) local on_attach = function(client, bufnr) -- Install `omnifunc` completion handler, get completion with . vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") -- Disable LSP highlighting. client.server_capabilities.semanticTokensProvider = nil end -- Setup rust-analyzer. require'lspconfig'.rust_analyzer.setup { on_attach = on_attach, capabilities = capabilities, } -- Setup clangd. require'lspconfig'.clangd.setup { cmd = { "clangd", "--background-index", "--completion-style=detailed" }, on_attach = on_attach, capabilities = capabilities, } -- Setup pyright. require'lspconfig'.pyright.setup { on_attach = on_attach, capabilities = capabilities, } -- Telescope. local picker_cfg = { theme = "ivy" } require('telescope').setup{ pickers = { buffers = picker_cfg, find_files = picker_cfg, man_pages = picker_cfg, }, } -- Telescope: load fzf-native. require('telescope').load_extension('fzf') EOF " ----------------- " Mappings. " ----------------- vnoremap p "_dP " LSP nnoremap lua vim.lsp.buf.definition() nnoremap lua vim.lsp.buf.type_definition() nnoremap K lua vim.lsp.buf.hover() nnoremap lua vim.lsp.buf.signature_help() inoremap lua vim.lsp.buf.signature_help() nnoremap r lua vim.lsp.buf.references() nnoremap i lua vim.lsp.buf.implementation() nnoremap f lua vim.lsp.buf.formatting() nnoremap a lua vim.lsp.buf.code_action() nnoremap n lua vim.lsp.buf.rename() " Telescope nnoremap fb Telescope buffers nnoremap ff Telescope find_files nnoremap fe Telescope file_browser nnoremap fg Telescope live_grep nnoremap fm Telescope man_pages sections={"2","3"} nnoremap ft Telescope lsp_document_symbols nnoremap fwt Telescope lsp_dynamic_workspace_symbols " ----------------- " Autogroups. " ----------------- augroup AG_highlight_yank autocmd! autocmd TextYankPost * silent! lua require'vim.highlight'.on_yank({timeout = 300}) augroup END " vim:ft=vim