Added cmp stuff and drag binds

This commit is contained in:
Thomas Muller 2024-06-14 15:33:56 -04:00
parent 4b8c565254
commit fd24df3d2c

View file

@ -20,8 +20,11 @@ Plug 'powerman/vim-plugin-AnsiEsc'
Plug 'neovim/nvim-lspconfig' Plug 'neovim/nvim-lspconfig'
Plug 'williamboman/mason.nvim' Plug 'williamboman/mason.nvim'
Plug 'williamboman/mason-lspconfig.nvim' Plug 'williamboman/mason-lspconfig.nvim'
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-nvim-lsp' Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/cmp-cmdline'
Plug 'hrsh7th/nvim-cmp'
Plug 'L3MON4D3/LuaSnip' Plug 'L3MON4D3/LuaSnip'
Plug 'VonHeikemen/lsp-zero.nvim', {'branch': 'v3.x'} Plug 'VonHeikemen/lsp-zero.nvim', {'branch': 'v3.x'}
@ -31,6 +34,7 @@ Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.6' }
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'nvim-treesitter/nvim-treesitter-context' Plug 'nvim-treesitter/nvim-treesitter-context'
Plug 'nvim-treesitter/playground'
Plug 'mbbill/undotree' Plug 'mbbill/undotree'
Plug 'tpope/vim-fugitive' Plug 'tpope/vim-fugitive'
@ -44,7 +48,7 @@ call plug#end()
" ----[NVim LSPConfig]---- " ----[NVim LSPConfig]----
lua << EOF lua << EOF
local lsp = require 'lspconfig' local lsp = require 'lspconfig'
local qt_uic = require 'qt_uic' -- local qt_uic = require 'qt_uic'
-- local coq = require 'coq' -- local coq = require 'coq'
-- lsp.cmake.setup{} -- lsp.cmake.setup{}
@ -54,38 +58,85 @@ local qt_uic = require 'qt_uic'
-- lsp.cmake.setup{coq.lsp_ensure_capabilities{}} -- lsp.cmake.setup{coq.lsp_ensure_capabilities{}}
-- lsp.pyright.setup{coq.lsp_ensure_capabilities{}} -- lsp.pyright.setup{coq.lsp_ensure_capabilities{}}
local lsp_zero = require('lsp-zero') local lsp_zero = require('lsp-zero')
lsp_zero.on_attach(function(client, bufnr) lsp_zero.on_attach(function(client, bufnr)
-- see :help lsp-zero-keybindings -- see :help lsp-zero-keybindings
-- to learn the available actions -- to learn the available actions
lsp_zero.default_keymaps({buffer = bufnr}) lsp_zero.default_keymaps({buffer = bufnr})
end) end)
vim.diagnostic.config({ local cmp = require('cmp')
virtual_text = false local cmp_lsp = require("cmp_nvim_lsp")
}) local capabilities = vim.tbl_deep_extend(
"force",
{},
vim.lsp.protocol.make_client_capabilities(),
cmp_lsp.default_capabilities())
-- to learn how to use mason.nvim with lsp-zero -- to learn how to use mason.nvim with lsp-zero
-- read this: https://github.com/VonHeikemen/lsp-zero.nvim/blob/v3.x/doc/md/guides/integrate-with-mason-nvim.md -- read this: https://github.com/VonHeikemen/lsp-zero.nvim/blob/v3.x/doc/md/guides/integrate-with-mason-nvim.md
local lspconfig = require('lspconfig')
require('mason').setup({}) require('mason').setup({})
require('mason-lspconfig').setup({ require('mason-lspconfig').setup({
handlers = { handlers = {
function(server_name) function(server_name)
require('lspconfig')[server_name].setup({}) lspconfig[server_name].setup({capabilities=capabilities})
end,
['lua_ls'] = function()
lspconfig.lua_ls.setup {
capabilities = capabilities,
settings = {
Lua = {
runtime = { version = 'Lua 5.1' },
diagnostics = {
globals = { 'vim', 'it', 'describe', 'before_each', 'after_each' },
}
}
}
}
end, end,
} }
}) })
lsp.clangd.setup{} -- memes = vim.lsp.start_client({
lsp.cmake.setup{} -- name='qt_uic',
lsp.pyright.setup{} -- cmd={'python', 'lsptest.py'},
-- root_dir='/home/devnull'
-- })
-- qt_uic.setup{}
cmp.setup({
mapping = cmp.mapping.preset.insert({
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
['<tab>'] = cmp.mapping.select_next_item(cmp_select),
['<C-y>'] = cmp.mapping.confirm({ select = true }),
['<CR>'] = cmp.mapping.confirm({ select = true }),
['<C-Space>'] = cmp.mapping.complete(),
}),
sources = cmp.config.sources(
{
{ name = 'nvim_lsp' },
-- { name = 'qt_uic' },
}, {
{ name = 'buffer' },
}
)
})
-- lsp.clangd.setup{}
-- lsp.cmake.setup{}
-- lsp.pyright.setup{}
-- lsp.clangd.setup{coq.lsp_ensure_capabilities{}} -- lsp.clangd.setup{coq.lsp_ensure_capabilities{}}
-- lsp.cmake.setup{coq.lsp_ensure_capabilities{}} -- lsp.cmake.setup{coq.lsp_ensure_capabilities{}}
-- lsp.pyright.setup{coq.lsp_ensure_capabilities{}} -- lsp.pyright.setup{coq.lsp_ensure_capabilities{}}
lsp.pyright.setup{qt_uic.extend_lsp_completion{}}
require("nvim-treesitter.configs").setup({ require("nvim-treesitter.configs").setup({
-- A list of parser names, or "all" -- A list of parser names, or "all"
ensure_installed = { ensure_installed = {
@ -136,6 +187,10 @@ vim.keymap.set('n', '<leader>gs', vim.cmd.Git)
vim.opt.scrolloff = 8 vim.opt.scrolloff = 8
vim.opt.signcolumn = 'yes' vim.opt.signcolumn = 'yes'
vim.opt.isfname:append('@-@') vim.opt.isfname:append('@-@')
-- Dragging
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
EOF EOF
" ----[Look and Feel]---- " ----[Look and Feel]----