neovim: upgrade to nvim-cmp from nvim-compe
This commit is contained in:
		@@ -42,7 +42,7 @@ config =
 | 
			
		||||
        ],
 | 
			
		||||
      sepChar = "*",
 | 
			
		||||
      alignSep = "--",
 | 
			
		||||
      template = "<action=`dmenu_run` button=1><icon=/home/natto/.xmonad/lib/nixos.xpm/></action> *UnsafeStdinReader* " ++ sep ++ " <fn=1></fn>*mpd* -- *multicpu* " ++ sep ++ " *memory* " ++ sep ++ " *wlp0s20f3* " ++ sep ++ " *battery* " ++ sep ++ " <fn=1>\xf028</fn> <fc=" ++ green ++ ">*pamixer*%</fc> " ++ sep ++ " *date* - *time* *tray*"
 | 
			
		||||
      template = "<action=`dmenu_run` button=1><icon=/home/natto/.xmonad/lib/nixos.xpm/></action> *UnsafeStdinReader* " ++ sep ++ " <fn=1></fn>*mpd* -- *multicpu* " ++ sep ++ " *memory* " ++ sep ++ " *wlp0s20f3* " ++ sep ++ " *battery* " ++ sep ++ " <fn=1>\xf028</fn> <fc=" ++ green ++ ">*pamixer*%</fc> " ++ sep ++ " *date* - *time* " ++ sep ++ "*tray*"
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
main :: IO ()
 | 
			
		||||
 
 | 
			
		||||
@@ -247,8 +247,8 @@ main = do xmproc <- spawnPipe ("xmobar " ++ myXmobarrc)
 | 
			
		||||
              , logHook            = dynamicLogWithPP xmobarPP
 | 
			
		||||
                  { ppOutput = hPutStrLn xmproc
 | 
			
		||||
                  , ppCurrent = xmobarColor activeWinColor "" . wrap "(" ")"
 | 
			
		||||
                    , ppVisible = xmobarColor activeWinColor ""
 | 
			
		||||
                    , ppHidden = xmobarColor inactiveWinColor ""
 | 
			
		||||
                  , ppVisible = xmobarColor activeWinColor ""
 | 
			
		||||
                  , ppHidden = xmobarColor inactiveWinColor ""
 | 
			
		||||
                  , ppTitle = xmobarColor fgColor "" . shorten 40
 | 
			
		||||
                  , ppLayout = const ""
 | 
			
		||||
                  , ppUrgent = xmobarColor urgentWinColor "" . wrap "!" ""
 | 
			
		||||
 
 | 
			
		||||
@@ -90,15 +90,15 @@ in
 | 
			
		||||
        enable = true;
 | 
			
		||||
        config = {
 | 
			
		||||
          geometry = "1x1-0";
 | 
			
		||||
          max_geometry = "5x0";
 | 
			
		||||
          max_geometry = "10x0";
 | 
			
		||||
          window_type = "dock";
 | 
			
		||||
          sticky = true;
 | 
			
		||||
          scrollbars = "horizontal";
 | 
			
		||||
          icon_size = 23;
 | 
			
		||||
          background = "#1d2021";
 | 
			
		||||
          grow_gravity = "E";
 | 
			
		||||
          icon_gravity = "E";
 | 
			
		||||
          grow_gravity = "E";
 | 
			
		||||
          kludges = "force_icons_size";
 | 
			
		||||
          window_layer = "top";
 | 
			
		||||
        };
 | 
			
		||||
      };
 | 
			
		||||
    };
 | 
			
		||||
 
 | 
			
		||||
@@ -29,6 +29,7 @@
 | 
			
		||||
    ccls
 | 
			
		||||
    clang-tools
 | 
			
		||||
    nodePackages.typescript-language-server
 | 
			
		||||
    nodePackages.svelte-language-server
 | 
			
		||||
    rnix-lsp
 | 
			
		||||
    python3Packages.python-lsp-server
 | 
			
		||||
    haskell-language-server
 | 
			
		||||
 
 | 
			
		||||
