neovim refresh

This commit is contained in:
Sloane Perrault 2022-09-19 07:47:06 -04:00
parent 63f786d78e
commit c085935775
4 changed files with 130 additions and 240 deletions

View file

@ -1,74 +1,6 @@
set nocompatible
" download vim-plug if missing
if empty(glob("~/.local/share/nvim/site/autoload/plug.vim"))
silent! execute '!curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * silent! PlugInstall
endif
call plug#begin(stdpath('data') . '/plugged')
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-abolish'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb'
Plug 'tpope/vim-sexp-mappings-for-regular-people'
Plug 'guns/vim-sexp'
Plug 'christoomey/vim-sort-motion'
Plug 'kana/vim-textobj-user'
Plug 'kana/vim-textobj-indent'
Plug 'kana/vim-textobj-line'
Plug 'kyazdani42/nvim-web-devicons'
Plug 'christoomey/vim-tmux-navigator'
Plug 'preservim/nerdtree'
Plug 'tversteeg/registers.nvim'
Plug 'neovim/nvim-lspconfig'
Plug 'williamboman/nvim-lsp-installer'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/cmp-cmdline'
Plug 'hrsh7th/nvim-cmp'
Plug 'jose-elias-alvarez/null-ls.nvim'
Plug 'duane9/nvim-rg'
Plug 'tversteeg/registers.nvim'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
" https://github.com/mrjones2014/dash.nvim/issues/137
Plug 'ibhagwan/fzf-lua', {'commit': '341f0641ea4b0bd1cb798d7138f1a84c90848b02'}
Plug 'mrjones2014/dash.nvim', { 'do': 'make install' }
Plug 'elixir-editors/vim-elixir'
Plug 'khaveesh/vim-fish-syntax'
Plug 'neovimhaskell/haskell-vim'
Plug 'alx741/vim-hindent'
Plug 'gleam-lang/gleam.vim'
Plug 'benknoble/vim-racket'
Plug 'vim-scripts/scribble.vim'
Plug 'dracula/vim', { 'as': 'dracula' }
call plug#end()
syntax enable
filetype plugin indent on
colorscheme dracula
lua require('plugins')
set number
set relativenumber
@ -79,70 +11,6 @@ set expandtab
set mouse=a
set cmdheight=2
colorscheme dracula
set nobackup
set nowritebackup
set spell
let mapleader=','
nnoremap ; :
nnoremap q; q:
vnoremap ; :
vnoremap q; q:
nnoremap <Leader>w :w<CR>
nnoremap <Leader>wq :wq<CR>
nnoremap <Leader>q :q<CR>
nnoremap <silent> <ESC> :nohlsearch<CR>
nnoremap <Leader><Tab> :NERDTreeToggle<CR>
" Copy to clipboard
vnoremap <leader>y "+y
nnoremap <leader>Y "+yg_
nnoremap <leader>y "+y
" Paste from clipboard
nnoremap <leader>p "+p
nnoremap <leader>P "+P
vnoremap <leader>p "+p
vnoremap <leader>P "+P
nnoremap <Leader>~ :split ~/.config/nvim/init.vim<CR>
nnoremap <Leader>so :so %<CR>
nnoremap <Leader>f <cmd>lua require('fzf-lua').files()<CR>
nnoremap <Leader>a <cmd>lua require('fzf-lua').grep_project()<CR>
" nnoremap <Leader>gs :Git<CR>
nnoremap <Leader>gs :Git<CR>
nnoremap <Leader>gp :Git push --force-with-lease -u origin head<CR>
nnoremap <Leader>gf :Git fetch<CR>
nnoremap <Leader>gr :Git rebase origin/main<CR>
nnoremap <Leader>gb :Git checkout -b
luafile ~/.config/nvim/lua/lsp-setup.lua
" lua require('gitsigns').setup()
nnoremap <Leader>o :only<CR>
lua require('dash').setup({ file_type_keywords = { elixir = { 'ex' } } })
nnoremap <Leader>d <cmd>lua require('dash').search()<CR>
" Terminal mode
tnoremap <Esc> <C-\><C-n>
tnoremap <C-h> <C-\><C-n><C-w>h
tnoremap <C-j> <C-\><C-n><C-w>j
tnoremap <C-k> <C-\><C-n><C-w>k
tnoremap <C-l> <C-\><C-n><C-w>l
let g:vim_markdown_frontmatter = 1
let g:vim_markdown_toml_frontmatter = 1
lua require('keys')

49
.config/nvim/lua/keys.lua Normal file
View file

