commit 0d9e316168bcb1559c9b4aab3d5efb053c049a3e
parent 1d1da1f4456b6a37d5f6a7b5bd2e80673b2a6641
Author: Tomas Nemec <nemi@skaut.cz>
Date: Wed, 3 Nov 2021 23:51:42 +0100
update
Diffstat:
6 files changed, 69 insertions(+), 60 deletions(-)
diff --git a/init.lua b/init.lua
@@ -146,6 +146,9 @@ nnoremap {'v.', 'V'}
nnoremap {'=.', '=='}
nnoremap {'gc.', 'gcc'}
+-- plugins
+vim.g.user_emmet_leader_key = '<C-Z>'
+
-- autocommands
local au = require('tms.c.autocmd')
au.addListeners({
@@ -177,7 +180,6 @@ au.addListeners({
-- autocmd BufWritePost lua/tms/plugins.lua PackerCompile
-- augroup end
-- ]], false)
-
vim.cmd [[ packadd cfilter ]]
require('tms.diagnostic').setup()
require('tms.lsp').setup()
diff --git a/lua/tms/lsp/init.lua b/lua/tms/lsp/init.lua
@@ -13,7 +13,7 @@ local keybind = function(bufnr)
vim.keymap.inoremap {'<c-p>', vim.lsp.buf.signature_help, silent = true, buffer = bufnr}
vim.keymap.nnoremap {'gr', vim.lsp.buf.references, silent = true, buffer = bufnr}
vim.keymap.nnoremap {'ga', t.lsp_code_actions, silent = true, buffer = bufnr}
- vim.keymap.vnoremap {'ga', ':Telescope lsp_range_code_actions<cr>', silent = true, buffer = bufnr}
+ vim.keymap.vnoremap {'ga', ':Telescope lsp_range_code_actions theme=dropdown previewer=false<cr>', silent = true, buffer = bufnr}
vim.keymap.nnoremap {'gn', vim.lsp.buf.rename, silent = true, buffer = bufnr}
vim.keymap.nnoremap {'gm', t.lsp_document_symbols, silent = true, buffer = bufnr}
-- formatting
diff --git a/lua/tms/p/cmp/init.lua b/lua/tms/p/cmp/init.lua
@@ -3,11 +3,6 @@ local cmp = require('cmp')
local M = {}
--- local has_words_before = function()
--- local line, col = unpack(vim.api.nvim_win_get_cursor(0))
--- return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match('%s') == nil
--- end
-
M.sources = {
{name = 'nvim_lsp'},
{name = 'nvim_lua'},
@@ -40,29 +35,6 @@ M.setup = function()
['<Down>'] = cmp.mapping.select_next_item(),
['<Up>'] = cmp.mapping.select_prev_item(),
['<Right>'] = cmp.mapping.confirm({behavior = cmp.ConfirmBehavior.Insert, select = true}),
-
- -- ['<Tab>'] = cmp.mapping(function(fallback)
- -- if cmp.visible() then
- -- cmp.select_next_item()
- -- elseif luasnip.expand_or_jumpable() then
- -- luasnip.expand_or_jump()
- -- elseif has_words_before() then
- -- cmp.complete()
- -- else
- -- fallback()
- -- end
- -- end, {'i', 's'}),
- --
- -- ['<S-Tab>'] = cmp.mapping(function(fallback)
- -- if cmp.visible() then
- -- cmp.select_prev_item()
- -- elseif luasnip.jumpable(-1) then
- -- luasnip.jump(-1)
- -- else
- -- fallback()
- -- end
- -- end, {'i', 's'}),
-
},
sources = M.sources,
experimental = {ghost_text = true},
diff --git a/lua/tms/p/luasnip.lua b/lua/tms/p/luasnip.lua
@@ -1,38 +1,74 @@
local luasnip = require('luasnip')
-local M = {}
-local function feedkeys(key)
- key = vim.api.nvim_replace_termcodes(key, true, false, true)
- vim.api.nvim_feedkeys(key, 'n', true)
-end
+local M = {}
-M.setup = function()
- local next = '<C-n>'
- local prev = '<C-p>'
+local keymaps = function()
+ vim.keymap.inoremap {'<C-l>', function() if luasnip.expand_or_jumpable() then luasnip.expand_or_jump() end end}
+ vim.keymap.snoremap {'<C-l>', function() if luasnip.expand_or_jumpable() then luasnip.expand_or_jump() end end}
+ vim.keymap.inoremap {'<C-h>', function() if luasnip.jumpable(-1) then luasnip.jump(-1) end end}
+ vim.keymap.snoremap {'<C-h>', function() if luasnip.jumpable(-1) then luasnip.jump(-1) end end}
vim.keymap.inoremap {
- next,
- function()
- if luasnip.jumpable(1) then
- luasnip.jump(1)
- else
- feedkeys(next)
- end
- end,
+ '<C-e>',
+ function() if luasnip.choice_active() then luasnip.change_choice(1) end end,
silent = true,
}
- vim.keymap.snoremap {next, '<cmd>lua require("luasnip").jump(1)<cr>', silent = true}
- vim.keymap.inoremap {
- prev,
- function()
- if luasnip.jumpable(-1) then
- luasnip.jump(-1)
- else
- feedkeys(prev)
- end
- end,
+ vim.keymap.snoremap {
+ '<C-e>',
+ function() if luasnip.choice_active() then luasnip.change_choice(1) end end,
silent = true,
}
- vim.keymap.snoremap {prev, '<cmd>lua require("luasnip").jump(-1)<cr>', silent = true}
+ -- vim.api.nvim_set_keymap("i", "<C-E>", "<Plug>luasnip-next-choice", {})
+ -- vim.api.nvim_set_keymap("s", "<C-E>", "<Plug>luasnip-next-choice", {})
+end
+
+local function copy(args) return args[1] end
+-- Make sure to not pass an invalid command, as io.popen() may write over nvim-text.
+
+local function bash(_, _, command)
+ local file = io.popen(command, 'r')
+ local res = {}
+ for line in file:lines() do table.insert(res, line) end
+ return res
+end
+
+local snippets = function()
+ local ls = luasnip
+ local s = ls.snippet
+ local sn = ls.snippet_node
+ local isn = ls.indent_snippet_node
+ local t = ls.text_node
+ local i = ls.insert_node
+ local f = ls.function_node
+ local c = ls.choice_node
+ local d = ls.dynamic_node
+ local events = require('luasnip.util.events')
+ local l = require('luasnip.extras').lambda
+ local p = require('luasnip.extras').partial
+ ls.snippets = {
+ all = {
+ s('date', p(os.date, '%d.%m.%Y')),
+ s('time', p(os.date, '%H:%M:%S')),
+ s('todo', {
+ f(function(_, _, _) return require('luasnip.util.util').buffer_comment_chars()[1] end, {}),
+ t(' TODO('),
+ f(bash, {}, 'id -un'),
+ t(') '),
+ p(os.date, '%d.%m.%y'),
+ t(': '),
+ }),
+ },
+ }
+end
+-- TODO(tms) 03.11.2021:
+
+M.setup = function()
+ local types = require('luasnip.util.types')
+ luasnip.config.set_config({
+ store_selection_keys = '<Tab>',
+ ext_opts = {[types.choiceNode] = {active = {virt_text = {{'choiceNode', 'Comment'}}}}},
+ })
+ keymaps()
+ snippets()
end
return M
diff --git a/lua/tms/p/treesitter.lua b/lua/tms/p/treesitter.lua
@@ -48,7 +48,7 @@ M.setup = function()
},
playground = {enable = true, disable = {}, updatetime = 25, persist_queries = false},
- context_commentstring = {enable = true, enable_autocmd = false},
+ context_commentstring = {enable = true, enable_autocmd = false, config = {scss = '// %s'}},
}
require 'nvim-treesitter.highlight'
diff --git a/lua/tms/plugins.lua b/lua/tms/plugins.lua
@@ -26,7 +26,6 @@ local function init()
function() vim.cmd [[let b:lexima_disabled = 1]] end)
end,
}
- use 'michaeljsmith/vim-indent-object'
use {'JoosepAlviste/nvim-ts-context-commentstring'}
use {
'numToStr/Comment.nvim',
@@ -279,7 +278,7 @@ local function init()
-- filetype
use 'tikhomirov/vim-glsl'
- use 'mattn/emmet-vim'
+ use {'mattn/emmet-vim'}
use {'windwp/nvim-ts-autotag', config = function() require('nvim-ts-autotag').setup {} end} -- html tag autoclose/rename
use {'vim-php/vim-composer', config = function() vim.g.composer_cmd = 'composer' end}
use 'fpob/nette.vim'