neovim

Personal neovim configuration files
git clone git://gtms.dev:neovim
Log | Files | Refs

commit d4dee5aaca00ea1f4cc1be0f9f615d044558f35f
parent d7f55f06c398d154e5b27bd0d56a89034e24ffd3
Author: Tomas Nemec <nemi@skaut.cz>
Date:   Sat, 17 Dec 2022 02:03:58 +0100

update

Diffstat:
Dafter/plugin/actions.lua | 67-------------------------------------------------------------------
Aafter/plugin/medoro.lua | 8++++++++
Aafter/plugin/pubspec.lua | 10++++++++++
Dcompiler/bash.vim | 21---------------------
Dcompiler/dart.vim | 18------------------
Acompiler/dart_ng_test.lua | 5+++++
Dcompiler/dart_ng_test.vim | 18------------------
Dcompiler/dcli.vim | 18------------------
Dcompiler/lua.lua | 11-----------
Dcompiler/zsh.vim | 21---------------------
Mftplugin/dart.lua | 21++++++++++++---------
Mftplugin/go.lua | 21+++++++++++----------
Mftplugin/lua.lua | 4+++-
Mftplugin/sh.lua | 7+++++--
Mftplugin/zsh.lua | 21++++++++++++++++-----
Mlua/plugins.lua | 3---
Mlua/tms/autocmd.lua | 1+
Alua/tms/compiler.lua | 8++++++++
Alua/tms/medoro.lua | 26++++++++++++++++++++++++++
Dlua/tms/ws/init.lua | 23-----------------------
Dlua/tms/ws/medoro.lua | 25-------------------------
Dplugin/ws.lua | 21---------------------
22 files changed, 105 insertions(+), 273 deletions(-)

