mirror of
https://github.com/tiyn/dotfiles.git
synced 2025-10-10 19:41:15 +02:00
nvim: switched to init.lua
This commit is contained in:
6
.config/nvim/lua/colorscheme.lua
Normal file
6
.config/nvim/lua/colorscheme.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
-- colorscheme
|
||||
|
||||
-- basic color settings
|
||||
vim.o.background = 'dark'
|
||||
vim.cmd('colorscheme tccs')
|
||||
vim.api.nvim_set_hl(0, 'colorcolumn', {bg='#772222'})
|
138
.config/nvim/lua/filetype.lua
Normal file
138
.config/nvim/lua/filetype.lua
Normal file
@@ -0,0 +1,138 @@
|
||||
-- filetype
|
||||
|
||||
-- read files correctly
|
||||
vim.filetype.add({
|
||||
pattern = {
|
||||
['.*.lua'] = 'lua',
|
||||
['.*.h'] = 'c',
|
||||
['.*.html'] = 'html',
|
||||
['.*.nim'] = 'nim',
|
||||
['.*.py'] = 'python',
|
||||
['.*.tex'] = 'tex',
|
||||
}})
|
||||
|
||||
-- formatting options
|
||||
vim.api.nvim_create_autocmd({'FileType'},
|
||||
{pattern = {'markdown'},
|
||||
command = 'setlocal shiftwidth=2 softtabstop=2',
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({'FileType'},
|
||||
{pattern = {'java'},
|
||||
command = 'setlocal shiftwidth=2 softtabstop=2',
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({'FileType'},
|
||||
{pattern = {'javascript'},
|
||||
command = 'setlocal shiftwidth=2 softtabstop=2',
|
||||
})
|
||||
|
||||
-- formatting programs
|
||||
vim.api.nvim_create_autocmd({'FileType'},
|
||||
{pattern = {'c'},
|
||||
command = 'setlocal formatprg=astyle --mode=c --style=ansi',
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({'FileType'},
|
||||
{pattern = {'c'},
|
||||
command = 'noremap <F8> gggqG',
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({'FileType'},
|
||||
{pattern = {'html'},
|
||||
command = 'noremap <F8> :silent %!tidy -q -i --show-errors 0 <CR>',
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({'FileType'},
|
||||
{pattern = {'java'},
|
||||
command = 'setlocal formatprg=astyle --indent=spaces=2 --style=google',
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({'FileType'},
|
||||
{pattern = {'java'},
|
||||
command = 'noremap <F8> gggqG',
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({'FileType'},
|
||||
{pattern = {'markdown'},
|
||||
command = 'noremap <F8> :silent %!prettier --stdin-filepath % <CR>',
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({'FileType'},
|
||||
{pattern = {'nim'},
|
||||
command = 'noremap <F8> :silent !nimpretty %<CR>',
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({'FileType'},
|
||||
{pattern = {'nim'},
|
||||
command = 'noremap <F8> gggqG',
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({'FileType'},
|
||||
{pattern = {'python'},
|
||||
command = 'setlocal formatprg=autopep8 "%"',
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({'FileType'},
|
||||
{pattern = {'python'},
|
||||
command = 'noremap <F8> gggqG',
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({'FileType'},
|
||||
{pattern = {'tex', 'latex'},
|
||||
command = 'setlocal formatprg=latexindent',
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({'FileType'},
|
||||
{pattern = {'tex', 'latex'},
|
||||
command = 'noremap <F8> gggqG',
|
||||
})
|
||||
|
||||
-- cleanup certain files after leaving the editor
|
||||
vim.api.nvim_create_autocmd({'VimLeave'},
|
||||
{pattern = {'*.c'},
|
||||
command = '!cclear'
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({'VimLeave'},
|
||||
{pattern = {'*.tex'},
|
||||
command = '!texclear %'
|
||||
})
|
||||
|
||||
-- highlighting break line
|
||||
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
|
||||
{pattern = {'c'},
|
||||
command = 'set colorcolumn=80'
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
|
||||
{pattern = {'java'},
|
||||
command = 'set colorcolumn=100'
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
|
||||
{pattern = {'markdown'},
|
||||
command = 'set colorcolumn=80'
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
|
||||
{pattern = {'nim'},
|
||||
command = 'set colorcolumn=80'
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
|
||||
{pattern = {'python'},
|
||||
command = 'set colorcolumn=80'
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
|
||||
{pattern = {'tex'},
|
||||
command = 'set colorcolumn=80'
|
||||
})
|
||||
|
||||
-- conceallevel
|
||||
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
|
||||
{pattern = {'markdown'},
|
||||
command = 'set conceallevel=2'
|
||||
})
|
||||
|
79
.config/nvim/lua/keymap.lua
Normal file
79
.config/nvim/lua/keymap.lua
Normal file
@@ -0,0 +1,79 @@
|
||||
-- keymap
|
||||
|
||||
-- set mapleader for hotkeys
|
||||
vim.g.mapleader = ","
|
||||
|
||||
-- shortcut for split navigation
|
||||
vim.api.nvim_set_keymap('n', '<C-h>', '<C-w>h', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<C-j>', '<C-w>j', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<C-k>', '<C-w>k', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<C-l>', '<C-w>l', {noremap = true})
|
||||
|
||||
-- unmap unwanted commands
|
||||
vim.api.nvim_set_keymap('n', '<F1>', '<NOP>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<F4>', '<NOP>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<F9>', '<NOP>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<F10>', '<NOP>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<F11>', '<NOP>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<F12>', '<NOP>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('i', '<F2>', '<NOP>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('i', '<F3>', '<NOP>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('i', '<F4>', '<NOP>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('i', '<F5>', '<NOP>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('i', '<F6>', '<NOP>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('i', '<F7>', '<NOP>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('i', '<F8>', '<NOP>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('i', '<F9>', '<NOP>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('i', '<F10>', '<NOP>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('i', '<F11>', '<NOP>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('i', '<F12>', '<NOP>', {noremap = true})
|
||||
|
||||
-- mapping Dictionaries
|
||||
vim.api.nvim_set_keymap('n', '<F6>', ':setlocal spell! spelllang=de_de<CR>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<F7>', ':setlocal spell! spelllang=en_us<CR>', {noremap = true})
|
||||
|
||||
-- compiler for languages
|
||||
vim.api.nvim_set_keymap('n', '<leader>c', ':w! | !compiler <c-r>%<CR>', {noremap = true})
|
||||
|
||||
-- open corresponding file (pdf/html/...)
|
||||
vim.api.nvim_set_keymap('n', '<leader>p', ':!opout <c-r>%<CR><CR>', {noremap = true})
|
||||
|
||||
|
||||
-- save file as sudo on files that require root permission
|
||||
vim.api.nvim_set_keymap('c', 'w!!', '"silent! write !sudo tee % >/dev/null" <bar> edit!', {noremap = true})
|
||||
|
||||
|
||||
-- alias for replacing
|
||||
vim.api.nvim_set_keymap('n', '<leader>ss', ':%s//gI<Left><Left><Left>', {noremap = true})
|
||||
|
||||
-- irc compatibility for interactivity
|
||||
vim.api.nvim_set_keymap('n', '<leader>is', ':.w >> in<cr>dd', {noremap = true})
|
||||
|
||||
-- majutsushi/tagbar
|
||||
vim.api.nvim_set_keymap('n', '<F3>', ':TagbarToggle<CR>', {})
|
||||
|
||||
-- scrooloose/nerdtree
|
||||
vim.api.nvim_set_keymap('n', '<F2>', ':NERDTreeToggle<CR>', {})
|
||||
|
||||
-- tpope/vim-fugitive
|
||||
vim.api.nvim_set_keymap('n', '<leader>ga', ':Git add %:p<CR><CR>', { noremap = true })
|
||||
vim.api.nvim_set_keymap('n', '<leader>gd', ':Git diff<CR>', { noremap = true })
|
||||
vim.api.nvim_set_keymap('n', '<leader>gc', ':Git commit<CR>', { noremap = true })
|
||||
vim.api.nvim_set_keymap('n', '<leader>gh', ':diffget //3<CR>', { noremap = true })
|
||||
vim.api.nvim_set_keymap('n', '<leader>gr', ':Gread<CR>', { noremap = true })
|
||||
vim.api.nvim_set_keymap('n', '<leader>gu', ':diffget //2<CR>', { noremap = true })
|
||||
vim.api.nvim_set_keymap('n', '<leader>gs', ':G<CR>', { noremap = true })
|
||||
|
||||
-- hrsh7th/nvim-cmp
|
||||
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
|
||||
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', 'gy', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||
buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||
buf_set_keymap('n', '<F5>', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||
end
|
75
.config/nvim/lua/loadplugins.lua
Normal file
75
.config/nvim/lua/loadplugins.lua
Normal file
@@ -0,0 +1,75 @@
|
||||
-- loadplugins
|
||||
|
||||
-- load plugins with packer
|
||||
return require("packer").startup(function(use)
|
||||
-- automatic closing of brackets
|
||||
use 'raimondi/delimitmate'
|
||||
|
||||
-- improved java syntax highlighting
|
||||
use {'uiiaoo/java-syntax.vim',
|
||||
ft = {'java'}}
|
||||
|
||||
-- custom statusline
|
||||
use {'itchyny/lightline.vim',
|
||||
require = {"tiyn/vim-tccs"}}
|
||||
|
||||
-- latex asynchronous pdf rendering
|
||||
use {'donRaphaco/neotex',
|
||||
ft = {'tex'}}
|
||||
|
||||
-- navigating folders with a file tree
|
||||
use {'scrooloose/nerdtree',
|
||||
cmd = 'NERDTreeToggle',
|
||||
requires = 'ryanoasis/vim-devicons'}
|
||||
|
||||
-- nim language support
|
||||
use {'zah/nim.vim', ft = {'nim'}}
|
||||
|
||||
-- autocompletion and its sources
|
||||
use {'hrsh7th/nvim-cmp',
|
||||
requires = {'hrsh7th/cmp-buffer',
|
||||
'hrsh7th/cmp-path',
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
'l3mon4d3/luasnip',
|
||||
'saadparwaiz1/cmp_luasnip',
|
||||
'neovim/nvim-lspconfig',
|
||||
'onsails/lspkind-nvim'}}
|
||||
|
||||
-- showing color of hex values, etc
|
||||
use 'norcalli/nvim-colorizer.lua'
|
||||
|
||||
-- package manager
|
||||
use 'wbthomason/packer.nvim'
|
||||
|
||||
-- colorful brackets
|
||||
use 'luochen1990/rainbow'
|
||||
|
||||
-- show tags
|
||||
use {'majutsushi/tagbar',
|
||||
cmd = 'TagbarToggle'}
|
||||
|
||||
-- git wrapper
|
||||
use 'tpope/vim-fugitive'
|
||||
|
||||
-- indicate git diff status of line
|
||||
use 'airblade/vim-gitgutter'
|
||||
|
||||
-- golang language support
|
||||
use {'fatih/vim-go',
|
||||
ft = {'go'}}
|
||||
|
||||
-- markdown language support
|
||||
use {'preservim/vim-markdown',
|
||||
ft = {'md'},
|
||||
requires = {'godlygeek/tabular'}}
|
||||
|
||||
-- bulk renamer
|
||||
use 'qpkorr/vim-renamer'
|
||||
|
||||
-- additional quote/parantheses funtions
|
||||
use 'tpope/vim-surround'
|
||||
|
||||
-- colorscheme
|
||||
use 'tiyn/vim-tccs'
|
||||
|
||||
end)
|
Reference in New Issue
Block a user