Compare commits

..

5 Commits

Author SHA1 Message Date
Fabian Schmidt
a8818ea92a I honestly don't know anymore 2022-10-13 17:31:11 +02:00
Fabian Schmidt
bebd4c1ff9 I did way too much in this one commit
Vimconf2021 inspired me a lot and I'm not done yet
2021-11-26 23:38:04 +01:00
Fabian Schmidt
aa4d71c989 First step toward completing IDE
Update Settings to make lualine work again
Disable treesitter temporarily
2021-07-14 14:17:19 +02:00
Fabian Schmidt
c1516e7018 Install nvim-tree and telescope. Configure undofile. Some minor changes 2021-03-02 16:11:31 +01:00
Fabian Schmidt
54181f1123 Added script to more easily start nvim with init.lua 2021-03-02 10:51:52 +01:00
12 changed files with 411 additions and 99 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
spell/

View File

@ -1,7 +1,6 @@
-- init.lua
require('lua/plugins')
require('lua/settings')
require('lua/maps')
require('lua/commands')
require('lua/utils')
require'plugins'
require'settings'.init()
require'maps'.init()
require'commands'

View File

@ -1,10 +1,10 @@
-- 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 [[autocmd BufWritePre * lua vim.lsp.buf.format()]]
vim.cmd 'command W :execute \':silent w !sudo tee % > /dev/null\' | :edit!'

View File

@ -1,29 +1,72 @@
-- 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
map('n', '<C-g>', ':Goyo<Enter>', {noremap = false})
-- 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>')
-- 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')
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>')
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>')
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

View File

