I did way too much in this one commit
Vimconf2021 inspired me a lot and I'm not done yet
This commit is contained in:
parent
aa4d71c989
commit
bebd4c1ff9
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
spell/
|
9
init.lua
9
init.lua
@ -1,7 +1,6 @@
|
||||
-- init.lua
|
||||
|
||||
require('plugins')
|
||||
require('settings')
|
||||
require('maps')
|
||||
require('commands')
|
||||
require('utils')
|
||||
require'plugins'.init()
|
||||
require'settings'.init()
|
||||
require'maps'.init()
|
||||
require'commands'
|
||||
|
@ -1,10 +1,8 @@
|
||||
-- commands.lua
|
||||
|
||||
-- autocmd! User GoyoEnter Limelight
|
||||
-- autocmd! User GoyoLeave Limelight!
|
||||
-- command W :execute ':silent w !sudo tee % > /dev/null' | :edit!
|
||||
|
||||
vim.cmd'autocmd! User GoyoEnter Limelight'
|
||||
vim.cmd'autocmd! User GoyoLeave Limelight!'
|
||||
|
||||
vim.cmd'autocmd BufRead,BufNewFile *.wiki,*.md,*.tex set wrap'
|
||||
|
||||
vim.cmd'command W :execute \':silent w !sudo tee % > /dev/null\' | :edit!'
|
||||
|
74
lua/maps.lua
74
lua/maps.lua
@ -1,35 +1,71 @@
|
||||
|
||||
-- maps.lua
|
||||
|
||||
local maps = {}
|
||||
|
||||
local function map(mode, lhs, rhs, opts)
|
||||
local options = {noremap = true}
|
||||
if opts then options = vim.tbl_extend('force', options, opts) end
|
||||
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
|
||||
end
|
||||
|
||||
vim.g.mapleader = " "
|
||||
-- Toggle Goyo
|
||||
function maps.toggleGoyo()
|
||||
map('n', '<C-g>', ':Goyo<Enter>', {noremap = false})
|
||||
end
|
||||
function maps.term()
|
||||
-- Open and move to resized terminal
|
||||
map('n', '<leader>t', '<C-w>s<C-w>j :terminal<CR>:res 5<CR>i', {noremap = false})
|
||||
-- Enter normal mode in terminal
|
||||
map('t', 'ß<C-N>', '<C-\\><C-N>')
|
||||
-- Clear highlight
|
||||
map('n', '<C-l>', '<cmd>noh<CR>')
|
||||
-- Telescope
|
||||
end
|
||||
|
||||
function maps.telescope()
|
||||
map('n', '<Leader>ff', '<cmd>lua require(\'telescope.builtin\').git_files()<CR>')
|
||||
map('n', '<Leader>fg', '<cmd>lua require(\'telescope.builtin\').live_grep()<CR>')
|
||||
map('n', '<Leader>fb', '<cmd>lua require(\'telescope.builtin\').buffers()<CR>')
|
||||
map('n', '<Leader>fh', '<cmd>lua require(\'telescope.builtin\').help_tags()<CR>')
|
||||
-- Move to window in any mode
|
||||
-- map('t', 'ª', '<C-\\><C-N><C-w>h')
|
||||
-- map('t', 'º', '<C-\\><C-N><C-w>j')
|
||||
-- map('t', '∆', '<C-\\><C-N><C-w>k')
|
||||
-- map('t', '@', '<C-\\><C-N><C-w>l')
|
||||
-- map('i', 'ª', '<C-\\><C-N><C-w>h')
|
||||
-- map('i', 'º', '<C-\\><C-N><C-w>j')
|
||||
-- map('i', '∆', '<C-\\><C-N><C-w>k')
|
||||
-- map('i', '@', '<C-\\><C-N><C-w>l')
|
||||
-- map('n', 'ª', '<C-w>h')
|
||||
-- map('n', 'º', '<C-w>j')
|
||||
-- map('n', '∆', '<C-w>k')
|
||||
-- map('n', '@', '<C-w>l')
|
||||
end
|
||||
|
||||
function maps.fixIndent()
|
||||
map('v', '<', '<gv')
|
||||
map('v', '>', '>gv')
|
||||
end
|
||||
|
||||
function maps.moveByRow()
|
||||
-- When text is wrapped, move by terminal rows, not lines, unles a count is provided
|
||||
map('n', 'j', 'v:count == 0 ? \'gj\' : \'j\'', {silent = true, expr = true})
|
||||
map('n', 'k', 'v:count == 0 ? \'gk\' : \'k\'', {silent = true, expr = true})
|
||||
end
|
||||
|
||||
function maps.centeredSearch()
|
||||
map('n', 'n', 'nzzzv')
|
||||
map('n', 'N', 'Nzzzv')
|
||||
end
|
||||
|
||||
function maps.moveToWindow()
|
||||
map('t', 'ª', '<C-\\><C-N><C-w>h')
|
||||
map('t', 'º', '<C-\\><C-N><C-w>j')
|
||||
map('t', '∆', '<C-\\><C-N><C-w>k')
|
||||
map('t', '@', '<C-\\><C-N><C-w>l')
|
||||
map('i', 'ª', '<C-\\><C-N><C-w>h')
|
||||
map('i', 'º', '<C-\\><C-N><C-w>j')
|
||||
map('i', '∆', '<C-\\><C-N><C-w>k')
|
||||
map('i', '@', '<C-\\><C-N><C-w>l')
|
||||
map('n', 'ª', '<C-w>h')
|
||||
map('n', 'º', '<C-w>j')
|
||||
map('n', '∆', '<C-w>k')
|
||||
map('n', '@', '<C-w>l')
|
||||
end
|
||||
|
||||
function maps.init()
|
||||
vim.g.mapleader = " "
|
||||
|
||||
maps.toggleGoyo()
|
||||
maps.term()
|
||||
maps.telescope()
|
||||
maps.fixIndent()
|
||||
maps.moveByRow()
|
||||
maps.centeredSearch()
|
||||
maps.moveToWindow()
|
||||
end
|
||||
|
||||
return maps
|
||||
|
@ -1,28 +1,49 @@
|
||||
-- plugin.lua
|
||||
|
||||
vim.cmd 'packadd paq-nvim'
|
||||
local paq = require'paq-nvim'.paq
|
||||
paq{'savq/paq-nvim', opt=true}
|
||||
local plugins = {}
|
||||
|
||||
function plugins.load(pluginList)
|
||||
for _, plugin in pairs(pluginList) do
|
||||
require'paq-nvim'.paq(plugin)
|
||||
end
|
||||
end
|
||||
|
||||
local pluginList = {
|
||||
-- Handle itself
|
||||
{'savq/paq-nvim', opt=true},
|
||||
|
||||
-- Theme
|
||||
paq 'akinsho/nvim-bufferline.lua'
|
||||
paq 'hoob3rt/lualine.nvim'
|
||||
paq 'airblade/vim-gitgutter'
|
||||
paq 'kyazdani42/nvim-web-devicons'
|
||||
paq 'doums/darcula'
|
||||
paq 'junegunn/goyo.vim'
|
||||
paq 'junegunn/limelight.vim'
|
||||
|
||||
-- Utils
|
||||
paq 'nvim-lua/popup.nvim'
|
||||
paq 'nvim-lua/plenary.nvim'
|
||||
|
||||
-- File Navigation
|
||||
paq 'kyazdani42/nvim-tree.lua'
|
||||
paq 'nvim-telescope/telescope.nvim'
|
||||
|
||||
-- lsp
|
||||
paq 'neovim/nvim-lspconfig'
|
||||
'kyazdani42/nvim-web-devicons',
|
||||
'rktjmp/lush.nvim',
|
||||
'briones-gabriel/darcula-solid.nvim',
|
||||
|
||||
-- treesitter
|
||||
-- paq 'nvim-treesitter/nvim-treesitter'
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
|
||||
-- Utils
|
||||
'akinsho/nvim-bufferline.lua',
|
||||
'hoob3rt/lualine.nvim',
|
||||
'airblade/vim-gitgutter',
|
||||
'nvim-lua/popup.nvim',
|
||||
'nvim-lua/plenary.nvim',
|
||||
|
||||
-- File Navigation
|
||||
'kyazdani42/nvim-tree.lua',
|
||||
'nvim-telescope/telescope.nvim',
|
||||
|
||||
-- lsp
|
||||
'neovim/nvim-lspconfig',
|
||||
'williamboman/nvim-lsp-installer',
|
||||
|
||||
-- writing
|
||||
'vimwiki/vimwiki',
|
||||
'junegunn/goyo.vim',
|
||||
'junegunn/limelight.vim',
|
||||
}
|
||||
|
||||
function plugins.init()
|
||||
vim.cmd 'packadd paq-nvim'
|
||||
plugins.load(pluginList)
|
||||
end
|
||||
|
||||
return plugins
|
||||
|
@ -1,64 +0,0 @@
|
||||
-- settings.lua
|
||||
|
||||
local cmd = vim.cmd
|
||||
local scopes = {o = vim.o, bo = vim.bo, wo = vim.wo}
|
||||
|
||||
local function opt(scope, key, value)
|
||||
scopes[scope][key] = value
|
||||
if scope ~= 'o' then scopes['o'][key] = value end
|
||||
end
|
||||
|
||||
|
||||
---- Misc Options
|
||||
-- global options
|
||||
opt('o', 'backup', false)
|
||||
opt('o', 'undodir', '/Users/fschmidt/.cache/nvim/undodir')
|
||||
opt('o', 'smartcase', true)
|
||||
opt('o', 'laststatus', 2)
|
||||
opt('o', 'hidden', true)
|
||||
opt('o', 'hlsearch', false)
|
||||
opt('o', 'incsearch', true)
|
||||
opt('o', 'ignorecase', true)
|
||||
opt('o', 'scrolloff', 12)
|
||||
opt('o', 'mouse', 'a')
|
||||
opt('o', 'autochdir', true)
|
||||
|
||||
-- window-local options
|
||||
opt('wo', 'number', true)
|
||||
opt('wo', 'wrap', false)
|
||||
opt('wo', 'signcolumn', 'yes')
|
||||
|
||||
-- buffer-local options
|
||||
opt('bo', 'shiftwidth', 4)
|
||||
opt('bo', 'tabstop', 4)
|
||||
opt('bo', 'softtabstop', 4)
|
||||
opt('bo', 'expandtab', true)
|
||||
opt('bo', 'autoindent', true)
|
||||
opt('bo', 'swapfile', false)
|
||||
opt('bo', 'undofile', true)
|
||||
|
||||
---- Theme
|
||||
-- Font
|
||||
opt('o', 'guifont', 'Source Code Pro for Powerline')
|
||||
|
||||
-- Statusline
|
||||
require'lualine'.setup {
|
||||
options = {
|
||||
theme = 'onedark'
|
||||
}
|
||||
}
|
||||
|
||||
-- Bufferline
|
||||
local bufferline = require('bufferline')
|
||||
bufferline.setup()
|
||||
|
||||
local function ColorDarcula()
|
||||
vim.g.limelight_conceal_ctermfg = 'gray'
|
||||
cmd 'colorscheme darcula'
|
||||
end
|
||||
|
||||
opt('bo', 'syntax', 'on')
|
||||
ColorDarcula()
|
||||
|
||||
|
||||
-- File Navigation
|
44
lua/settings/init.lua
Normal file
44
lua/settings/init.lua
Normal file
@ -0,0 +1,44 @@
|
||||
-- settings.lua
|
||||
|
||||
local settings = {}
|
||||
|
||||
function settings.initMisc()
|
||||
vim.opt.backup = false
|
||||
vim.opt.undodir = '/Users/fschmidt/.cache/nvim/undodir'
|
||||
vim.opt.swapfile = false
|
||||
vim.opt.undofile = true
|
||||
vim.opt.smartcase = true
|
||||
vim.opt.ignorecase = true
|
||||
vim.opt.laststatus = 2
|
||||
vim.opt.hidden = true
|
||||
vim.opt.hlsearch = false
|
||||
vim.opt.incsearch = true
|
||||
vim.opt.scrolloff = 12
|
||||
vim.opt.sidescrolloff = 8
|
||||
vim.opt.mouse = 'a'
|
||||
vim.opt.autochdir = true
|
||||
vim.opt.clipboard = 'unnamed,unnamedplus'
|
||||
vim.opt.number = true
|
||||
vim.opt.wrap = false
|
||||
vim.opt.signcolumn = 'yes:2'
|
||||
vim.opt.list = true
|
||||
vim.opt.listchars = 'tab:▸ ,trail:·'
|
||||
vim.opt.shiftwidth = 4
|
||||
vim.opt.tabstop = 4
|
||||
vim.opt.softtabstop = 4
|
||||
vim.opt.expandtab = false
|
||||
vim.opt.autoindent = true
|
||||
end
|
||||
|
||||
function settings.initVimWiki()
|
||||
vim.g.vimwiki_list = {{path = '~/Documents/Buch/wiki', syntax = 'markdown', ext = '.md'}}
|
||||
end
|
||||
|
||||
function settings.init()
|
||||
settings.initMisc()
|
||||
settings.initVimWiki()
|
||||
require'settings.theme'.init()
|
||||
require'settings.lsp'.init()
|
||||
end
|
||||
|
||||
return settings
|
55
lua/settings/lsp.lua
Normal file
55
lua/settings/lsp.lua
Normal file
@ -0,0 +1,55 @@
|
||||
-- LSP Config
|
||||
|
||||
local lsp = {}
|
||||
|
||||
local on_attach = function(_, 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')
|
||||
|
||||
local opts = { noremap=true, silent=true }
|
||||
|
||||
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', '<leader>wa', '<cmd>lua vim.lsp.buf.add_workleader_folder()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>wr', '<cmd>lua vim.lsp.buf.remove_workleader_folder()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workleader_folders()))<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>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', '<leader>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
|
||||
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
||||
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
||||
end
|
||||
|
||||
function lsp.init()
|
||||
local lsp_installer = require'nvim-lsp-installer'
|
||||
|
||||
lsp_installer.on_server_ready(function(server)
|
||||
local opts = {}
|
||||
if server.name == 'sumneko_lua' then
|
||||
opts.settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { 'vim' }
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
opts.on_attach = on_attach
|
||||
opts.flags = {
|
||||
debounce_text_changes = 150,
|
||||
}
|
||||
server:setup(opts)
|
||||
end)
|
||||
end
|
||||
|
||||
return lsp
|
36
lua/settings/theme.lua
Normal file
36
lua/settings/theme.lua
Normal file
@ -0,0 +1,36 @@
|
||||
-- Theming
|
||||
|
||||
local theme = {}
|
||||
|
||||
function theme.initFont()
|
||||
vim.opt.guifont = 'Source Code Pro for Powerline'
|
||||
end
|
||||
|
||||
function theme.initStatusline()
|
||||
require'lualine'.setup {
|
||||
options = {
|
||||
theme = 'onedark'
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
function theme.initBufferline()
|
||||
local bufferline = require'bufferline'
|
||||
bufferline.setup()
|
||||
end
|
||||
|
||||
function theme.initColorscheme()
|
||||
vim.g.limelight_conceal_ctermfg = 'gray'
|
||||
vim.cmd'colorscheme darcula-solid'
|
||||
vim.cmd'set termguicolors'
|
||||
vim.opt.syntax = 'on'
|
||||
end
|
||||
|
||||
function theme.init()
|
||||
theme.initFont()
|
||||
theme.initStatusline()
|
||||
theme.initBufferline()
|
||||
theme.initColorscheme()
|
||||
end
|
||||
|
||||
return theme
|
Loading…
Reference in New Issue
Block a user