commit 58ea0d7bd69dbad1527d0bb17e813bb2c7c0e3d1
parent d74886584b75580469d4c4bed3d6eb8d7eda297e
Author: Tomas Nemec <nemi@skaut.cz>
Date: Mon, 18 Oct 2021 23:36:16 +0200
update
Diffstat:
18 files changed, 261 insertions(+), 442 deletions(-)
diff --git a/after/queries/bash/textobjects.scm b/after/queries/bash/textobjects.scm
@@ -0,0 +1 @@
+[(variable_name) (word)] @identifier
diff --git a/after/queries/lua/textobjects.scm b/after/queries/lua/textobjects.scm
@@ -0,0 +1 @@
+(identifier) @identifier
diff --git a/ftplugin/gdscript.lua b/ftplugin/gdscript.lua
@@ -1 +1 @@
-require('tms.p.compe').setup(nil, {autocomplete = true})
+-- require('tms.p.compe').setup(nil, {autocomplete = true})
diff --git a/ftplugin/mail.lua b/ftplugin/mail.lua
@@ -1,4 +1,2 @@
-vim.opt.spelllang = 'cs,csa,en'
vim.opt.spell = true
-
-require('tms.p.compe').setup({spell = true})
+vim.opt.spelllang = {'cs', 'csa', 'en'}
diff --git a/init.lua b/init.lua
@@ -20,7 +20,7 @@ vim.opt.exrc = true
vim.opt.secure = true
-- utilsions
vim.opt.clipboard = 'unnamedplus'
-vim.opt.completeopt = 'menuone,noselect'
+vim.opt.completeopt = 'menu,menuone,noselect'
vim.opt.equalalways = false
vim.opt.grepprg = 'rg --vimgrep --no-heading --smart-case'
vim.opt.grepformat = '%f:%l:%c:%m'
diff --git a/lua/tms/c/keybind.lua b/lua/tms/c/keybind.lua
@@ -4,9 +4,9 @@ local kbb = api.nvim_buf_set_keymap
local globalListenerName = 'TMS_KEYBIND' -- change this to be unique across multiple plugin name
local kbhandlers = {}
-local id = 0
-_G[globalListenerName] = function(id) kbhandlers[id]() end
+_G[globalListenerName] = function(i) kbhandlers[i]() end
+local id = 0
local function createCmd(fn)
id = id + 1
kbhandlers[id] = fn
@@ -14,17 +14,13 @@ local function createCmd(fn)
end
local function expand_rhs(rhs)
- if type(rhs) == 'function' then
- return createCmd(rhs)
- end
+ if type(rhs) == 'function' then return createCmd(rhs) end
return rhs
end
local function add(mode, lhs, rhs, opt)
if type(lhs) == 'table' then
- for _, v in ipairs(lhs) do
- kb(mode, v, expand_rhs(rhs), opt)
- end
+ for _, v in ipairs(lhs) do kb(mode, v, expand_rhs(rhs), opt) end
else
kb(mode, lhs, expand_rhs(rhs), opt)
end
@@ -32,9 +28,7 @@ end
local function badd(bufnr, mode, lhs, rhs, opt)
if type(lhs) == 'table' then
- for _, v in ipairs(lhs) do
- kbb(bufnr, mode, v, expand_rhs(rhs), opt)
- end
+ for _, v in ipairs(lhs) do kbb(bufnr, mode, v, expand_rhs(rhs), opt) end
else
kbb(bufnr, mode, lhs, expand_rhs(rhs), opt)
end
diff --git a/lua/tms/lsp/efm.lua b/lua/tms/lsp/efm.lua
@@ -4,33 +4,11 @@ M.settings = {
languages = {
lua = {{formatCommand = 'lua-format -i', formatStdin = true}},
clang = {{formatCommand = 'clang-format --style=file', formatStdin = true}},
- css = {
- {
- formatCommand = 'prettier --config ~/.config/prettier/config.yaml --parser css',
- formatStdin = true,
- },
- },
- scss = {
- {
- formatCommand = 'prettier --config ~/.config/prettier/config.yaml --parser scss',
- formatStdin = true,
- },
- },
- html = {
- {formatCommand = 'html-beautify -f - -A aligned-multiple -s 2 -w 120', formatStdin = true},
- },
- json = {
- {
- formatCommand = 'prettier --config ~/.config/prettier/config.yaml --parser json',
- formatStdin = true,
- },
- },
- yaml = {
- {
- formatCommand = 'prettier --config ~/.config/prettier/config.yaml --parser yaml',
- formatStdin = true,
- },
- },
+ css = {{formatCommand = 'prettier --config ~/.config/prettier/config.yaml --parser css', formatStdin = true}},
+ scss = {{formatCommand = 'prettier --config ~/.config/prettier/config.yaml --parser scss', formatStdin = true}},
+ html = {{formatCommand = 'prettier --config ~/.config/prettier/config.yaml --parser html', formatStdin = true}},
+ json = {{formatCommand = 'prettier --config ~/.config/prettier/config.yaml --parser json', formatStdin = true}},
+ yaml = {{formatCommand = 'prettier --config ~/.config/prettier/config.yaml --parser yaml', formatStdin = true}},
-- javascript = {
-- {
-- formatCommand = 'prettier --config ~/.config/prettier/config.yaml --parser typescript',
@@ -43,28 +21,16 @@ M.settings = {
-- List all filetypes efm handles
M.filetypes = function()
local fts = {}
- for ft, _ in pairs(M.settings.languages) do
- table.insert(fts, ft)
- end
+ for ft, _ in pairs(M.settings.languages) do table.insert(fts, ft) end
return fts
end
-- Check if filetype is handled by efm
M.handle_filetype = function(filetype)
if type(filetype) == 'string' then
- for _, ft in ipairs(M.filetypes()) do
- if ft == filetype then
- return true
- end
- end
+ for _, ft in ipairs(M.filetypes()) do if ft == filetype then return true end end
elseif type(filetype) == 'table' then
- for _, ft in ipairs(M.filetypes()) do
- for _, fft in ipairs(filetype) do
- if ft == fft then
- return true
- end
- end
- end
+ for _, ft in ipairs(M.filetypes()) do for _, fft in ipairs(filetype) do if ft == fft then return true end end end
end
end
diff --git a/lua/tms/lsp/init.lua b/lua/tms/lsp/init.lua
@@ -1,10 +1,11 @@
local kb = require('tms.c.keybind')
local efm = require('tms.lsp.efm')
local handlers = require('tms.lsp.handlers')
+local servers = require('tms.lsp.servers')
local M = {}
-local function keybind(bufnr)
+local keybind = function(bufnr)
local o = {silent = true}
local oe = {silent = true, expr = true}
local t = '<cmd>lua require("tms.p.telescope")'
@@ -34,8 +35,7 @@ local function keybind(bufnr)
kb.bnnoremap(bufnr, 'gww', t .. '.b.lsp_workspace_symbols()<cr>', o)
kb.bnnoremap(bufnr, 'gwa', l .. '.buf.add_workspace_folder()<cr>', o)
kb.bnnoremap(bufnr, 'gwr', l .. '.buf.remove_workspace_folder()<cr>', o)
- kb.bnnoremap(bufnr, 'gwl',
- '<cmd>lua dump(vim.lsp.buf.list_workspace_folders())<cr>', o)
+ kb.bnnoremap(bufnr, 'gwl', '<cmd>lua dump(vim.lsp.buf.list_workspace_folders())<cr>', o)
-- diagnostic
kb.bnnoremap(bufnr, 'gs', l .. '.diagnostic.show_line_diagnostics()<cr>', o)
kb.bnnoremap(bufnr, 'gll', '<cmd>lua vim.lsp.diagnostic.set_loclist()<cr>', o)
@@ -45,122 +45,40 @@ local function keybind(bufnr)
kb.bnnoremap(bufnr, {'<d', '<('}, l .. '.diagnostic.goto_prev()<cr>', o)
end
-local function custom_attach(client, bufnr)
+local custom_attach = function(client, bufnr)
if client.name ~= 'efm' and efm.handle_filetype(client.config.filetypes) then
client.resolved_capabilities.document_formatting = false
end
- -- override
local lsp = vim.lsp
- -- lsp.handlers['textDocument/rename'] = handlers.rename
lsp.handlers['textDocument/hover'] = handlers.hover
lsp.handlers['textDocument/signatureHelp'] = handlers.signatureHelp
lsp.handlers['textDocument/publishDiagnostics'] = handlers.publishDiagnostics
+ -- lsp.handlers['textDocument/rename'] = handlers.rename
keybind(bufnr)
end
-function M.setup()
+M.setup = function()
local lspc = require('lspconfig')
-
- lspc.efm.setup {
- on_attach = custom_attach,
- init_options = {documentFormatting = true},
- settings = efm.settings,
- root_dir = lspc.util.root_pattern('.git', vim.fn.getcwd()),
- filetypes = efm.filetypes(),
- }
-
- lspc.dartls.setup {
- on_attach = custom_attach,
- cmd = require'tms.ft.dart.bin'.lspcmd(),
- init_options = {closingLabels = true, outline = true},
- settings = {
- dart = {lineLength = 120, showTodos = true, completeFunctionCalls = true},
- },
- handlers = {
- ['dart/textDocument/publishClosingLabels'] = require(
- 'tms.ft.dart.closing_labels').get_callback {},
- },
- root_dir = lspc.util.root_pattern('pubspec.yaml', '.git', vim.fn.getcwd()),
- }
-
- local luadev = require('lua-dev').setup({
- lspconfig = {
- cmd = {
- '/home/tms/.cache/nvim/lspconfig/sumneko_lua/lua-language-server/bin/Linux/lua-language-server',
- '-E',
- '/home/tms/.cache/nvim/lspconfig/sumneko_lua/lua-language-server/main.lua',
- },
-
- settings = {
- Lua = {
- runtime = {version = 'LuaJIT', path = vim.split(package.path, ';')},
- diagnostics = {
- globals = {
- 'vim',
- 'vimp',
- 'Color',
- 'c',
- 'Group',
- 'g',
- 's',
- 'use',
- 'mutt',
- },
- },
- },
- },
- },
- })
- lspc.sumneko_lua.setup(luadev)
- -- {
- -- on_attach = custom_attach,
- -- cmd = {
- -- "/home/tms/.cache/nvim/lspconfig/sumneko_lua/lua-language-server/bin/Linux/lua-language-server",
- -- "-E",
- -- "/home/tms/.cache/nvim/lspconfig/sumneko_lua/lua-language-server/main.lua",
- -- },
- -- settings = {
-
- -- Lua = {
- -- runtime = {version = "LuaJIT", path = vim.split(package.path, ";")},
- -- diagnostics = {globals = {"vim", "vimp", "Color", "c", "Group", "g", "s", "use", "mutt"}},
- -- workspace = {
- -- -- Make the server aware of Neovim runtime files
- -- library = {[vim.fn.expand('$VIMRUNTIME/lua')] = true, [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true},
- -- },
- -- },
- -- },
- -- }
- -- php
- lspc.intelephense.setup {
- on_attach = custom_attach,
- init_options = {
- clearCache = true,
- licenceKey = os.getenv('XDG_CONFIG_HOME') ..
- '/intelephense/licenceKey.txt',
- globalStoragePath = os.getenv('XDG_CONFIG_HOME') .. '/intelephense',
- },
- }
-
- -- other
- lspc.gdscript.setup {on_attach = custom_attach}
- lspc.cssls.setup {on_attach = custom_attach}
- lspc.clangd.setup {on_attach = custom_attach}
- lspc.vimls.setup {on_attach = custom_attach}
- lspc.bashls.setup {on_attach = custom_attach}
- lspc.jsonls.setup {on_attach = custom_attach}
- lspc.gopls.setup {
- on_attach = custom_attach,
- root_dir = lspc.util.root_pattern('go.mod', '.git', vim.fn.getcwd()),
- }
- lspc.jdtls.setup {cmd = {'jdtls'}, on_attach = custom_attach}
- -- lspc.pyls.setup {on_attach = custom_attach}
- lspc.tsserver.setup {on_attach = custom_attach}
- lspc.html.setup {
- cmd = {'html-languageserver', '--stdio'},
- on_attach = custom_attach,
- filetypes = {'html', 'latte'},
- }
+ local lsp_installer = require('nvim-lsp-installer')
+ lsp_installer.on_server_ready(function(server)
+ local opts = {}
+ if server.name == 'intelephense' then
+ opts.init_options = {
+ clearCache = true,
+ licenceKey = os.getenv('XDG_CONFIG_HOME') .. '/intelephense/licenceKey.txt',
+ globalStoragePath = os.getenv('XDG_CONFIG_HOME') .. '/intelephense',
+ }
+ elseif server.name == 'gopls' then
+ opts.root_dir = lspc.util.root_pattern('go.mod', '.git', vim.fn.getcwd())
+ end
+ opts.on_attach = custom_attach
+ opts.capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
+ server:setup(opts)
+ vim.cmd [[ do User LspAttachBuffers ]]
+ end)
+ lspc.efm.setup(servers.efm(custom_attach))
+ lspc.dartls.setup(servers.dartls(custom_attach))
+ lspc.gdscript.setup(servers.gdscript(custom_attach))
end
return M
diff --git a/lua/tms/lsp/servers.lua b/lua/tms/lsp/servers.lua
@@ -0,0 +1,66 @@
+local lspc = require('lspconfig')
+local efm = require('tms.lsp.efm')
+
+local M = {}
+
+M.dartls = function(attach_fn)
+ return {
+ on_attach = attach_fn,
+ cmd = require'tms.ft.dart.bin'.lspcmd(),
+ init_options = {closingLabels = true, outline = true},
+ settings = {dart = {lineLength = 120, showTodos = true, completeFunctionCalls = true}},
+ handlers = {['dart/textDocument/publishClosingLabels'] = require('tms.ft.dart.closing_labels').get_callback {}},
+ root_dir = lspc.util.root_pattern('pubspec.yaml', '.git', vim.fn.getcwd()),
+ capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()),
+ }
+end
+
+M.gdscript = function(attach_fn)
+ return {
+ on_attach = attach_fn,
+ capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()),
+ }
+end
+
+M.efm = function(attach_fn)
+ return {
+ on_attach = attach_fn,
+ init_options = {documentFormatting = true},
+ settings = efm.settings,
+ root_dir = lspc.util.root_pattern('.git', vim.fn.getcwd()),
+ filetypes = efm.filetypes(),
+ }
+end
+
+M.lua = function()
+ return require('lua-dev').setup({
+ lspconfig = {
+ cmd = {
+ '/home/tms/.cache/nvim/lspconfig/sumneko_lua/lua-language-server/bin/Linux/lua-language-server',
+ '-E',
+ '/home/tms/.cache/nvim/lspconfig/sumneko_lua/lua-language-server/main.lua',
+ },
+ settings = {
+ Lua = {
+ runtime = {version = 'LuaJIT', path = vim.split(package.path, ';')},
+ diagnostics = {globals = {'vim', 'vimp', 'Color', 'c', 'Group', 'g', 's', 'use', 'mutt'}},
+ },
+ },
+ capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()),
+ },
+ })
+end
+
+M.php = function(attach_fn)
+ return {
+ on_attach = attach_fn,
+ init_options = {
+ clearCache = true,
+ licenceKey = os.getenv('XDG_CONFIG_HOME') .. '/intelephense/licenceKey.txt',
+ globalStoragePath = os.getenv('XDG_CONFIG_HOME') .. '/intelephense',
+ },
+ capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()),
+ }
+end
+
+return M
diff --git a/lua/tms/p/actions/init.lua b/lua/tms/p/actions/init.lua
@@ -9,30 +9,29 @@ local mappings = {['n <leader>dr'] = 'run', ['n <leader>dt'] = 'test', ['n <lead
local function make(_) vim.cmd [[make]] end
-- helpers
-M.add = function(action) table.insert(actions, action) end
+local add = function(action) table.insert(actions, action) end
-- make_language_predicated
-M.add_lang =
- function(lang, a) M.add {predicate = utils.make_language_predicate(lang), actions = a} end
+local add_lang = function(lang, a) add {predicate = utils.make_language_predicate(lang), actions = a} end
-- make_git_predicate
-M.add_git = function(project, escape, a)
+local add_git = function(project, escape, a)
if type(escape) == 'table' then
a = escape
escape = false
end
- M.add {predicate = my_utils.make_git_predicate(project, escape), actions = a}
+ add {predicate = my_utils.make_git_predicate(project, escape), actions = a}
end
M.setup = function()
- M.add_lang('dart', {
+ add_lang('dart', {
run = make,
build = function(_) -- analyze
require('tms.ft.dart.analyze').qf2103()
end,
})
- M.add_lang('lua', {run = make})
- M.add_lang('go', {
+ add_lang('lua', {run = make})
+ add_lang('go', {
run = function(_)
vim.cmd [[set makeprg=go\ run\ %]]
vim.cmd [[make]]
@@ -45,7 +44,7 @@ M.setup = function()
end,
build = make,
})
- M.add_lang('zsh', {
+ add_lang('zsh', {
run = function(_)
vim.cmd [[set makeprg=./%]]
vim.cmd [[set efm=%f:%.%#:%l:\ %m,%f:%l:\ %m,%-G%.%#]]
@@ -54,11 +53,9 @@ M.setup = function()
end,
build = make,
})
- M.add_lang('gdscript', {
- run = function(_) vim.cmd [[GodotRun]] end,
- build = function(_) vim.api.nvim_input(':GodotRun ') end,
- })
- M.add_lang('sh', {run = make})
+ add_lang('gdscript',
+ {run = function(_) vim.cmd [[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/lua/tms/p/async_make.lua b/lua/tms/p/async_make.lua
@@ -1,62 +0,0 @@
-local M = {}
-
-M.job_id = nil
-
-function M.make(args)
- if M.job_id then
- return
- end
- local lines = {}
- -- local winnr = vim.fn.win_getid()
- -- local bufnr = vim.api.nvim_win_get_buf(winnr)
-
- local makeprg = vim.api.nvim_get_option('makeprg')
- if not makeprg then
- return
- end
-
- local cmd = vim.fn.expandcmd(makeprg)
-
- local function on_event(job_id, data, event)
- if event == 'stdout' or event == 'stderr' then
- if data then
- vim.list_extend(lines, data)
- end
- end
-
- if event == 'exit' then
- vim.fn.setqflist({}, ' ',
- {title = cmd, lines = lines, efm = vim.api.nvim_get_option('errorformat')})
- vim.api.nvim_command('doautocmd QuickFixCmdPost')
- M.job_id = nil
- end
- end
-
- local id = vim.fn.jobstart(cmd, {
- on_stderr = on_event,
- on_stdout = on_event,
- on_exit = on_event,
- stdout_buffered = true,
- stderr_buffered = true,
- })
-
- if id > 0 then
- M.job_id = id
- end
-end
-
-function M.stop()
- if M.job_id then
- vim.fn.jobstop(M.job_id)
- print('Async make stopped.')
- end
-end
-
-function M.running()
- if M.job_id then
- return true
- end
- return false
-end
-
-return M
diff --git a/lua/tms/p/compe.lua b/lua/tms/p/compe.lua
@@ -1,58 +0,0 @@
-local M = {}
-
-M.config = {autocomplete = false, preselect = 'always'}
-M.source = {
- path = true,
- buffer = true,
- calc = true,
- nvim_lsp = true,
- nvim_lua = true,
- snippets_nvim = true,
- -- emoji = true,
- norg = true,
-}
-
-local t = function(str)
- return vim.api.nvim_replace_termcodes(str, true, true, true)
-end
-
-local check_back_space = function()
- local col = vim.fn.col('.') - 1
- if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
- return true
- else
- return false
- end
-end
-
-M.setup = function(sources, c)
- local config = M.config
- local source = M.source
- if sources then for k, v in pairs(sources) do source[k] = v end end
- if c then for k, v in pairs(c) do config[k] = v end end
- config.source = source
- require('compe').setup(config)
-
- -- Use (s-)tab to:
- --- move to prev/next item in completion menuone
- --- jump to prev/next snippet's placeholder
- _G.tab_complete = function()
- if vim.fn.pumvisible() == 1 then
- return t '<C-n>'
- elseif check_back_space() then
- return t '<Tab>'
- else
- return vim.fn['compe#complete']()
- end
- end
-
- _G.s_tab_complete = function()
- if vim.fn.pumvisible() == 1 then
- return t '<C-p>'
- else
- return t '<S-Tab>'
- end
- end
-end
-
-return M
diff --git a/lua/tms/p/firenvim.lua b/lua/tms/p/firenvim.lua
@@ -1,15 +0,0 @@
-local kb = require 'tms.c.keybind'
-local M = {}
-
-function M.setup()
- vim.o.laststatus = 0
-
- vim.g.firenvim_config = {
- globalSettings = {['alt'] = 'all'},
- localSettings = {['.*'] = {cmdline = 'neovim', takeover = 'never'}},
- }
-
- kb.nnoremap('<c-z>', '<cmd>call firenvim#hide_frame()<cr>')
-end
-
-return M
diff --git a/lua/tms/p/gitlens.lua b/lua/tms/p/gitlens.lua
@@ -1,36 +0,0 @@
---- GitLens layer
--- @module layer.gitlens
-local api = vim.api
-
-local layer = {}
-
-function layer.blame_virt_text()
- local ft = vim.fn.expand('%:h:t')
- if ft == '' then return end
- if ft == 'bin' then return end
- api.nvim_buf_clear_namespace(0, 2, 0, -1)
- local currFile = vim.fn.expand('%')
- local line = api.nvim_win_get_cursor(0)
- local blame = vim.fn.system(string.format('git blame -c -L %d,%d %s', line[1], line[1], currFile))
- local hash = vim.split(blame, '%s')[1]
- local cmd = string.format("git show %s ", hash) .. "--format='%an | %ar | %s'"
- local text
- if hash == '00000000' then
- text = "Not Committed Yes"
- else
- text = vim.fn.system(cmd)
- text = vim.split(text, '\n')[1]
- if text:find("fatal") then text = "Not Committed Yes" end
- end
- api.nvim_buf_set_virtual_text(0, 2, line[1] - 1, {{text, 'GitLens'}}, {})
-end
-
-function layer.clear_blame_virt_text() api.nvim_buf_clear_namespace(0, 2, 0, -1) end
-
-function layer.init_config()
--- autocmd.bind("CursorHold *", function() layer.blame_virt_text() end)
--- autocmd.bind("CursorMoved, CursorMovedI *", function() layer.clear_blame_virt_text() end)
- vim.api.nvim_command("hi! link GitLens comment")
-end
-
-return layer
diff --git a/lua/tms/p/spectre.lua b/lua/tms/p/spectre.lua
@@ -0,0 +1,60 @@
+local M = {}
+M.setup = function()
+ require('spectre').setup({
+ mapping = {
+ ['toggle_line'] = {
+ map = 'gd',
+ cmd = '<cmd>lua require(\'spectre\').toggle_line()<CR>',
+ desc = 'toggle current item',
+ },
+ ['enter_file'] = {
+ map = '<cr>',
+ cmd = '<cmd>lua require(\'spectre.actions\').select_entry()<CR>',
+ desc = 'goto current file',
+ },
+ ['send_to_qf'] = {
+ map = 'gq',
+ cmd = '<cmd>lua require(\'spectre.actions\').send_to_qf()<CR>',
+ desc = 'send all item to quickfix',
+ },
+ ['replace_cmd'] = {
+ map = 'gc',
+ cmd = '<cmd>lua require(\'spectre.actions\').replace_cmd()<CR>',
+ desc = 'input replace vim command',
+ },
+ ['show_option_menu'] = {
+ map = 'go',
+ cmd = '<cmd>lua require(\'spectre\').show_options()<CR>',
+ desc = 'show option',
+ },
+ ['run_replace'] = {
+ map = 'gR',
+ cmd = '<cmd>lua require(\'spectre.actions\').run_replace()<CR>',
+ desc = 'replace all',
+ },
+ ['change_view_mode'] = {
+ map = 'tt',
+ cmd = '<cmd>lua require(\'spectre\').change_view()<CR>',
+ desc = 'change result view mode',
+ },
+ ['toggle_live_update'] = {
+ map = 'tu',
+ cmd = '<cmd>lua require(\'spectre\').toggle_live_update()<CR>',
+ desc = 'update change when vim write file.',
+ },
+ ['toggle_ignore_case'] = {
+ map = 'ti',
+ cmd = '<cmd>lua require(\'spectre\').change_options(\'ignore-case\')<CR>',
+ desc = 'toggle ignore case',
+ },
+ ['toggle_ignore_hidden'] = {
+ map = 'th',
+ cmd = '<cmd>lua require(\'spectre\').change_options(\'hidden\')<CR>',
+ desc = 'toggle search hidden',
+ },
+ -- you can put your mapping here it only use normal mode
+ },
+ })
+end
+
+return M
diff --git a/lua/tms/p/treesitter.lua b/lua/tms/p/treesitter.lua
@@ -4,15 +4,6 @@ M.setup = function()
require'nvim-treesitter.configs'.setup {
ensure_intalled = 'maintained',
highlight = {enable = true},
- incremental_selection = {
- enable = true,
- keymaps = {
- init_selection = '+',
- node_incremental = '+',
- -- scope_incremental = "grc",
- node_decremental = '-',
- },
- },
indent = {enable = true},
@@ -28,7 +19,7 @@ M.setup = function()
['af'] = '@function.outer',
['if'] = '@function.inner',
['ac'] = '@comment.outer',
- ['im'] = {dart = '@identifier'},
+ ['im'] = '@identifier',
['ia'] = {html = '@attribute'},
},
},
@@ -47,31 +38,17 @@ M.setup = function()
enable = true,
goto_next_start = {[']]'] = '@function.outer', [']c'] = '@class.outer'},
goto_next_end = {[']['] = '@function.inner', [']C'] = '@class.outer'},
- goto_previous_start = {
- ['[['] = '@function.outer',
- ['[c'] = '@class.outer',
- },
- goto_previous_end = {
- ['[]'] = '@function.inner',
- ['[C'] = '@class.outer',
- },
+ goto_previous_start = {['[['] = '@function.outer', ['[c'] = '@class.outer'},
+ goto_previous_end = {['[]'] = '@function.inner', ['[C'] = '@class.outer'},
},
lsp_interop = {
enable = true,
border = 'single',
- peek_definition_code = {
- ['<leader>sf'] = '@function.outer',
- ['<leader>sc'] = '@class.outer',
- },
+ peek_definition_code = {['<leader>sf'] = '@function.outer', ['<leader>sc'] = '@class.outer'},
},
},
- playground = {
- enable = true,
- disable = {},
- updatetime = 25,
- persist_queries = false,
- },
+ playground = {enable = true, disable = {}, updatetime = 25, persist_queries = false},
}
end
diff --git a/lua/tms/plugins.lua b/lua/tms/plugins.lua
@@ -159,12 +159,14 @@ local function init()
use {
'windwp/nvim-spectre',
config = function()
+ require('tms.p.spectre').setup()
local kb = require('tms.c.keybind')
kb.nnoremap('<leader>S', '<cmd>lua require("spectre").open()<cr>')
kb.vnoremap('<leader>s', '<cmd>lua require("spectre").open_visual()<cr>')
end,
} -- replace
use {'tjdevries/astronauta.nvim'}
+ use {'luukvbaal/stabilize.nvim'}
-- quickfix list
use {'kevinhwang91/nvim-bqf', config = function() require('tms.p.bqf').setup() end}
@@ -205,7 +207,7 @@ local function init()
end,
}
use 'sindrets/diffview.nvim' -- view diffs for multiple files
- use {
+ use { -- git integration
'tpope/vim-fugitive',
config = function()
local kb = require('tms.c.keybind')
@@ -213,14 +215,25 @@ local function init()
kb.nnoremap('<leader>gc', '<cmd>G commit<cr>')
kb.nnoremap('<leader>gb', '<cmd>Git blame<cr>')
end,
- } -- git integration
- use {
+ }
+ use { -- git info for current line
'rhysd/git-messenger.vim',
config = function()
local kb = require('tms.c.keybind')
kb.nnoremap('<leader>gm', '<plug>(git-messenger)')
end,
- } -- git info for current line
+ }
+ use {
+ 'ThePrimeagen/git-worktree.nvim',
+ after = {'telescope.nvim'},
+ config = function()
+ require('git-worktree').setup()
+ local kb = require('tms.c.keybind')
+ require('telescope').load_extension('git_worktree')
+ kb.nnoremap('<space>wo', require('telescope').extensions.git_worktree.git_worktrees)
+ kb.nnoremap('<space>wi', require('telescope').extensions.git_worktree.create_git_worktree)
+ end,
+ }
-- colorscheme
use {'ishan9299/nvim-solarized-lua', config = function() end}
@@ -236,17 +249,6 @@ local function init()
after = {'gruvbox', 'nvim-solarized-lua'},
config = function() require('tms.colors').setup() end,
}
- use {
- 'ThePrimeagen/git-worktree.nvim',
- after = {'telescope.nvim'},
- config = function()
- require('git-worktree').setup()
- local kb = require('tms.c.keybind')
- require('telescope').load_extension('git_worktree')
- kb.nnoremap('<space>wo', require('telescope').extensions.git_worktree.git_worktrees)
- kb.nnoremap('<space>wi', require('telescope').extensions.git_worktree.create_git_worktree)
- end,
- }
-- http
use {disable = true, 'nicwest/vim-http'}
@@ -265,20 +267,10 @@ local function init()
}
-- file manager
- -- use {'junegunn/fzf'}
- -- use {'junegunn/fzf.vim', config = function() vim.g.fzf_buffers_jump = 1 end}
use {'vifm/vifm.vim', config = function() vim.g.vifm_replace_netrw = true end}
-- tasks
use {'amirrezaask/actions.nvim', config = function() require('tms.p.actions').setup() end}
- use {
- 'skywind3000/asyncrun.vim',
- config = function()
- local kb = require('tms.c.keybind')
- kb.nnoremap('<leader>rs', '<cmd>AsyncStop<cr>')
- kb.nnoremap('<leader>rr', ':AsyncRun ')
- end,
- }
-- filetype
use {
@@ -302,43 +294,80 @@ local function init()
-- completion
use {
- disable = false,
- 'hrsh7th/nvim-compe',
+ 'hrsh7th/nvim-cmp',
+ requires = {
+ 'hrsh7th/cmp-buffer',
+ 'hrsh7th/cmp-nvim-lsp',
+ 'hrsh7th/cmp-path',
+ 'hrsh7th/cmp-nvim-lua',
+ 'f3fora/cmp-spell',
+ 'hrsh7th/cmp-calc',
+ 'ray-x/cmp-treesitter',
+ 'uga-rosa/cmp-dictionary',
+ },
config = function()
- require('tms.p.compe').setup()
- local kb = require('tms.c.keybind')
+ -- require('tms.p.compe').setup()
+ local cmp = require('cmp')
+ cmp.setup({
+ completion = {autocomplete = false},
+ documentation = {border = 'single'},
+ mapping = {
+ ['<C-d>'] = cmp.mapping.scroll_docs(-4),
+ ['<C-f>'] = cmp.mapping.scroll_docs(4),
+ ['<Down'] = cmp.mapping.select_next_item({behavior = cmp.SelectBehavior.Insert}),
+ ['<Up>'] = cmp.mapping.select_prev_item({behavior = cmp.SelectBehavior.Insert}),
+ ['<C-Space>'] = cmp.mapping.complete(),
+ ['<C-e>'] = cmp.mapping.close(),
+ ['<CR>'] = cmp.mapping.confirm({select = true, behavior = cmp.ConfirmBehavior.Replace}),
+ },
+ sources = {
+ {name = 'nvim_lsp'},
+ {name = 'nvim_lua'},
+ {name = 'path'},
+ {name = 'buffer'},
+ {name = 'spell'},
+ {name = 'calc'},
+ {name = 'treesitter'},
+ {name = 'dictionary'},
+ },
+ })
+ -- local kb = require('tms.c.keybind')
-- kb.inoremap('<c-space>', 'compe#complete()', {silent = true, expr = true})
- kb.inoremap('<cr>', 'compe#confirm("<cr>")', {silent = true, expr = true})
- kb.inoremap('<c-e>', 'compe#close("<c-e>")', {silent = true, expr = true})
- kb.imap('<Tab>', 'v:lua.tab_complete()', {expr = true})
- kb.smap('<Tab>', 'v:lua.tab_complete()', {expr = true})
- kb.imap('<S-Tab>', 'v:lua.s_tab_complete()', {expr = true})
- kb.smap('<S-Tab>', 'v:lua.s_tab_complete()', {expr = true})
+ -- kb.imap('<Tab>', 'v:lua.tab_complete()', {expr = true})
+ -- kb.smap('<Tab>', 'v:lua.tab_complete()', {expr = true})
+ -- kb.imap('<S-Tab>', 'v:lua.s_tab_complete()', {expr = true})
+ -- kb.smap('<S-Tab>', 'v:lua.s_tab_complete()', {expr = true})
end,
}
- use {disable = false, 'tamago324/compe-zsh', requires = {'hrsh7th/nvim-compe', 'nvim-lua/plenary.nvim'}}
- use {
- disable = true,
- 'ms-jpq/coq_nvim',
- branch = 'coq',
- config = function() vim.g.coq_settings = {['display.pum.source_context'] = {'', ''}} end,
- }
-- ui
use 'MunifTanjim/nui.nvim'
use 'rcarriga/nvim-notify'
+ -- refactor
+ use {
+ 'ThePrimeagen/refactoring.nvim',
+ config = function()
+ local refactor = require('refactoring')
+ refactor.setup()
+ vim.api.nvim_set_keymap('v', '<leader>re',
+ [[ <Esc><Cmd>lua require('refactoring').refactor('Extract Function')<CR>]],
+ {noremap = true, silent = true, expr = false})
+ vim.api.nvim_set_keymap('v', '<leader>rf',
+ [[ <Esc><Cmd>lua require('refactoring').refactor('Extract Function To File')<CR>]],
+ {noremap = true, silent = true, expr = false})
+ end,
+ }
+
-- lsp
use 'neovim/nvim-lspconfig'
- use {disable = true, 'RRethy/vim-illuminate'}
- use 'ray-x/lsp_signature.nvim'
- use 'alexaandru/nvim-lspupdate'
+ use 'williamboman/nvim-lsp-installer'
use {
'folke/lsp-trouble.nvim',
requires = 'kyazdani42/nvim-web-devicons',
config = function() require('trouble').setup {} end,
}
- use {'folke/lua-dev.nvim', config = function() end}
+ use {'folke/lua-dev.nvim'}
use {
'jose-elias-alvarez/null-ls.nvim',
config = function()
@@ -381,13 +410,6 @@ local function init()
branch = 'main',
},
}
- parser_configs.norg = {
- install_info = {
- url = 'https://github.com/vhyrro/tree-sitter-norg',
- files = {'src/parser.c', 'src/scanner.cc'},
- branch = 'main',
- },
- }
require('tms.p.treesitter').setup()
-- hack
vim.cmd [[command! TSHRefresh execute 'write|edit|TSBufEnable highlight']]
@@ -463,14 +485,6 @@ local function init()
use {'habamax/vim-godot'}
-- external usage
- use {
- 'glacambre/firenvim',
- run = ':call firenvim#install(1)',
- config = function()
- if not vim.g.started_by_firenvim then return end
- require'tms.p.firenvim'.setup()
- end,
- }
-- personal
use {
diff --git a/plugin/async_make.lua b/plugin/async_make.lua
@@ -1,2 +0,0 @@
-vim.cmd [[command! -nargs=* -complete=shellcmd Make lua require('tms.p.async_make').make(vim.fn.expand('<args>'))]]
-vim.cmd [[command! -nargs=0 MakeStop lua require('tms.p.async_make').stop()]]