summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.config/nvim/init.vim18
-rw-r--r--.config/nvim/lua/lsp_conf.lua50
2 files changed, 63 insertions, 5 deletions
diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim
index 063a8f8..0007a52 100644
--- a/.config/nvim/init.vim
+++ b/.config/nvim/init.vim
@@ -24,14 +24,22 @@ Plug 'matze/vim-move'
Plug 'togglebyte/togglerust' " Debug Rust projects
+Plug 'chriskempson/base16-vim'
+
if has('nvim')
- Plug 'rktjmp/lush.nvim'
+ " Plug 'rktjmp/lush.nvim'
Plug 'dcariotti/gruvbox.nvim'
Plug 'nvim-telescope/telescope.nvim'
Plug 'neovim/nvim-lspconfig'
- Plug 'ms-jpq/coq_nvim', {'branch': 'coq'}
- Plug 'ms-jpq/coq.artifacts', {'branch': 'artifacts'}
+
+ Plug 'hrsh7th/nvim-cmp'
+ Plug 'hrsh7th/cmp-nvim-lsp'
+ Plug 'saadparwaiz1/cmp_luasnip'
+ Plug 'L3MON4D3/LuaSnip'
+
+ " Plug 'ms-jpq/coq_nvim', {'branch': 'coq'}
+ " Plug 'ms-jpq/coq.artifacts', {'branch': 'artifacts'}
Plug 'kyazdani42/nvim-tree.lua'
Plug 'ray-x/lsp_signature.nvim'
Plug 'folke/todo-comments.nvim'
@@ -45,6 +53,7 @@ if has('nvim')
Plug 'folke/trouble.nvim'
Plug 'folke/lsp-colors.nvim'
+
Plug 'sindrets/diffview.nvim'
Plug 'windwp/nvim-ts-autotag'
@@ -116,6 +125,9 @@ set background=dark
if has('nvim')
colorscheme gruvbox
+ " let base16colorspace=256
+ " colorscheme base16-irblack
+
lua require('git')
let g:coq_settings = { 'auto_start': v:true }
lua require('lsp_conf')
diff --git a/.config/nvim/lua/lsp_conf.lua b/.config/nvim/lua/lsp_conf.lua
index a64839e..36b6735 100644
--- a/.config/nvim/lua/lsp_conf.lua
+++ b/.config/nvim/lua/lsp_conf.lua
@@ -1,5 +1,8 @@
local nvim_lsp = require('lspconfig')
-local coq = require('coq')
+-- local coq = require('coq')
+--
+
+local capabilities = require("cmp_nvim_lsp").default_capabilities()
local null_ls = require("null-ls")
local trouble = require("trouble")
@@ -48,6 +51,7 @@ local common_on_attach = function(client, bufnr)
-- Mappings.
vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
+ vim.api.nvim_buf_set_keymap(bufnr, "n", "ga", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "<space>e", "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", opts)
@@ -57,7 +61,7 @@ end
local servers = { 'pyright', 'rust_analyzer', 'tsserver', 'clangd' }
-local capabilities = vim.lsp.protocol.make_client_capabilities()
+-- local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.offsetEncoding = { "utf-16" }
for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup {
@@ -75,3 +79,45 @@ trouble.setup({
auto_open = false
})
+
+-- nvim-cmp setup
+local luasnip = require 'luasnip'
+local cmp = require 'cmp'
+cmp.setup {
+ snippet = {
+ expand = function(args)
+ luasnip.lsp_expand(args.body)
+ end,
+ },
+ mapping = cmp.mapping.preset.insert({
+ ['<C-d>'] = cmp.mapping.scroll_docs(-4),
+ ['<C-f>'] = cmp.mapping.scroll_docs(4),
+ ['<C-Space>'] = cmp.mapping.complete(),
+ ['<CR>'] = cmp.mapping.confirm {
+ behavior = cmp.ConfirmBehavior.Replace,
+ 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()
+ 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 = {
+ { name = 'nvim_lsp' },
+ { name = 'luasnip' },
+ },
+}