From cc34940c06124fbfc5caebfee9d7d07ed70f2fa6 Mon Sep 17 00:00:00 2001 From: tastytea Date: Wed, 17 Aug 2022 01:47:49 +0200 Subject: [PATCH] nvim: autoformat everything, clean up, small fixes --- .config/nvim/lua/my/coding.lua | 9 +++++---- .config/nvim/lua/my/filetypes.lua | 27 +++++++++++++-------------- .config/nvim/lua/my/functions.lua | 3 +++ .config/nvim/lua/my/keymaps.lua | 1 + .config/nvim/lua/my/net.lua | 17 +++++++++-------- .config/nvim/lua/my/plugins.lua | 8 ++++++-- .config/nvim/lua/my/tools.lua | 4 ---- 7 files changed, 37 insertions(+), 32 deletions(-) diff --git a/.config/nvim/lua/my/coding.lua b/.config/nvim/lua/my/coding.lua index 5cd7655..a9e814f 100644 --- a/.config/nvim/lua/my/coding.lua +++ b/.config/nvim/lua/my/coding.lua @@ -1,5 +1,4 @@ require('my/plugins') -require('my/tools') local map = require('my.functions').map @@ -25,12 +24,14 @@ require('Comment').setup({ local location = nil if ctx.ctype == comment_utils.ctype.block then location = context_utils.get_cursor_location() - elseif ctx.cmotion == comment_utils.cmotion.v or ctx.cmotion == comment_utils.cmotion.V then + elseif ctx.cmotion == comment_utils.cmotion.v or + ctx.cmotion == comment_utils.cmotion.V then location = context_utils.get_visual_start_location() end return context_internal.calculate_commentstring { - key = ctx.ctype == comment_utils.ctype.line and "__default" or "__multiline", + key = ctx.ctype == comment_utils.ctype.line and "__default" or + "__multiline", location = location, } end @@ -73,7 +74,7 @@ require('gitsigns').setup({ on_attach = function(bufnr) local gs = package.loaded.gitsigns - map('n', 'gb', function() gs.blame_line({ full=true }) end, + map('n', 'gb', function() gs.blame_line({ full = true }) end, 'Show blame for current line', bufnr) end }) diff --git a/.config/nvim/lua/my/filetypes.lua b/.config/nvim/lua/my/filetypes.lua index 17a34cd..98300eb 100644 --- a/.config/nvim/lua/my/filetypes.lua +++ b/.config/nvim/lua/my/filetypes.lua @@ -1,6 +1,6 @@ require('my/plugins') -require'nvim-treesitter.configs'.setup { +require 'nvim-treesitter.configs'.setup { ensure_installed = 'all', highlight = { enable = true, @@ -8,23 +8,22 @@ require'nvim-treesitter.configs'.setup { }, context_commentstring = { enable = true, - enable_autocmd = false -- handled by Comment + enable_autocmd = false -- handled by Comment } } -require('orgmode').setup{} +require('orgmode').setup {} require('orgmode').setup_ts_grammar() vim.api.nvim_create_augroup('config_fileformats', { clear = true }) vim.api.nvim_create_autocmd( -{ 'BufEnter' }, -{ - group = 'config_fileformats', - pattern = { '*.org' }, - callback = function() - -- allow to hide stuff, like links - vim.opt_local.conceallevel = 2 - vim.opt_local.concealcursor = 'nc' - end -} -) + { 'BufEnter' }, + { + group = 'config_fileformats', + pattern = { '*.org' }, + callback = function() + -- allow to hide stuff, like links + vim.opt_local.conceallevel = 2 + vim.opt_local.concealcursor = 'nc' + end + }) diff --git a/.config/nvim/lua/my/functions.lua b/.config/nvim/lua/my/functions.lua index 6d2ea6d..57e6b53 100644 --- a/.config/nvim/lua/my/functions.lua +++ b/.config/nvim/lua/my/functions.lua @@ -12,6 +12,7 @@ function M.remove_trailing_whitespace() vim.cmd([[keeppatterns %s/\s\+$//e]]) vim.api.nvim_win_set_cursor(0, curpos) end + vim.api.nvim_create_augroup('config_functions', { clear = true }) vim.api.nvim_create_autocmd( { 'BufWritePre' }, @@ -63,6 +64,7 @@ function M.insert_modeline() print('modeline inserted') end end + vim.api.nvim_create_user_command('ModelineInsert', M.insert_modeline, {}) -- set colorcolumn to textwidth after buffer is displayed or option is changed @@ -73,6 +75,7 @@ function M.set_colorcolumn() vim.opt_local.colorcolumn = '' end end + vim.api.nvim_create_augroup('config_settings', { clear = true }) vim.api.nvim_create_autocmd( { 'BufEnter' }, diff --git a/.config/nvim/lua/my/keymaps.lua b/.config/nvim/lua/my/keymaps.lua index abcaf9a..45b1e32 100644 --- a/.config/nvim/lua/my/keymaps.lua +++ b/.config/nvim/lua/my/keymaps.lua @@ -1,3 +1,4 @@ +---@format disable local map = require('my.functions').map vim.g.mapleader = ' ' -- diff --git a/.config/nvim/lua/my/net.lua b/.config/nvim/lua/my/net.lua index f1390c3..f083f51 100644 --- a/.config/nvim/lua/my/net.lua +++ b/.config/nvim/lua/my/net.lua @@ -23,20 +23,21 @@ if vim.g.started_by_firenvim then vim.o.textwidth = 0 vim.o.colorcolumn = '0' + local FV_fileprefix = vim.env['XDG_RUNTIME_DIR'] .. '/firenvim/' vim.api.nvim_create_augroup('firenvim', { clear = true }) vim.api.nvim_create_autocmd( { 'BufEnter' }, { group = 'firenvim', pattern = { - 'schlomp.space_*', - 'codeberg.org_*', - 'gitlab.com_*', - 'github.com_*', - 'very.tastytea.de_*', - 'bookwyrm.social_*', - 'openlibrary.org_*', - 'bugs.gentoo.org_*', + FV_fileprefix .. 'schlomp\\.space_*', + FV_fileprefix .. 'codeberg\\.org_*', + FV_fileprefix .. 'gitlab\\.com_*', + FV_fileprefix .. 'github\\.com_*', + FV_fileprefix .. 'very\\.tastytea\\.de_*', + FV_fileprefix .. 'bookwyrm\\.social_*', + FV_fileprefix .. 'openlibrary\\.org_*', + FV_fileprefix .. 'bugs\\.gentoo\\.org_*', }, command = [[set filetype=markdown | set tw=0 cc=0]] }) diff --git a/.config/nvim/lua/my/plugins.lua b/.config/nvim/lua/my/plugins.lua index 7964d11..505e724 100644 --- a/.config/nvim/lua/my/plugins.lua +++ b/.config/nvim/lua/my/plugins.lua @@ -1,4 +1,5 @@ -local install_path = vim.fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim' +local install_path = vim.fn.stdpath('data') .. + '/site/pack/packer/start/packer.nvim' local packer_bootstrap if vim.fn.empty(vim.fn.glob(install_path)) > 0 then packer_bootstrap = vim.fn.system({ @@ -65,7 +66,10 @@ require('packer').startup(function(use) -- tools use { - 'https://github.com/folke/which-key.nvim' + 'https://github.com/folke/which-key.nvim', + config = function() + require('which-key').setup({}) + end } use { 'https://github.com/nvim-telescope/telescope.nvim', diff --git a/.config/nvim/lua/my/tools.lua b/.config/nvim/lua/my/tools.lua index 84bd0de..fe66eda 100644 --- a/.config/nvim/lua/my/tools.lua +++ b/.config/nvim/lua/my/tools.lua @@ -1,10 +1,6 @@ require('my/plugins') -require('my/filetypes') local map = require('my.functions').map - -require('which-key').setup{} - local telescope = require('telescope') local actions = require('telescope.actions') telescope.load_extension('media_files') -- FIXME: does not work