1
0
mirror of https://github.com/tiyn/dotfiles.git synced 2025-04-19 16:27:45 +02:00

Compare commits

...

2 Commits

Author SHA1 Message Date
933819855f nvim: set color columns and moved filetypes into autocmd 2023-07-28 00:00:30 +02:00
7d0168ff4e nvim: added todo-comments.nvim 2023-07-27 20:45:49 +02:00
5 changed files with 131 additions and 47 deletions

View File

@ -56,14 +56,11 @@ vim.g.python_host_prog = '/usr/bin/python2'
vim.g.python3_host_prog = '/usr/bin/python3' vim.g.python3_host_prog = '/usr/bin/python3'
-- set filetypes correctly by extension -- set filetypes correctly by extension
require('filetype') require('autocmd')
-- load plugins (autoload all files in plugin folder) -- load plugins (autoload all files in plugin folder)
require('loadplugins') require('loadplugins')
-- load filetype specific mappings and commands
require('autocmd')
-- load general mapped keys -- load general mapped keys
require('keymap') require('keymap')

View File

@ -1,4 +1,17 @@
-- autocmd -- read files correctly
vim.filetype.add({
extension = {
c = 'c',
h = 'c',
html = 'html',
java = 'java',
js = 'javascript',
lua = 'lua',
md = 'markdown',
nim = 'nim',
py = 'python',
tex = 'tex',
}})
-- delete trailing whitespaces on save -- delete trailing whitespaces on save
vim.api.nvim_create_autocmd({'BufWritePre'}, vim.api.nvim_create_autocmd({'BufWritePre'},
@ -6,67 +19,88 @@ vim.api.nvim_create_autocmd({'BufWritePre'},
command = [[%s/\s\+$//e]], command = [[%s/\s\+$//e]],
}) })
-- formatting options -- c
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',
})
-- cleanup certain files after leaving the editor
vim.api.nvim_create_autocmd({'VimLeave'}, vim.api.nvim_create_autocmd({'VimLeave'},
{pattern = {'c'}, {pattern = {'c'},
command = '!cclear' command = '!cclear'
}) })
vim.api.nvim_create_autocmd({'VimLeave'},
{pattern = {'tex'},
command = '!texclear %'
})
-- highlighting break line
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'}, vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
{pattern = {'c'}, {pattern = {'c'},
command = 'set colorcolumn=80' command = 'set colorcolumn=80'
}) })
-- java
vim.api.nvim_create_autocmd({'FileType'},
{pattern = {'java'},
command = 'setlocal shiftwidth=2 softtabstop=2',
})
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'}, vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
{pattern = {'java'}, {pattern = {'java'},
command = 'set colorcolumn=100' command = 'set colorcolumn=100'
}) })
-- javascript
vim.api.nvim_create_autocmd({'FileType'},
{pattern = {'javascript'},
command = 'setlocal shiftwidth=2 softtabstop=2',
})
-- lua
vim.api.nvim_create_autocmd({'FileType'},
{pattern = {'lua'},
command = 'setlocal shiftwidth=2 softtabstop=2',
})
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
{pattern = {'lua'},
command = 'set colorcolumn=100'
})
-- markdown
vim.api.nvim_create_autocmd({'FileType'},
{pattern = {'markdown'},
command = 'setlocal shiftwidth=2 softtabstop=2',
})
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'}, vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
{pattern = {'markdown'}, {pattern = {'markdown'},
command = 'set colorcolumn=80' command = 'set colorcolumn=100'
}) })
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
{pattern = {'markdown'},
command = 'set conceallevel=2'
})
-- nim
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'}, vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
{pattern = {'nim'}, {pattern = {'nim'},
command = 'set colorcolumn=80' command = 'set colorcolumn=80'
}) })
-- python
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'}, vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
{pattern = {'python'}, {pattern = {'python'},
command = 'set colorcolumn=80' command = 'set colorcolumn=80'
}) })
-- tex
vim.api.nvim_create_autocmd({'VimLeave'},
{pattern = {'tex'},
command = '!texclear %'
})
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'}, vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
{pattern = {'tex'}, {pattern = {'tex'},
command = 'set colorcolumn=80' command = 'set colorcolumn=80'
}) })
-- conceallevel
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
{pattern = {'markdown'},
command = 'set conceallevel=2'
})