diff --git a/after/plugin/actions.lua b/after/plugin/actions.lua @@ -1,67 +0,0 @@ -if not pcall(require, 'actions') then - return -end - -local utils = require 'actions.utils' - -local actions = {} -local mappings = { ['n <space>ar'] = 'run', ['n <space>at'] = 'test', ['n <space>ab'] = 'build' } - -local function make(_) - vim.cmd.make() -end - -local add = function(action) - table.insert(actions, action) -end - -local add_lang = function(lang, a) - add { predicate = utils.make_language_predicate(lang), actions = a } -end - -add_lang('dart', { - run = make, - build = function(_) -- analyze - require('tms.ft.dart.analyze').qf2103() - end, -}) - -add_lang('lua', { run = make }) - -add_lang('go', { - run = function(_) - vim.bo.makeprg = 'go run %' - vim.cmd.make() - vim.cmd.compiler('go') - end, - test = function(_) - vim.bo.makeprg = 'go test' - vim.cmd.make() - vim.cmd.compiler('go') - end, - build = make, -}) - -add_lang('zsh', { - run = function(_) - vim.bo.makeprg = [[./%]] - vim.bo.efm = [[%f:%.%#:%l:\ %m,%f:%l:\ %m,%-G%.%#]] - vim.cmd.make() - vim.cmd.compiler('zsh') - end, - build = make, -}) - -add_lang('gdscript', { - run = function(_) - vim.api.nvim_command('GodotRun') - end, - build = function(_) - vim.api.nvim_input(':GodotRun ') - end, -}) - -add_lang('sh', { run = make }) - -actions.mappings = mappings -require('actions'):setup(actions) diff --git a/after/plugin/medoro.lua b/after/plugin/medoro.lua @@ -0,0 +1,8 @@ +local group = vim.api.nvim_create_augroup('tms-medoro', {}) +vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, { + group = group, + pattern = '*/medoro/**', + callback = function() + vim.keymap.set('n', '<leader>al', require('tms.medoro').lang, { buffer = true }) + end, +}) diff --git a/after/plugin/pubspec.lua b/after/plugin/pubspec.lua @@ -0,0 +1,10 @@ +local group = vim.api.nvim_create_augroup('tms-dart-pubspec', {}) +vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, { + group = group, + callback = function() + if #vim.fs.find('pubspec.yaml', { upward = true, type = 'file' }) == 0 then + return + end + vim.keymap.set('n', '<leader>an', require('tms.ft.dart.analyze').qf2131, { buffer = true, desc = 'Dart Analyze' }) + end, +}) diff --git a/compiler/bash.vim b/compiler/bash.vim @@ -1,21 +0,0 @@ -" Vim compiler file -" Compiler: Bash -" Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2020 Sep 6 - -if exists("current_compiler") - finish -endif -let current_compiler = "bash" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - -let s:cpo_save = &cpo -set cpo&vim - -CompilerSet makeprg=sh\ %:S -CompilerSet errorformat=%f:\ line\ %l:\ %m - -let &cpo = s:cpo_save -unlet s:cpo_save diff --git a/compiler/dart.vim b/compiler/dart.vim @@ -1,18 +0,0 @@ -" Vim compiler file -" Compiler: Dart test -" Maintainer: Tomas Nemec <nemi@skaut.cz> -" Last Change: May 17 2021 - -if exists("current_compiler") - finish -endif -let current_compiler = "dart" - -let s:cpo_save = &cpo -set cpo&vim - -set makeprg=dart\ % -set errorformat=%f:%l:%c:\ %m - -let &cpo = s:cpo_save -unlet s:cpo_save diff --git a/compiler/dart_ng_test.lua b/compiler/dart_ng_test.lua @@ -0,0 +1,5 @@ +vim.v.current_compiler = 'dart_ng_test' +local set = require('tms.compiler').set + +set('makeprg', [[pub run build_runner test -- --no-color %]]) +set('efm', [[%E%.%#\] %m \[E\]%.%#,%Z%.%#\.dart %l:%c %.%#,%C%.%#]]) diff --git a/compiler/dart_ng_test.vim b/compiler/dart_ng_test.vim @@ -1,18 +0,0 @@ -" Vim compiler file -" Compiler: Dart test -" Maintainer: Tomas Nemec <nemi@skaut.cz] -" Last Change: Mon May 17 10:34:27 AM CEST 2021 - -if exists("current_compiler") - finish -endif -let current_compiler = "dart_ng_test" - -let s:cpo_save = &cpo -set cpo&vim - -set makeprg=pub\ run\ build_runner\ test\ --\ --no-color\ % -set errorformat=%E%.%#\]\ %m\ \[E\]%.%#,%Z%.%#\.dart\ %l:%c\ %.%#,%C%.%# - -let &cpo = s:cpo_save -unlet s:cpo_save diff --git a/compiler/dcli.vim b/compiler/dcli.vim @@ -1,18 +0,0 @@ -" Vim compiler file -" Compiler: Dart test -" Maintainer: Tomas Nemec <nemi@skaut.cz> -" Last Change: May 17 2021 - -if exists("current_compiler") - finish -endif -let current_compiler = "dcli" - -let s:cpo_save = &cpo -set cpo&vim - -set makeprg=dcli\ run\ % -set errorformat=%f:%l:%c:\ %m - -let &cpo = s:cpo_save -unlet s:cpo_save diff --git a/compiler/lua.lua b/compiler/lua.lua @@ -1,11 +0,0 @@ --- Vim compiler file --- Compiler: Lua --- Maintainer: Tomas Nemec <owl@gtms.dev> --- Last Change: 18.10.2022 -if vim.fn.exists('current_compiler') then - return -end -vim.g.current_compiler = 'lua' - -vim.bo.makeprg = 'lua %:S' -vim.bo.errorformat = 'lua: %f:%l: %m' diff --git a/compiler/zsh.vim b/compiler/zsh.vim @@ -1,21 +0,0 @@ -" Vim compiler file -" Compiler: Zsh -" Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2020 Sep 6 - -if exists("current_compiler") - finish -endif -let current_compiler = "zsh" -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal <args> -endif - -let s:cpo_save = &cpo -set cpo&vim - -CompilerSet makeprg=zsh\ -n\ --\ %:S -CompilerSet errorformat=%f:%l:\ %m,%f:\ line\ %l:\ %m,\ %-G%.%# - -let &cpo = s:cpo_save -unlet s:cpo_save diff --git a/ftplugin/dart.lua b/ftplugin/dart.lua @@ -5,19 +5,24 @@ vim.opt_local.isfname:append{ ':' } vim.opt_local.iskeyword:append{ '$' } vim.b.undo_ftplugin = 'setl com< cms< inex< isf<' +local first_line = vim.filetype.getlines(0, 1) +if string.match(first_line, '^#!.*dcli') then + vim.bo.makeprg = [[dcli run %]] + vim.bo.efm = [[%f:%l:%c: %m]] +else + vim.bo.makeprg = [[dart %]] + vim.bo.efm = [[%f:%l:%c: %m]] +end + local full_path = vim.fn.expand('%:p') if string.find(full_path, '%.pub%-cache') then vim.bo.modifiable = false end -if vim.fn.getline(1):match('^#!.*dcli') then - vim.cmd.compiler('dcli') -else - vim.cmd.compiler('dart') -end - vim.lsp.start(require'tms.lsp'.make_opts('dartls')) +vim.keymap.set('n', '<leader>ar', vim.cmd.make) + if pcall(require, 'dart-tools') then local dt_lsp = require('dart-tools.lsp') local dt_req = require('dart-tools.lsp.request') @@ -38,9 +43,7 @@ if pcall(require, 'dart-tools') then ddebug.print() end, opts('Dart Debug Print')) vim.keymap.set('n', '<leader>ao', dt_lsp.organize_imports, opts('Dart Organize Imports')) - vim.keymap.set('n', '<leader>af', function() - dt_lsp.fix_all() - end, opts('Dart Fix All')) + vim.keymap.set('n', '<leader>af', dt_lsp.fix_all, opts('Dart Fix All')) vim.keymap.set({ 'v', 'n' }, '<leader>ai', dt_lsp.inline_local_variable, opts('Dart Inline Local Varibale')) vim.keymap.set({ 'v', 'n' }, '<leader>ae', dt_lsp.extract_local_variable, opts('Dart Extract Local Varibale')) vim.keymap.set({ 'v', 'n' }, '<leader>am', dt_lsp.extract_method, opts('Dart Extract Method')) diff --git a/ftplugin/go.lua b/ftplugin/go.lua @@ -1,11 +1,12 @@ -vim.cmd.compiler('go') +vim.bo.makeprg = [[go run %]] -- vim.cmd [[command! -buffer -nargs=? Godoc lua require('tms.ft.go.doc').godoc(vim.fn.expand('<args>'), vim.fn.expand('<cword>'))]] - -vim.api.nvim_create_autocmd('BufWritePre', { - callback = function() require('tms.ft.go').org_imports() end, - buffer = 0, - desc = 'GO Organize Imports', -}) - -vim.keymap.set('n', '<leader>po', function() require('tms.ft.go').org_imports() end, - { buffer = true, desc = 'Go Organize Imports' }) +vim.api.nvim_create_autocmd('BufWritePre', + { callback = require('tms.ft.go').org_imports, buffer = 0, desc = 'GO Organize Imports' }) +vim.keymap.set('n', '<leader>ao', require('tms.ft.go').org_imports, { buffer = true, desc = 'Go Organize Imports' }) +vim.keympa.set('n', '<leader>ar', vim.cmd.make, { buffer = true }) +vim.keympa.set('n', '<leader>at', function() + local tmp = vim.bo.makeprg + vim.bo.makeprg = 'go test' + vim.cmd.make() + vim.bo.makeprg = tmp +end, { buffer = true }) diff --git a/ftplugin/lua.lua b/ftplugin/lua.lua @@ -1,3 +1,5 @@ -vim.cmd.compiler('lua') +vim.bo.efm = [[lua: %f:%l: %m]] +vim.bo.makeprg = [[lua %:S]] vim.treesitter.start() +vim.keymap.set('n', '<leader>ar', vim.cmd.make) diff --git a/ftplugin/sh.lua b/ftplugin/sh.lua @@ -1,4 +1,7 @@ -vim.cmd.compiler('bash') +vim.bo.makeprg = [[sh %:S]] +vim.bo.efm = [[%f: line %l: %m]] local cmp = require('cmp') -cmp.setup.buffer {sources = {{name = 'nvim_lsp'}, {name = 'exe'}, {name = 'path'}}} +cmp.setup.buffer { sources = { { name = 'nvim_lsp' }, { name = 'exe' }, { name = 'path' } } } + +vim.keymap.set('n', '<leader>ar', vim.cmd.make, { buffer = true }) diff --git a/ftplugin/zsh.lua b/ftplugin/zsh.lua @@ -1,12 +1,23 @@ -vim.cmd.compiler('zsh') +vim.bo.makeprg = [[zsh -n -- %:S]] +vim.bo.efm = [[%f:%l: %m,%f: line %l: %m, %-G%.%#]] require('cmp').setup.buffer { -- - completion = {autocomplete = false}, + completion = { autocomplete = false }, sources = { -- - {name = 'nvim_lsp'}, - {name = 'exe'}, - {name = 'path'}, + { name = 'nvim_lsp' }, + { name = 'exe' }, + { name = 'path' }, }, } + +vim.keymap.set('n', '<leader>ar', function() + local tms_prg = vim.bo.makeprg + local tms_efm = vim.bo.efm + vim.bo.makeprg = [[./%]] + vim.bo.efm = [[%f:%.%#:%l:\ %m,%f:%l:\ %m,%-G%.%#]] + vim.cmd.make() + vim.bo.makeprg = tms_prg + vim.bo.efm = tms_efm +end, { buffer = true }) diff --git a/lua/plugins.lua b/lua/plugins.lua @@ -77,9 +77,6 @@ return packer.startup({ -- http use { 'NTBBloodbath/rest.nvim', requires = { 'nvim-lua/plenary.nvim' } } - -- tasks - use 'amirrezaask/actions.nvim' - -- filetype use 'tikhomirov/vim-glsl' use 'windwp/nvim-ts-autotag' diff --git a/lua/tms/autocmd.lua b/lua/tms/autocmd.lua @@ -4,6 +4,7 @@ vim.api.nvim_create_autocmd('TextYankPost', { require('vim.highlight').on_yank() end, }) + vim.api.nvim_create_autocmd('BufEnter', { pattern = '*', callback = function(opt) diff --git a/lua/tms/compiler.lua b/lua/tms/compiler.lua @@ -0,0 +1,8 @@ +local M = {} + +function M.set(option, arg) + arg = vim.fn.escape(arg, ' ') + vim.api.nvim_cmd({ cmd = 'CompilerSet', args = { option .. '=' .. arg } }, {}) +end + +return M diff --git a/lua/tms/medoro.lua b/lua/tms/medoro.lua @@ -0,0 +1,26 @@ +local M = {} + +M.lang = function() + -- TODO(tms) 17.12.22: little to specific not? + local cwd = '/home/tms/dev/medoro/dpgw/dpgw/src/main/resources/org/medoro/dpgw/core/lang/' + local files = { 'lang.properties', 'lang_cs.properties' } + require('telescope.builtin').live_grep({ + cwd = cwd, + search_dirs = files, + disable_coordinates = true, + attach_mappings = function(prompt_bufnr) + local actions = require('telescope.actions') + actions.select_default:replace(function(_, _) + local entry = require('telescope.actions.state').get_selected_entry() + local lang = entry.text:match('(%S+)=.*') + print(entry.text, lang) + actions.close(prompt_bufnr) + vim.fn.setreg('+', lang) + vim.fn.setreg('*', lang) + end) + return true + end, + }) +end + +return M diff --git a/lua/tms/ws/init.lua b/lua/tms/ws/init.lua @@ -1,23 +0,0 @@ -local M = {} - -M.medoro = { - path = '*/medoro/**', - config = function() - vim.keymap.set('n', '<leader>al', '<cmd>lua require("tms.ws.medoro").lang()<cr>', { buffer = true }) - end, -} - -M.dart = { - root_pattern = 'pubspec.yaml', - config = function() - local analyze = require('tms.ft.dart.analyze') - local opts = function(desc) - return { buffer = true, desc = desc } - end - vim.keymap.set('n', '<leader>an', function() - analyze.qf2131() - end, opts('Dart Analyze')) - end, -} - -return M diff --git a/lua/tms/ws/medoro.lua b/lua/tms/ws/medoro.lua @@ -1,25 +0,0 @@ -local M = {} - -M.lang = function() - local cwd = '/home/tms/dev/medoro/dpgw/dpgw/src/main/resources/org/medoro/dpgw/core/lang/' - local files = { 'lang.properties', 'lang_cs.properties' } - require('telescope.builtin').live_grep({ - cwd = cwd, - search_dirs = files, - disable_coordinates = true, - attach_mappings = function(prompt_bufnr) - local actions = require('telescope.actions') - actions.select_default:replace(function(_, _) - local entry = require('telescope.actions.state').get_selected_entry() - local lang = entry.text:match('(%S+)=.*') - print(entry.text, lang) - actions.close(prompt_bufnr) - vim.fn.setreg('+', lang) - vim.fn.setreg('*', lang) - end) - return true - end, - }) -end - -return M diff --git a/plugin/ws.lua b/plugin/ws.lua @@ -1,21 +0,0 @@ -local ws = require('tms.ws') - -for name, setup in pairs(ws) do - if setup.path then - local group = vim.api.nvim_create_augroup('user-project-' .. name, {}) - vim.api.nvim_create_autocmd('BufEnter', { group = group, pattern = setup.path, callback = setup.config }) - end - if setup.root_pattern then - local group = vim.api.nvim_create_augroup('user-project-' .. name, {}) - vim.api.nvim_create_autocmd('BufEnter', { - group = group, - callback = function() - if not pcall(require, 'lspconfig') then return end - if require('lspconfig.util').root_pattern(setup.root_pattern)(vim.fn.getcwd()) then - setup.config() - end - end, - }) - end - -- if setup.buffer then au.addListener('user-project-buffer-' .. name, {'BufEnter ' .. setup.buffer}, setup.config) end -end