@@ -21,15 +21,23 @@
 | 
			
		||||
          vim-floaterm 
 | 
			
		||||
          vim-closetag
 | 
			
		||||
          nerdcommenter
 | 
			
		||||
          nvim-compe
 | 
			
		||||
          nvim-cmp
 | 
			
		||||
          cmp_luasnip
 | 
			
		||||
          cmp-nvim-lsp
 | 
			
		||||
          cmp-path
 | 
			
		||||
          cmp-calc
 | 
			
		||||
          cmp-emoji
 | 
			
		||||
 #         cmp-look
 | 
			
		||||
          cmp-buffer
 | 
			
		||||
          nvim-lspconfig
 | 
			
		||||
          barbar-nvim
 | 
			
		||||
          presence-nvim
 | 
			
		||||
          nvim-web-devicons
 | 
			
		||||
          nvim-tree-lua
 | 
			
		||||
          vim-vsnip
 | 
			
		||||
          luasnip
 | 
			
		||||
          nvim-treesitter
 | 
			
		||||
          vim-latex-live-preview
 | 
			
		||||
          lspkind-nvim
 | 
			
		||||
        # (gruvbox.overrideAttrs (oa: { patches = [ ./gruvbox.patch ]; }))
 | 
			
		||||
          base16-vim
 | 
			
		||||
        ];
 | 
			
		||||
 
 | 
			
		||||
@@ -7,9 +7,7 @@ local getvar = vim.api.nvim_get_var
 | 
			
		||||
function hi(hi_var, hi_value)
 | 
			
		||||
    comm("hi " .. hi_var .. " " .. hi_value)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
--SETTINGS
 | 
			
		||||
 | 
			
		||||
vim.o.cmdheight = 1
 | 
			
		||||
vim.o.modifiable = true
 | 
			
		||||
vim.o.cursorline = true
 | 
			
		||||
@@ -40,7 +38,6 @@ vim.o.clipboard = "unnamedplus"
 | 
			
		||||
vim.o.completeopt = "menuone,noselect"
 | 
			
		||||
vim.o.cursorcolumn = true
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
--KEYBINDS
 | 
			
		||||
 | 
			
		||||
--Colemak-DH bind fuction for hjkl [mnei]) 
 | 
			
		||||
@@ -140,10 +137,6 @@ bind('n', "<M-o>", ":NvimTreeToggle<CR>", {noremap=true, silent=true})
 | 
			
		||||
bind('n', "<Space>r", ":NvimTreeRefresh<CR>", {noremap=true, silent=true})
 | 
			
		||||
bind('n', "<Space>f", ":NvimTreeFindFile<CR>", {noremap=true, silent=true})
 | 
			
		||||
 | 
			
		||||
--theme
 | 
			
		||||
--im.g.gruvbox_italic=1
 | 
			
		||||
--vim.g.gruvbox_contrast_dark="hard"
 | 
			
		||||
--vim.g.gruvbox_contrast_light="hard"
 | 
			
		||||
vim.o.background="dark"
 | 
			
		||||
comm("colorscheme base16-tomorrow-night")
 | 
			
		||||
 | 
			
		||||