View File

@ -1,12 +0,0 @@
-- read files correctly
vim.filetype.add({
extension = {
h = 'c',
html = 'html',
java = 'java',
js = 'javascript',
md = 'markdown',
nim = 'nim',
py = 'python',
tex = 'tex',
}})

View File

@ -76,6 +76,10 @@ return require("packer").startup(function(use)
use {'majutsushi/tagbar', use {'majutsushi/tagbar',
cmd = 'TagbarToggle'} cmd = 'TagbarToggle'}
-- todo symbols and highlighting
use {'folke/todo-comments.nvim',
requires = {'nvim-lua/plenary.nvim'}}
-- git wrapper -- git wrapper
use {'tpope/vim-fugitive'} use {'tpope/vim-fugitive'}

View File

@ -0,0 +1,61 @@
-- folke/todo-comments.nvim
require 'todo-comments'.setup {
signs = true, -- show icons in the signs column
sign_priority = 8, -- sign priority
-- keywords recognized as todo comments
keywords = {
ERRO = { icon = "", color = "error"},
TODO = { icon = "", color = "info" },
HACK = { icon = "", color = "warning"},
WARN = { icon = "", color = "warning"},
PERF = { icon = "", color = "default"},
NOTE = { icon = "", color = "hint"},
TEST = { icon = "", color = "test"},
},
gui_style = {
fg = "NONE", -- The gui style to use for the fg highlight group.
bg = "BOLD", -- The gui style to use for the bg highlight group.
},
merge_keywords = true, -- when true, custom keywords will be merged with the defaults
-- highlighting of the line containing the todo comment
-- * before: highlights before the keyword (typically comment characters)
-- * keyword: highlights of the keyword
-- * after: highlights after the keyword (todo text)
highlight = {
multiline = true, -- enable multine todo comments
multiline_pattern = "^.", -- lua pattern to match the next multiline from the start of the matched keyword
multiline_context = 10, -- extra lines that will be re-evaluated when changing a line
before = "", -- "fg" or "bg" or empty
keyword = "wide", -- "fg", "bg", "wide", "wide_bg", "wide_fg" or empty. (wide and wide_bg is the same as bg, but will also highlight surrounding characters, wide_fg acts accordingly but with fg)
after = "fg", -- "fg" or "bg" or empty
pattern = [[.*<(KEYWORDS)\s*:]], -- pattern or table of patterns, used for highlighting (vim regex)
comments_only = true, -- uses treesitter to match keywords in comments only
max_line_len = 400, -- ignore lines longer than this
exclude = {}, -- list of file types to exclude highlighting
},
-- list of named colors where we try to extract the guifg from the
-- list of highlight groups or use the hex color if hl not found as a fallback
colors = {
error = { "DiagnosticError", "ErrorMsg", "#DC2626" },
warning = { "WarningMsg", "DiagnosticWarn", "#FBBF24" },
info = { "Constant", "#2563EB" },
hint = { "Comment", "#10B981" },
default = { "Operator", "#7C3AED" },
test = { "Function", "#FF00FF" }
},
search = {
command = "rg",
args = {
"--color=never",
"--no-heading",
"--with-filename",
"--line-number",
"--column",
},
-- regex that will be used to match keywords.
-- don't replace the (KEYWORDS) placeholder
pattern = [[\b(KEYWORDS):]], -- ripgrep regex
-- pattern = [[\b(KEYWORDS)\b]], -- match without the extra colon. You'll likely get false positives
},
}