my neovim conf ported to lua
This commit is contained in:
commit
0bc8580653
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
plugin/packer_compiled.lua
|
7
init.lua
Normal file
7
init.lua
Normal file
@ -0,0 +1,7 @@
|
||||
require 'plugins'
|
||||
|
||||
vim.cmd('colorscheme space-vim-dark')
|
||||
|
||||
require 'lsp'
|
||||
require 'settings'
|
||||
require 'keys'
|
22
lua/keys.lua
Normal file
22
lua/keys.lua
Normal file
@ -0,0 +1,22 @@
|
||||
local key = vim.api.nvim_set_keymap
|
||||
local u = require('utils')
|
||||
|
||||
vim.cmd([[autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif]])
|
||||
vim.cmd([[autocmd BufNewFile,BufRead *.md setlocal filetype=notes]])
|
||||
|
||||
key('n', ';', ':Files<CR>', {})
|
||||
key('', '<C-n>', ':NERDTreeToggle<CR>', {})
|
||||
|
||||
-- LSP Key Config
|
||||
local silent_opts = {silent = true}
|
||||
key('n', '<c-]>', ':lua vim.lsp.buf.definition()<CR>', silent_opts)
|
||||
key('n', 'K', ':lua vim.lsp.buf.hover()<CR>', silent_opts)
|
||||
key('n', 'gD', ':lua vim.lsp.buf.implementation()<CR>', silent_opts)
|
||||
key('n', '<c-k>', ':lua vim.lsp.buf.signature_help()<CR>', silent_opts)
|
||||
key('n', '1gD', ':lua vim.lsp.buf.type_definition()<CR>', silent_opts)
|
||||
key('n', 'gr', ':lua vim.lsp.buf.references()<CR>', silent_opts)
|
||||
key('n', 'g0', ':lua vim.lsp.buf.document_symbol()<CR>', silent_opts)
|
||||
key('n', 'gW', ':lua vim.lsp.buf.workspace_symbol()<CR>', silent_opts)
|
||||
key('n', 'gd', ':lua vim.lsp.buf.definition()<CR>', silent_opts)
|
||||
key('n', 'ga', ':lua vim.lsp.buf.code_action()<CR>', silent_opts)
|
||||
key('n', 'ff', ':lua vim.lsp.buf.formatting()<CR>', silent_opts)
|
69
lua/lsp.lua
Normal file
69
lua/lsp.lua
Normal file
@ -0,0 +1,69 @@
|
||||
local nvim_lsp = require'lspconfig'
|
||||
|
||||
local function setup_servers()
|
||||
require'lspinstall'.setup()
|
||||
local servers = require'lspinstall'.installed_servers()
|
||||
for _, lsp in pairs(servers) do
|
||||
nvim_lsp[lsp].setup{}
|
||||
end
|
||||
end
|
||||
|
||||
local opts = {
|
||||
tools = {
|
||||
autoSetHints = true,
|
||||
hover_with_actions = true,
|
||||
runnables = {
|
||||
use_telescope = true
|
||||
},
|
||||
inlay_hints = {
|
||||
show_parameter_hints = false,
|
||||
parameter_hints_prefix = "",
|
||||
other_hints_prefix = "",
|
||||
},
|
||||
},
|
||||
|
||||
-- all the opts to send to nvim-lspconfig
|
||||
-- these override the defaults set by rust-tools.nvim
|
||||
-- see https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#rust_analyzer
|
||||
server = {}, -- rust-analyer options
|
||||
}
|
||||
|
||||
require('rust-tools').setup(opts)
|
||||
|
||||
setup_servers()
|
||||
|
||||
require'lspinstall'.post_install_hook = function ()
|
||||
setup_servers()
|
||||
vim.cmd("bufdo e")
|
||||
end
|
||||
|
||||
local cmp = require'cmp'
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
vim.fn["vsnip#anonymous"](args.body)
|
||||
end,
|
||||
},
|
||||
mapping = {
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
['<S-Tab>'] = cmp.mapping.select_prev_item(),
|
||||
['<Tab>'] = cmp.mapping.select_next_item(),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.close(),
|
||||
['<CR>'] = cmp.mapping.confirm({
|
||||
behavior = cmp.ConfirmBehavior.Insert,
|
||||
select = true,
|
||||
})
|
||||
},
|
||||
|
||||
-- Installed sources
|
||||
sources = {
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'vsnip' },
|
||||
{ name = 'path' },
|
||||
{ name = 'buffer' },
|
||||
},
|
||||
})
|
45
lua/plugins.lua
Normal file
45
lua/plugins.lua
Normal file
@ -0,0 +1,45 @@
|
||||
vim.cmd([[autocmd BufWritePost plugins.lua source <afile> | PackerCompile]])
|
||||
|
||||
return require('packer').startup({function()
|
||||
-- Packer can manage itself
|
||||
use 'wbthomason/packer.nvim'
|
||||
|
||||
use 'vim-airline/vim-airline'
|
||||
use 'scrooloose/nerdtree'
|
||||
use 'Xuyuanp/nerdtree-git-plugin'
|
||||
use 'liuchengxu/space-vim-dark'
|
||||
|
||||
use 'tpope/vim-fugitive'
|
||||
use 'tpope/vim-commentary'
|
||||
use { 'tpope/vim-dispatch', opt = true, cmd = { 'Dispatch', 'Dispatch!' } }
|
||||
use 'junegunn/fzf.vim'
|
||||
use 'sheerun/vim-polyglot'
|
||||
use 'honza/vim-snippets'
|
||||
use 'szw/vim-tags'
|
||||
use 'rodjek/vim-puppet'
|
||||
use 'tpope/vim-rails'
|
||||
use 'tpope/vim-haml'
|
||||
use 'vim-scripts/bash-support.vim'
|
||||
use "akinsho/nvim-toggleterm.lua"
|
||||
use 'xolox/vim-notes'
|
||||
use 'xolox/vim-misc'
|
||||
use 'jremmen/vim-ripgrep'
|
||||
use 'airblade/vim-gitgutter'
|
||||
-- LSP Setup
|
||||
use 'neovim/nvim-lspconfig'
|
||||
use 'kabouzeid/nvim-lspinstall'
|
||||
use 'hrsh7th/nvim-cmp'
|
||||
use 'hrsh7th/cmp-nvim-lsp'
|
||||
use 'hrsh7th/cmp-vsnip'
|
||||
use 'hrsh7th/cmp-path'
|
||||
use 'hrsh7th/cmp-buffer'
|
||||
use 'simrat39/rust-tools.nvim'
|
||||
use 'nvim-lua/popup.nvim'
|
||||
use 'nvim-lua/plenary.nvim'
|
||||
use 'nvim-telescope/telescope.nvim'
|
||||
end,
|
||||
config = {
|
||||
display = {
|
||||
open_fn = require('packer.util').float,
|
||||
}
|
||||
}})
|
26
lua/settings.lua
Normal file
26
lua/settings.lua
Normal file
@ -0,0 +1,26 @@
|
||||
local o = vim.o
|
||||
local wo = vim.wo
|
||||
local bo = vim.bo
|
||||
|
||||
vim.cmd('syntax on')
|
||||
vim.cmd('set number')
|
||||
o.startofline = true
|
||||
wo.cursorline = true
|
||||
|
||||
o.updatetime = 300
|
||||
wo.signcolumn='yes'
|
||||
o.showcmd = true
|
||||
|
||||
|
||||
o.shell = 'bash'
|
||||
o.mouse = 'a'
|
||||
|
||||
o.smarttab = true
|
||||
bo.tabstop = 2
|
||||
bo.shiftwidth = 2
|
||||
bo.expandtab = true
|
||||
|
||||
wo.relativenumber = true
|
||||
|
||||
vim.cmd('set completeopt=menuone,noinsert,noselect')
|
||||
vim.cmd('set shortmess+=c')
|
25
lua/utils.lua
Normal file
25
lua/utils.lua
Normal file
@ -0,0 +1,25 @@
|
||||
local M = {}
|
||||
|
||||
function M.create_augroup(autocmds, name)
|
||||
vim.cmd('augroup ' .. name)
|
||||
vim.cmd('autocmd!')
|
||||
for _, autocmd in ipairs(autocmds) do
|
||||
vim.cmd('autocmd ' .. table.concat(autocmd, ' '))
|
||||
end
|
||||
vim.cmd('augroup END')
|
||||
end
|
||||
|
||||
function M.create_function(body, name)
|
||||
vim.cmd('function! ' .. name)
|
||||
for _, line in ipairs(body) do
|
||||
vim.cmd(line)
|
||||
end
|
||||
vim.cmd('endfunction')
|
||||
end
|
||||
|
||||
function _G.dump(...)
|
||||
local objects = vim.tbl_map(vim.inspect, {...})
|
||||
print(unpack(objects))
|
||||
end
|
||||
|
||||
return M
|
Loading…
x
Reference in New Issue
Block a user