even more minimal config (flat file)

main
Steffen Rademacker 8 months ago
parent dfbfe6ea8e
commit c296d671ac

@ -1,4 +1,177 @@
require('plugins')
require('mappings')
require('options')
require('autocommands')
-- small helper function for loading external plugin config files
local g = vim.g
local set = vim.opt
local setlocal = vim.opt_local
local createCmd = vim.api.nvim_create_autocmd
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
local function get_config (key)
return function() require('plugins/' .. key) end
end
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({ 'git', 'clone', '--filter=blob:none', 'https://github.com/folke/lazy.nvim.git', '--branch=stable', lazypath })
end
-- minimum starter options and settings before loading plugins
set.rtp:prepend(lazypath)
vim.api.nvim_set_keymap('n', '<space>', '', {})
g.mapleader = ' '
g.maplocalleader = ' '
require('lazy').setup({
-- The colorscheme of choice
{ 'luisiacc/gruvbox-baby', priority = 1000 },
-- modern neovim with treesitter, lsp, cmp, vsnips and telescope
{ 'neovim/nvim-lspconfig', config = get_config('lspconfig') },
{ 'nvim-treesitter/nvim-treesitter', config = get_config('treesitter'), build = ':TSUpdate' },
{ 'nvim-treesitter/nvim-treesitter-textobjects', dependencies = 'nvim-treesitter/nvim-treesitter' },
{ 'nvim-treesitter/nvim-treesitter-refactor', dependencies = 'nvim-treesitter/nvim-treesitter' },
{ 'nvim-telescope/telescope.nvim', dependencies = 'nvim-lua/plenary.nvim', config = get_config('telescope') },
{ 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' },
{ 'hrsh7th/vim-vsnip', config = get_config('vsnip') },
{ 'rafamadriz/friendly-snippets', dependencies = 'hrsh7th/vim-vsnip' },
{ 'hrsh7th/nvim-cmp',
dependencies = {
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-cmdline',
'hrsh7th/cmp-calc',
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-path',
'hrsh7th/cmp-vsnip',
},
config = get_config('cmp'),
},
-- interface enhancements
{ 'folke/which-key.nvim', event = 'VeryLazy', config = get_config('which-key') },
{ 'folke/zen-mode.nvim', dependencies = 'folke/twilight.nvim', config = get_config('zen-mode') },
{ 'kevinhwang91/nvim-bqf', config = true },
{ 'lewis6991/gitsigns.nvim', config = true },
{ 'norcalli/nvim-colorizer.lua', event = 'BufReadPre', config = get_config('colorizer') },
{ 'nvim-lualine/lualine.nvim', dependencies = 'nvim-tree/nvim-web-devicons', config = get_config('lualine') },
-- editing / movement enhancements
{ 'AndrewRadev/splitjoin.vim' },
{ 'folke/flash.nvim', event = 'VeryLazy', config = true },
{ 'kylechui/nvim-surround', event = 'VeryLazy', config = true },
{ 'numToStr/Comment.nvim', config = true },
{ 'numToStr/Navigator.nvim', config = true },
{ 'tpope/vim-ragtag' }, -- TODO still needed?!
{ 'tpope/vim-repeat' }, -- TODO still needed?!
{ 'windwp/nvim-autopairs', event = 'InsertEnter', config = true },
-- more plugins and integrations
{ 'voldikss/vim-floaterm', config = get_config('floaterm') },
{ 'mfussenegger/nvim-lint', config = get_config('lint') },
-- TODO formatter with eslint, stylelint, markdownlint and code_actions?
{ 'nvim-neorg/neorg',
build = ':Neorg sync-parsers',
dependencies = 'nvim-lua/plenary.nvim',
config = get_config('neorg'),
},
{ 'jackMort/ChatGPT.nvim',
event = 'VeryLazy',
dependencies = {
'MunifTanjim/nui.nvim',
'nvim-lua/plenary.nvim',
'nvim-telescope/telescope.nvim'
},
config = true,
},
})
-- deactivate python and perl
g.loaded_python_provider = 0
g.loaded_perl_provider = 0
-- general sane vim options
set.breakindent = true
set.clipboard = 'unnamedplus'
set.cmdheight = 1
set.completeopt = { 'menu', 'menuone', 'noselect' }
set.conceallevel = 2
set.cpoptions:append('$')
set.cursorline = true
set.foldexpr = 'nvim_treesitter#foldexpr()'
set.foldmethod = 'expr'
set.gdefault = true
set.grepprg = 'rg'
set.hidden = true
set.ignorecase = true
set.infercase = true
set.laststatus = 3
set.lazyredraw = true
set.list = true
set.listchars = 'extends:»,precedes:«,tab:▸ ,trail:·'
set.foldenable = false
set.showmode = false
set.swapfile = false
set.wrap = false
set.writebackup = false
set.relativenumber = true
set.scrolljump = 5
set.scrolloff = 3
set.shiftround = true
set.shiftwidth = 2
set.shortmess:append('c')
set.showbreak = '\\\\\\\\'
set.showmatch = true
set.sidescroll = 10
set.sidescrolloff = 5
set.smartcase = true
set.splitright = true
set.splitbelow = true
set.timeoutlen = 300
set.updatetime = 300
set.virtualedit = 'all'
set.visualbell = true
set.wildmode = { 'list:longest', 'list:full' }
-- colorscheme
set.background = 'dark'
set.termguicolors = true
g.gruvbox_baby_telescope_theme = 1
vim.cmd 'colorscheme gruvbox-baby'
-- default language
vim.cmd 'language en_US.UTF-8'
-- set some autocommand -- TODO refactor those in createCmd if possible
vim.cmd([[
" Remember last location/cursor in file
autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal g'\"" | endif
" Autoresize windows/splits when vim resizes
autocmd VimResized * wincmd =
" floaterm integration
autocmd VimEnter * highlight FloatermBorder guibg='#282828' guifg='#fbf1c7'
]])
-- make dash-spearated-key"ords on "word" in vim
createCmd({ 'BufEnter', 'BufWinEnter' }, {
pattern = { '*.css', '*.scss', '*.json' },
callback = function() setlocal.iskeyword:append('-') end,
})
-- filetype-specific settings for text-files
createCmd({ 'BufEnter', 'BufWinEnter' }, {
pattern = { '*.md', '*.markdown', '*.rst', '*.txt', 'neomutt-*', '*.mail' },
callback = function()
setlocal.spell = true
setlocal.spelllang = { 'de', 'en' }
setlocal.wrap = true
setlocal.textwidth = 70
setlocal.formatoptions:append('q')
end,
})
-- filetype-specific settings for mails
createCmd({ 'BufEnter', 'BufWinEnter' }, {
pattern = { 'neomutt-*', '*.mail' },
callback = function()
setlocal.filetype = 'mail'
setlocal.comments:append('nb:>')
setlocal.formatoptions:append('aw')
end,
})

@ -1,39 +0,0 @@
local setlocal = vim.opt_local
local create = vim.api.nvim_create_autocmd
vim.cmd([[
" Remember last location/cursor in file
autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal g'\"" | endif
" Autoresize windows/splits when vim resizes
autocmd VimResized * wincmd =
]])
-- make dash-spearated-key"ords on "word" in vim
create({ 'BufEnter', 'BufWinEnter' }, {
pattern = { '*.css', '*.scss', '*.json' },
callback = function() setlocal.iskeyword:append('-') end,
})
-- filetype-specific settings for text-files
create({ 'BufEnter', 'BufWinEnter' }, {
pattern = { '*.md', '*.markdown', '*.rst', '*.txt', 'neomutt-*', '*.mail' },
callback = function()
setlocal.spell = true
setlocal.spelllang = { 'de', 'en' }
setlocal.wrap = true
setlocal.textwidth = 70
setlocal.formatoptions:append('q')
end,
})
-- filetype-specific settings for mails
create({ 'BufEnter', 'BufWinEnter' }, {
pattern = { 'neomutt-*', '*.mail' },
callback = function()
setlocal.filetype = 'mail'
setlocal.comments:append('nb:>')
setlocal.formatoptions:append('aw')
end,
})

@ -1,15 +0,0 @@
local null_ls = require('null-ls')
local b = null_ls.builtins
-- register any number of sources simultaneously
local sources = {
-- js and friends via eslint_d
b.formatting.eslint_d,
b.formatting.stylelint.with({ prefer_local = 'node_modules/.bin' }),
b.formatting.markdownlint,
b.code_actions.eslint_d,
}
null_ls.setup({
sources = sources,
})

@ -1,46 +0,0 @@
vim.opt.breakindent = true
vim.opt.clipboard = 'unnamedplus'
vim.opt.cmdheight = 1
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
vim.opt.conceallevel = 2
vim.opt.cpoptions:append('$')
vim.opt.cursorline = true
vim.opt.foldexpr = 'nvim_treesitter#foldexpr()'
vim.opt.foldmethod = 'expr'
vim.opt.gdefault = true
vim.opt.grepprg = 'rg'
vim.opt.hidden = true
vim.opt.ignorecase = true
vim.opt.infercase = true
vim.opt.laststatus = 3
vim.opt.lazyredraw = true
vim.opt.list = true
vim.opt.listchars = 'extends:»,precedes:«,tab:▸ ,trail:·'
vim.opt.foldenable = false
vim.opt.showmode = false
vim.opt.swapfile = false
vim.opt.wrap = false
vim.opt.writebackup = false
vim.opt.relativenumber = true
vim.opt.scrolljump = 5
vim.opt.scrolloff = 3
vim.opt.shiftround = true
vim.opt.shiftwidth = 2
vim.opt.shortmess:append('c')
vim.opt.showbreak = '\\\\\\\\'
vim.opt.showmatch = true
vim.opt.sidescroll = 10
vim.opt.sidescrolloff = 5
vim.opt.smartcase = true
vim.opt.splitright = true
vim.opt.splitbelow = true
vim.opt.timeoutlen = 300
vim.opt.updatetime = 300
vim.opt.virtualedit = 'all'
vim.opt.visualbell = true
vim.opt.wildmode = { 'list:longest', 'list:full' }
-- colorscheme and default language
vim.g.gruvbox_baby_telescope_theme = 1
vim.cmd 'colorscheme gruvbox-baby'
vim.cmd 'language en_US.UTF-8'

@ -1,83 +0,0 @@
-- small helper function for loading external plugin config files
local function get_config (key)
return function() require('config/' .. key) end
end
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({ 'git', 'clone', '--filter=blob:none', 'https://github.com/folke/lazy.nvim.git', '--branch=stable', lazypath })
end
-- minimum starter options and settings before loading plugins
vim.api.nvim_set_keymap('n', '<space>', '', {})
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
vim.g.loaded_python_provider = 0
vim.g.loaded_perl_provider = 0
vim.opt.rtp:prepend(lazypath)
vim.opt.background = 'dark'
vim.opt.termguicolors = true
require('lazy').setup({
-- The colorscheme of choice
{ 'luisiacc/gruvbox-baby', priority = 1000 },
-- modern neovim with treesitter, lsp, cmp, vsnips and telescope
{ 'neovim/nvim-lspconfig', config = get_config('lspconfig') },
{ 'nvim-treesitter/nvim-treesitter', config = get_config('treesitter'), build = ':TSUpdate' },
{ 'nvim-treesitter/nvim-treesitter-textobjects', dependencies = 'nvim-treesitter/nvim-treesitter' },
{ 'nvim-treesitter/nvim-treesitter-refactor', dependencies = 'nvim-treesitter/nvim-treesitter' },
{ 'nvim-telescope/telescope.nvim', dependencies = 'nvim-lua/plenary.nvim', config = get_config('telescope') },
{ 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' },
{ 'hrsh7th/vim-vsnip', config = get_config('vsnip') },
{ 'rafamadriz/friendly-snippets', dependencies = 'hrsh7th/vim-vsnip' },
{ 'hrsh7th/nvim-cmp',
dependencies = {
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-cmdline',
'hrsh7th/cmp-calc',
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-path',
'hrsh7th/cmp-vsnip',
},
config = get_config('cmp'),
},
-- interface enhancements
{ 'folke/which-key.nvim', event = 'VeryLazy', config = true },
{ 'folke/zen-mode.nvim', dependencies = 'folke/twilight.nvim', config = get_config('zen-mode') },
{ 'kevinhwang91/nvim-bqf', config = true },
{ 'lewis6991/gitsigns.nvim', config = true },
{ 'norcalli/nvim-colorizer.lua', event = 'BufReadPre', config = get_config('colorizer') },
{ 'nvim-lualine/lualine.nvim', dependencies = 'nvim-tree/nvim-web-devicons', config = get_config('lualine') },
-- editing / movement enhancements
{ 'AndrewRadev/splitjoin.vim' },
{ 'folke/flash.nvim', event = 'VeryLazy', config = true },
{ 'kylechui/nvim-surround', event = 'VeryLazy', config = true },
{ 'numToStr/Comment.nvim', config = true },
{ 'numToStr/Navigator.nvim', config = true },
{ 'tpope/vim-ragtag' }, -- TODO still needed?!
{ 'tpope/vim-repeat' }, -- TODO still needed?!
{ 'windwp/nvim-autopairs', event = 'InsertEnter', config = true },
-- more plugins and integrations
{ 'voldikss/vim-floaterm', config = get_config('floaterm') },
{ 'mfussenegger/nvim-lint', config = get_config('lint') },
-- TODO replace null-ls with formatter ?!
{ 'jose-elias-alvarez/null-ls.nvim', config = get_config('null-ls'), dependencies = 'nvim-lua/plenary.nvim' },
{ 'nvim-neorg/neorg',
build = ':Neorg sync-parsers',
dependencies = 'nvim-lua/plenary.nvim',
config = get_config('neorg'),
},
{ 'jackMort/ChatGPT.nvim',
event = 'VeryLazy',
dependencies = {
'MunifTanjim/nui.nvim',
'nvim-lua/plenary.nvim',
'nvim-telescope/telescope.nvim'
},
config = true,
},
})

@ -4,4 +4,3 @@ vim.g.floaterm_autoclose = 1
vim.g.floaterm_opener = 'edit'
vim.g.floaterm_borderchars = '─│─│╭╮╯╰'
vim.g.floaterm_title = ''
vim.cmd('au VimEnter * highlight FloatermBorder guibg="#282828" guifg="#fbf1c7"')

@ -11,6 +11,10 @@ require('lint').linters_by_ft = {
typescriptreact = { 'tsc', 'eslint_d' },
}
-- TODO stylelint for local files :/ override args/cwd
local stylelint = require('lint').linters.stylelint
require('lint').linters.stylelint = stylelint
vim.api.nvim_create_autocmd({ 'BufWritePost' }, {
pattern = {
'*.js', '*.ts', '*.jsx', '*.tsx',

@ -7,6 +7,11 @@ require('telescope').setup({
width = 0.9,
height = 0.9,
},
borderchars = {
prompt = { '', ' ', ' ', ' ', '', '', ' ', ' ' },
results = { ' ' },
preview = { ' ' },
},
},
extensions = {
fzf = {

@ -1,12 +1,3 @@
-- helper function for easier mappings
local map = function(mode, lhs, rhs, opts)
return vim.api.nvim_set_keymap(mode, lhs, rhs, vim.tbl_extend('keep', opts or {}, {
nowait = true,
silent = true,
noremap = true,
}))
end
local wk = require('which-key')
wk.register({
@ -37,34 +28,6 @@ wk.register({
S = { function() require('flash').treesitter() end, 'flash treesitter select' },
Y = { 'y$', 'yank till end of line with Y'},
-- all normal mode leader key mappings in one place
['<leader>'] = {
[','] = { '<cmd>Telescope find_files<cr>', '' },
['-'] = { '<C-w>s<C-w>j', '' },
['.'] = { '<cmd>Telescope buffers<cr>', '' },
['/'] = { '<cmd>Telescope search_history<cr>', '' },
[';'] = { '<cmd>Telescope command_history<cr>', '' },
['\''] = { '<cmd>Telescope git_files<cr>', '' },
['\\'] = { '<C-w>v<C-w>l', '' },
[']'] = { '<cmd>Telescope current_buffer_fuzzy_find<cr>', '' },
a = { '<cmd>Telescope live_grep<cr>', '' },
b = { '<cmd>Telescope git_branches<cr>', '' },
c = { '<cmd>Telescope git_bcommits<cr>', '' },
d = { '<cmd>lua vim.lsp.buf.declaration()<cr>', '' },
e = { '<cmd>lua vim.diagnostic.goto_next()<cr>', '' },
f = { '<cmd>lua vim.lsp.buf.formatting()<cr>', '' },
h = { '<cmd>lua vim.lsp.buf.hover()<cr>', '' },
r = { '<cmd>lua vim.lsp.buf.rename()<cr>', '' },
x = { '<cmd>lua vim.lsp.buf.code_action()<cr>', '' },
l = { '<cmd>FloatermNew lazygit<cr>', '' },
t = { '<cmd>FloatermNew<cr>', '' },
v = {
ve = { '<cmd>e $MYVIMRC<cr>', '' },
vr = { '<cmd>source $MYVIMRC<cr>', '' },
},
w = { '<cmd>set wrap! wrap?<cr>', '' },
},
-- with <CTRL> as modifier
['<C-h>'] = { '<cmd>NavigatorLeft<cr>', '' },
['<C-j>'] = { '<cmd>NavigatorDown<cr>', '' },
@ -79,10 +42,39 @@ wk.register({
['<M-l>'] = { '>>', 'bubbling lines with alt-hjkl', noremap = false },
})
-- non-normal-mode mappings
-- all normal mode leader key mappings in one place
wk.register({
['\\'] = { '<C-w>v<C-w>l', 'Vertical split' },
['-'] = { '<C-w>s<C-w>j', 'Horizontal split' },
[','] = { '<cmd>Telescope find_files<cr>', 'Telescope find files' },
['.'] = { '<cmd>Telescope buffers<cr>', 'Telescope find buffers' },
['\''] = { '<cmd>Telescope git_files<cr>', 'Telescope in git files' },
['/'] = { '<cmd>Telescope search_history<cr>', 'Telescope find in search history' },
[';'] = { '<cmd>Telescope command_history<cr>', 'Telescope find in command history' },
[']'] = { '<cmd>Telescope current_buffer_fuzzy_find<cr>', 'Telescope in current buffer' },
a = { '<cmd>Telescope live_grep<cr>', '' },
b = { '<cmd>Telescope git_branches<cr>', '' },
c = { '<cmd>Telescope git_bcommits<cr>', '' },
d = { '<cmd>lua vim.lsp.buf.declaration()<cr>', '' },
e = { '<cmd>lua vim.diagnostic.goto_next()<cr>', '' },
f = { '<cmd>lua vim.lsp.buf.formatting()<cr>', '' },
h = { '<cmd>lua vim.lsp.buf.hover()<cr>', '' },
r = { '<cmd>lua vim.lsp.buf.rename()<cr>', '' },
x = { '<cmd>lua vim.lsp.buf.code_action()<cr>', '' },
l = { '<cmd>FloatermNew lazygit<cr>', '' },
t = { '<cmd>FloatermNew<cr>', '' },
v = {
ve = { '<cmd>e $MYVIMRC<cr>', '' },
vr = { '<cmd>source $MYVIMRC<cr>', '' },
},
w = { '<cmd>set wrap! wrap?<cr>', '' },
}, { prefix = '<leader>' })
-- visual-mode mappings
wk.register({
[';'] = { ':', 'Colon with semicolon' },
v = { '<C-V>', 'remapping visual/visual-block mode', },
v = { '<C-V>', 'remapping visual/visual-block mode' },
-- with <CTRL> as modifier
['<C-V>'] = { 'v', 'remapping visual/visual-block mode' },
@ -94,13 +86,11 @@ wk.register({
['<M-l>'] = { '>gv', 'bubbling lines with alt-hjkl', noremap = false },
}, { mode = 'v' })
-- non-normal-mode mappings
wk.register({
['<C-j>'] = { 'vsnip#available(-1) ? "<Plug>(vsnip-jump-prev)" : "<C-j>"', 'snippet expansion' },
}, { mode = 's', expr = true, noremap = true })
-- add undo-repo-breakpoints automatically when writing long text
-- TODO only for prose (mail md etc)
-- map('i', ',', ',<c-g>u')
-- map('i', '.', '.<c-g>u')
-- map('i', '!', '!<c-g>u')
-- map('i', '?', '?<c-g>u')
}, {
mode = 's',
expr = true,
noremap = true
})
Loading…
Cancel
Save