diff --git a/.config/nvim/coc-settings.json b/.config/nvim/coc-settings.json index 11f943d..e0eda9a 100644 --- a/.config/nvim/coc-settings.json +++ b/.config/nvim/coc-settings.json @@ -44,9 +44,12 @@ "filetypes": [ "mun" ] - } + }, + "zls" : { + "command": "zls", + "filetypes": ["zig"] + } }, "java.format.enabled": true, - "java.format.onType.enabled": true, - "java.format.settings.url": "/home/lordmzte/.config/coc/extensions/node_modules/redhat.java/https:/raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml" + "java.format.onType.enabled": true } diff --git a/.config/nvim/lua/pluginconf/coc.lua b/.config/nvim/lua/pluginconf/coc.lua index 35d52b9..1fffefd 100644 --- a/.config/nvim/lua/pluginconf/coc.lua +++ b/.config/nvim/lua/pluginconf/coc.lua @@ -12,3 +12,22 @@ vim.g.coc_global_extensions = { "coc-tabnine", "coc-toml", } + +local function check_back_space() + local col = vim.fn.col(".") - 1 + return col <= 0 or vim.fn.getline("."):sub(col, col):match("%s") +end + +function tab_completion() + if vim.fn.pumvisible() > 0 then + return vim.api.nvim_replace_termcodes("", true, true, true) + end + + if check_back_space() then + return vim.api.nvim_replace_termcodes("", true, true, true) + end + + return vim.fn["coc#refresh"]() +end + +vim.api.nvim_set_keymap("i", "", "v:lua.tab_completion()", { expr = true, noremap = false })