@@ -216,75 +209,104 @@ local on_attach = function(client, bufnr)
 | 
			
		||||
  buf_set_keymap('n', "<M-f>", "<cmd>lua vim.lsp.buf.formatting()<CR>", {silent=true, noremap=true})
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
require'compe'.setup {
 | 
			
		||||
  enabled = true;
 | 
			
		||||
  autocomplete = true;
 | 
			
		||||
  debug = false;
 | 
			
		||||
  min_length = 1;
 | 
			
		||||
  preselect = 'enable';
 | 
			
		||||
  throttle_time = 80;
 | 
			
		||||
  source_timeout = 200;
 | 
			
		||||
  incomplete_delay = 400;
 | 
			
		||||
  max_abbr_width = 100;
 | 
			
		||||
  max_kind_width = 100;
 | 
			
		||||
  max_menu_width = 100;
 | 
			
		||||
  documentation = true;
 | 
			
		||||
 | 
			
		||||
  source = {
 | 
			
		||||
    path = true;
 | 
			
		||||
    buffer = true;
 | 
			
		||||
    nvim_lsp = true;
 | 
			
		||||
    calc = true;
 | 
			
		||||
    spell = true;
 | 
			
		||||
    treesitter = true;
 | 
			
		||||
    nvim_lua = true;
 | 
			
		||||
    vsnip = true;
 | 
			
		||||
  };
 | 
			
		||||
local servers = { "ccls", "rust_analyzer", "tsserver", "hls", "pylsp", "texlab", "rnix", "terraform_lsp" }
 | 
			
		||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
 | 
			
		||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
 | 
			
		||||
capabilities.textDocument.completion.completionItem.resolveSupport = {
 | 
			
		||||
  properties = {
 | 
			
		||||
    'documentation',
 | 
			
		||||
    'detail',
 | 
			
		||||
    'additionalTextEdits',
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local t = function(str)
 | 
			
		||||
  return vim.api.nvim_replace_termcodes(str, true, true, true)
 | 
			
		||||
local nvimlsp = require('lspconfig')
 | 
			
		||||
for _, lsp in ipairs(servers) do
 | 
			
		||||
  nvimlsp[lsp].setup { capabilities = capabilities, on_attach = on_attach }
 | 
			
		||||
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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
local luasnip = require 'luasnip'
 | 
			
		||||
local cmp = require 'cmp'
 | 
			
		||||
cmp.setup {
 | 
			
		||||
  snippet = {
 | 
			
		||||
    expand = function(args)
 | 
			
		||||
      require('luasnip').lsp_expand(args.body)
 | 
			
		||||
    end,
 | 
			
		||||
  },
 | 
			
		||||
  mapping = {
 | 
			
		||||
    ['<C-e>'] = cmp.mapping.select_prev_item(),
 | 
			
		||||
    ['<C-n>'] = cmp.mapping.select_next_item(),
 | 
			
		||||
    ['<C-p>'] = cmp.mapping.scroll_docs(-4),
 | 
			
		||||
    ['<C-f>'] = cmp.mapping.scroll_docs(4),
 | 
			
		||||
    ['<C-Space>'] = cmp.mapping.complete(),
 | 
			
		||||
    ['<C-q>'] = cmp.mapping.close(),
 | 
			
		||||
    ['<CR>'] = cmp.mapping.confirm {
 | 
			
		||||
      behavior = cmp.ConfirmBehavior.Replace,
 | 
			
		||||
      select = true,
 | 
			
		||||
    },
 | 
			
		||||
    ['<Tab>'] = function(fallback)
 | 
			
		||||
      if cmp.visible() then
 | 
			
		||||
        cmp.select_next_item()
 | 
			
		||||
      elseif luasnip.expand_or_jumpable() then
 | 
			
		||||
        luasnip.expand_or_jump()
 | 
			
		||||
      else
 | 
			
		||||
        fallback()
 | 
			
		||||
      end
 | 
			
		||||
    end,
 | 
			
		||||
    ['<S-Tab>'] = function(fallback)
 | 
			
		||||
      if cmp.visible() then
 | 
			
		||||
        cmp.select_prev_item()
 | 
			
		||||
      elseif luasnip.jumpable(-1) then
 | 
			
		||||
        luasnip.jump(-1)
 | 
			
		||||
      else
 | 
			
		||||
        fallback()
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
    },
 | 
			
		||||
    sources = {
 | 
			
		||||
      { name = 'nvim_lsp'},
 | 
			
		||||
      { name = 'path'},
 | 
			
		||||
      { name = 'nvim_lua'},
 | 
			
		||||
      { name = 'luasnip'},
 | 
			
		||||
      { name = 'calc'},
 | 
			
		||||
      { name = 'emoji'},
 | 
			
		||||
      { name = 'buffer'},
 | 
			
		||||
      { name = 'look'},
 | 
			
		||||
    },
 | 
			
		||||
    formatting = {
 | 
			
		||||
      format = require('lspkind').cmp_format({
 | 
			
		||||
        with_text = true,
 | 
			
		||||
        menu = ({
 | 
			
		||||
          buffer = "[Buffer]",
 | 
			
		||||
          nvim_lsp = "[LSP]",
 | 
			
		||||
          luasnip = "[LuaSnip]",
 | 
			
		||||
          nvim_lua = "[Lua]",
 | 
			
		||||
          latex_symbols = "[Latex]",
 | 
			
		||||
        })
 | 
			
		||||
      }),
 | 
			
		||||
    },
 | 
			
		||||
}
 | 
			
		||||
  cmp.setup.cmdline('/', {
 | 
			
		||||
    sources = {
 | 
			
		||||
      { name = 'buffer' }
 | 
			
		||||
    }
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
vim.g.vsnip_snippet_dir = "/home/natto/.vsnip"
 | 
			
		||||
-- 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 vim.fn.call("vsnip#available", {1}) == 1 then
 | 
			
		||||
    return t "<Plug>(vsnip-expand-or-jump)"
 | 
			
		||||
  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-e>"
 | 
			
		||||
  elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then
 | 
			
		||||
    return t "<Plug>(vsnip-jump-prev)"
 | 
			
		||||
  else
 | 
			
		||||
    -- If <S-Tab> is not working in your terminal, change it to <C-h>
 | 
			
		||||
    return t "<S-Tab>"
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
  -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
 | 
			
		||||
  cmp.setup.cmdline(':', {
 | 
			
		||||
    sources = cmp.config.sources({
 | 
			
		||||
      { name = 'path' }
 | 
			
		||||
    }, {
 | 
			
		||||
      { name = 'cmdline' }
 | 
			
		||||
    })
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
bind("i", "<Tab>", "v:lua.tab_complete()", {expr = true, silent = true})
 | 
			
		||||
bind("s", "<Tab>", "v:lua.tab_complete()", {expr = true, silent = true})
 | 
			
		||||
bind("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true, silent = true})
 | 
			
		||||
bind("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true, silent = true})
 | 
			
		||||
bind("i", "<CR>", "compe#confirm('<CR>')", {expr = true, silent = true})
 | 
			
		||||
--bind("i", "<Tab>", "v:lua.tab_complete()", {expr = true, silent = true})
 | 
			
		||||
--bind("s", "<Tab>", "v:lua.tab_complete()", {expr = true, silent = true})
 | 
			
		||||
--bind("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true, silent = true})
 | 
			
		||||
--bind("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true, silent = true})
 | 
			
		||||
--bind("i", "<CR>", "compe#confirm('<CR>')", {expr = true, silent = true})
 | 
			
		||||
 | 
			
		||||
comm("set shortmess+=c")
 | 
			
		||||
 | 
			
		||||
@@ -340,21 +362,6 @@ local statusline = {
 | 
			
		||||
}
 | 
			
		||||
vim.o.statusline = table.concat(statusline)
 | 
			
		||||
 | 
			
		||||
local servers = { "ccls", "rust_analyzer", "tsserver", "hls", "pylsp", "texlab", "rnix", "terraform_lsp" }
 | 
			
		||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
 | 
			
		||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
 | 
			
		||||
capabilities.textDocument.completion.completionItem.resolveSupport = {
 | 
			
		||||
  properties = {
 | 
			
		||||
    'documentation',
 | 
			
		||||
    'detail',
 | 
			
		||||
    'additionalTextEdits',
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
local nvimlsp = require('lspconfig')
 | 
			
		||||
for _, lsp in ipairs(servers) do
 | 
			
		||||
  nvimlsp[lsp].setup { capabilities = capabilities, on_attach = on_attach }
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
vim.g.tex_flavor = "latex"
 | 
			
		||||
comm("set syntax=off")
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user