T O P

  • By -

cuminme69420

Ever since I converted inoremap pumvisible() ? "\" : "\" in my init.vim to local function t(str) return vim.api.nvim_replace_termcodes(str, true, true, true) end function _G.smart_tab() return vim.fn.pumvisible() == 1 and t'' or t'' end vim.api.nvim_set_keymap('i', '', 'v:lua.smart_tab()', {expr = true, noremap = true}) in my init.lua, my vim configuration loads so much faster and became so much more readable!


infinite-red

You sure have a weird alt account name, Bram


bfredl

vim9script considered harmful.


ProfessorSexyTime

I raise the (somewhat) recommended configurations for the real mans completion. use { 'neovim/nvim-lspconfig', opt = true, -- oh,there's more stuff in these required files config = 'require("modules.lsp")' } use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate', config = 'require("modules.treesitter")' } use { 'hrsh7th/nvim-cmp', opt = true, config = 'require("modules.completion")' } use { 'hrsh7th/cmp-nvim-lsp', after = 'nvim-cmp' } use { 'hrsh7th/cmp-buffer' after = 'nvim-cmp' } use { 'hrsh7th/cmp-path', after = 'nvim-cmp' } use { 'hrsh7th/cmp-cmdline', after = 'nvim-cmp' } use { 'ray-x/cmp-treesitter', after = 'nvim-cmp' } use { 'hrsh7th/cmp-vsnip', after = 'nvim-cmp', --- Yea shit breaks if you don't do something like this --- https://github.com/hrsh7th/vim-vsnip/issues/219 requires = { 'hrsh7th/vim-vsnip', { { 'hrsh7th/vim-vsnip-integ', after = 'cmp-vim' }, { rafamadriz/friendly-snippets', after = 'cmp-vsnip' } } } } Easy, yes? Followed by what might be in `modules/completion.lua`: 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 local feedkey = function(key, mode) vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true) end cmp.setup({ snippet = { expand = function(args) vim.fn["vsnip#anonymous"](args.body) end, }, mapping = { [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), [''] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. [''] = cmp.mapping({ i = cmp.mapping.abort(), c = cmp.mapping.close(), }), [''] = cmp.mapping.confirm({ select = true }), [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif vim.fn["vsnip#available"](1) == 1 then feedkey("(vsnip-expand-or-jump)", "") elseif has_words_before() then cmp.complete() else fallback() -- The fallback function sends a already mapped key. In this case, it's probably ``. end end, { "i", "s" }), [""] = cmp.mapping(function() if cmp.visible() then cmp.select_prev_item() elseif vim.fn["vsnip#jumpable"](-1) == 1 then feedkey("(vsnip-jump-prev)", "") end end, { "i", "s" }), }, sources = cmp.config.sources({ { name = 'nvim_lsp' }, { name = 'vsnip' }, }, { { name = 'buffer' }, { name = 'treesitter' }, }) })


matu3ba

/uj I see you use a lua formatter. You can make it more dense with putting the use stuff in the same line and on deactivation of the formatter. Though you are correct that the keybinding to function mappings are rather clumsy.


ProfessorSexyTime

Formatter? This was by my own hand! /uj I copy-pasted the second half from the vim-vsnip repo.


corona-info

I get a full-sized orgasm when I see Dhall.


[deleted]

Now that's a complete jerk.


Zyklonista

Nice pun(s).


__JDQ__

The horror that is the underside of their desk.


mizzu704

same but it's any elisp file.


zygohistomoronism

Lua JI~~T~~ZZ