@ -0,0 +1,49 @@
local wk = require('which-key')
local map = vim.keymap.set
wk.setup({
key_labels = {
['<space>'] = 'SPC',
['<cr>'] = 'RET',
['<tab>'] = 'TAB'
}
})
vim.opt.timeoutlen = 500
vim.g.mapleader = ' '
map({ 'n', 'v' }, ';', ':')
map({ 'n', 'v' }, 'q;', 'q:')
wk.register({
['<space>'] = { '<cmd>Telescope find_files<cr>', 'File file in project' },
['/'] = { '<cmd>Telescope live_grep<cr>', 'Search project' },
['<tab>'] = { '<cmd>NERDTreeToggle<cr>', 'Toggle NERDTree' },
f = {
name = 'file',
e = { '<cmd>Telescope find_files cwd=~/.config/nvim<cr>', 'Find file in .config/nvim' },
E = { '<cmd>e ~/.config/nvim<cr>', 'Browse .config/nvim' },
f = { '<cmd>Telescope find_files cwd=~/ hidden=true no_ignore=true no_ignore_parent=true follow=true<cr>', 'Find file' },
F = { '<cmd>Telescope find_files<cr>', 'File file from here' },
l = { '<cmd>NERDTreeFind<cr>', 'Locate file' },
r = { '<cmd>Telescope oldfiles<cr>', 'Recent files' },
},
q = {
name = 'quit/session',
b = { '<cmd>q<cr>', 'Buffer' },
q = { '<cmd>qa<cr>', 'Neovim' },
},
e = {
name = 'editor',
p = {
name = 'packer',
s = { '<cmd>PackerSync<cr>', 'Packer Sync' },
c = { '<cmd>PackerCompile<cr>', 'Packer Compile' },
l = { '<cmd>PackerClean<cr>', 'Packer Clean' },
}
}
}, { prefix = '<leader>' })

View file

@ -1,105 +0,0 @@
local lsp_installer = require("nvim-lsp-installer")
local on_attach = function(client, bufnr)
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
-- Enable completion triggered by <c-x><c-o>
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
local opts = { noremap=true, silent=true }
-- See `:help vim.lsp.*` for documentation on any of the below functions
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
-- buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
-- buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
-- buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
-- buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
-- buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
-- buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
-- buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
-- buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
-- buf_set_keymap('n', '<space>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
-- buf_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
-- buf_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
-- buf_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', opts)
-- buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
if client.resolved_capabilities.document_formatting then
vim.cmd([[
augroup LspFormatting
autocmd! * <buffer>
autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()
augroup END
]])
end
-- 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) -- For `vsnip` users.
-- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
-- require('snippy').expand_snippet(args.body) -- For `snippy` users.
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
end,
},
mapping = {
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
['<C-e>'] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
['<Tab>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
}, {
{ name = 'buffer' },
})
})
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline('/', {
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
end
-- Register a handler that will be called for all installed servers.
-- Alternatively, you may also register handlers on specific server instances instead (see example below).
lsp_installer.on_server_ready(function(server)
local opts = {
on_attach = on_attach
}
-- (optional) Customize the options passed to the server
-- if server.name == "tsserver" then
-- opts.root_dir = function() ... end
-- end
-- This setup() function is exactly the same as lspconfig's setup function.
-- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
server:setup(opts)
end)

View file

@ -0,0 +1,78 @@
local ensure_packer = function()
local fn = vim.fn
local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
if fn.empty(fn.glob(install_path)) > 0 then
fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
vim.cmd [[packadd packer.nvim]]
return true
end
return false
end
local packer_bootstrap = ensure_packer()
vim.cmd([[
augroup packer_user_config
autocmd!
autocmd BufWritePost plugins.lua source <afile> | PackerSync
augroup end
]])
return require('packer').startup(function(use)
use 'wbthomason/packer.nvim'
use 'tpope/vim-sensible'
use 'tpope/vim-surround'
use 'tpope/vim-commentary'
use 'tpope/vim-repeat'
use 'tpope/vim-dispatch'
use 'tpope/vim-abolish'
use {
'tpope/vim-fugitive',
'tpope/vim-rhubarb',
}
use 'christoomey/vim-sort-motion'
use 'christoomey/vim-tmux-navigator'
use {
'kana/vim-textobj-user',
'kana/vim-textobj-indent',
'kana/vim-textobj-line',
}
use {
'nvim-telescope/telescope.nvim', tag = '0.1.0',
requires = {
{ 'nvim-lua/plenary.nvim' },
{ 'nvim-telescope/telescope-fzf-native.nvim', run='make' }
},
config = function()
require('telescope').setup()
require('telescope').load_extension('fzf')
end
}
use { 'folke/which-key.nvim', config = function() require('keys') end }
use 'preservim/nerdtree'
use {
{ 'williamboman/mason.nvim', config = function() require('mason').setup() end },
'williamboman/mason-lspconfig.nvim',
'neovim/nvim-lspconfig',
'mfussenegger/nvim-dap',
'jose-elias-alvarez/null-ls.nvim',
'mhartington/formatter.nvim',
}
use { 'dracula/vim', as = 'dracula' }
-- Automatically set up your configuration after cloning packer.nvim
-- Put this at the end after all plugins
if packer_bootstrap then
require('packer').sync()
end
end)