@ -1,18 +1,59 @@
-- plugin.lua
vim.cmd 'packadd paq-nvim'
local paq = require'paq-nvim'.paq
paq{'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'
require "paq" {
-- Handle itself
'savq/paq-nvim';
-- lsp
paq 'neovim/nvim-lspconfig'
paq 'nvim-lua/completion-nvim'
-- Theme
'kyazdani42/nvim-web-devicons';
'rktjmp/lush.nvim';
'briones-gabriel/darcula-solid.nvim';
-- treesitter
'nvim-treesitter/nvim-treesitter';
'nvim-treesitter/playground';
-- Utils
'akinsho/nvim-bufferline.lua';
'hoob3rt/lualine.nvim';
'j-hui/fidget.nvim';
'airblade/vim-gitgutter';
'nvim-lua/popup.nvim';
'nvim-lua/plenary.nvim';
-- File Navigation
'kyazdani42/nvim-tree.lua';
'nvim-telescope/telescope.nvim';
-- lsp
'williamboman/mason.nvim';
'williamboman/mason-lspconfig.nvim';
'neovim/nvim-lspconfig';
'onsails/lspkind-nvim'; -- pictograms
'simrat39/rust-tools.nvim';
-- completion
'hrsh7th/cmp-nvim-lsp';
'hrsh7th/cmp-nvim-lsp-signature-help';
'hrsh7th/cmp-buffer';
'hrsh7th/cmp-path';
'hrsh7th/cmp-nvim-lua';
'hrsh7th/cmp-cmdline';
'hrsh7th/nvim-cmp';
-- snippets needed for cmp
'L3MON4D3/LuaSnip';
'saadparwaiz1/cmp_luasnip';
-- autopair
'windwp/nvim-autopairs';
-- Linting & formtatting
'jose-elias-alvarez/null-ls.nvim';
-- writing
'vimwiki/vimwiki';
'junegunn/goyo.vim';
'junegunn/limelight.vim';
}

View File

@ -1,54 +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', 'swapfile', true)
opt('o', 'dir', '/tmp')
opt('o', 'smartcase', true)
opt('o', 'laststatus', 2)
opt('o', 'hlsearch', true)
opt('o', 'incsearch', true)
opt('o', 'ignorecase', true)
opt('o', 'scrolloff', 12)
opt('o', 'mouse', 'a')
-- window-local options
opt('wo', 'number', true)
opt('wo', 'wrap', false)
-- buffer-local options
opt('bo', 'shiftwidth', 4)
opt('bo', 'tabstop', 4)
opt('bo', 'softtabstop', 4)
opt('bo', 'expandtab', true)
opt('bo', 'autoindent', true)
---- Theme
-- Font
opt('o', 'guifont', 'Source Code Pro for Powerline')
-- Statusline
local lualine = require('lualine')
lualine.status()
-- Bufferline
local bufferline = require('bufferline')
bufferline.setup()
local function ColorDarcula()
lualine.options.theme = 'onedark'
vim.g.limelight_conceal_ctermfg = 'gray'
cmd 'colorscheme darcula'
end
opt('bo', 'syntax', 'on')
ColorDarcula()

View File

@ -0,0 +1,73 @@
-- Completion
local completion = {}
local cmp = require'cmp'
local lspkind = require'lspkind'
vim.opt.shortmess:append 'c'
cmp.setup({
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<C-n>"] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert },
["<C-p>"] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert },
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
['<C-s>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
['<C-y>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true
}),
['<C-e>'] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
['<CR>'] = cmp.mapping.confirm({ select = true }),
}),
sources = cmp.config.sources({
{ name = 'nvim_lua' },
{ name = 'nvim_lsp' },
{ name = 'path' },
{ name = 'luasnip' },
{ name = 'nvim_lsp_signature_help' },
}, {
{ name = 'buffer', keyword_length = 5 },
}),
formatting = {
format = lspkind.cmp_format {
with_text = true,
menu = {
buffer = "[buf]",
nvim_lsp = "[LSP]",
nvim_lua = "[api]",
path = "[path]",
luasnip = "[snip]",
}
}
}
})
-- Use buffer source for `/` (basically search words in buffer)
cmp.setup.cmdline('/', {
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':'
cmp.setup.cmdline(':', {
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
-- autopair
require('nvim-autopairs').setup {}
return completion

47
lua/settings/init.lua Normal file
View File

@ -0,0 +1,47 @@
-- 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
vim.opt.completeopt = { "menu", "menuone", "noselect" }
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()
require'settings.completion'
require'settings.tree'
end
return settings

61
lua/settings/lsp.lua Normal file
View File

@ -0,0 +1,61 @@
-- LSP Config
local lsp = {}
local lsp_attach = function(client, buf)
vim.api.nvim_buf_set_option(buf, "formatexpr", "v:lua.vim.lsp.formatexpr()")
vim.api.nvim_buf_set_option(buf, "omnifunc", "v:lua.vim.lsp.omnifunc")
vim.api.nvim_buf_set_option(buf, "tagfunc", "v:lua.vim.lsp.tagfunc")
local bufopts = { noremap=true, silent=true, buffer=buf }
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', '<C-k>', vim.lsp.buf.signature_help, bufopts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
end
function lsp.init()
require'mason'.setup()
require'mason-lspconfig'.setup()
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
local lspconfig = require'lspconfig'
lspconfig.sumneko_lua.setup {
capabilities = capabilities,
settings = {
Lua = {
diagnostics = {
globals = { 'vim' }
}
}
},
on_attach = lsp_attach
}
lspconfig.tsserver.setup {
capabilities = capabilities,
on_attach = lsp_attach
}
lspconfig.gopls.setup {
capabilities = capabilities,
on_attach = lsp_attach
}
--lspconfig.rust_analyzer.setup {
-- capabilities = capabilities,
-- on_attach = lsp_attach
--}
require("rust-tools").setup({
server = {
capabilities = capabilities,
on_attach = lsp_attach,
standalone = false
}
})
end
return lsp

41
lua/settings/theme.lua Normal file
View File

@ -0,0 +1,41 @@
-- Theming
local theme = {}
function theme.initFont()
vim.opt.guifont = 'Source Code Pro for Powerline'
end
function theme.lsp_status()
require'fidget'.setup {}
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.lsp_status()
theme.initStatusline()
theme.initBufferline()
theme.initColorscheme()
end
return theme

60
lua/settings/tree.lua Normal file
View File

@ -0,0 +1,60 @@
-- Tree
local tree = {}
require'nvim-tree'.setup {
disable_netrw = true,
hijack_netrw = true,
open_on_setup = false,
ignore_ft_on_setup = {},
open_on_tab = false,
hijack_cursor = false,
update_cwd = false,
hijack_directories = {
enable = true,
auto_open = true,
},
diagnostics = {
enable = false,
icons = {
hint = "",
info = "",
warning = "",
error = "",
}
},
update_focused_file = {
enable = false,
update_cwd = false,
ignore_list = {}
},
system_open = {
cmd = nil,
args = {}
},
filters = {
dotfiles = false,
custom = {}
},
git = {
enable = true,
ignore = true,
timeout = 500,
},
view = {
width = 30,
hide_root_folder = false,
side = 'left',
mappings = {
custom_only = false,
list = {}
}
},
actions = {
open_file = {
resize_window = false
}
}
}
return tree

View File