Corrections suite MAJ plugins
This commit is contained in:
@@ -1,80 +1,41 @@
|
||||
local has_words_before = function()
|
||||
unpack = unpack or table.unpack
|
||||
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 luasnip = require("luasnip")
|
||||
local cmp = require("cmp")
|
||||
local cmp = require('cmp')
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
-- REQUIRED - you must specify a snippet engine
|
||||
expand = function(args)
|
||||
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
||||
require('luasnip').lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
-- Use <C-b/f> to scroll the docs
|
||||
['<C-b>'] = cmp.mapping.scroll_docs( -4),
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
-- Use <C-k/j> to switch in items
|
||||
['<C-k>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-j>'] = cmp.mapping.select_next_item(),
|
||||
-- Use <CR>(Enter) to confirm selection
|
||||
-- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||
|
||||
-- A super tab
|
||||
-- sourc: https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#luasnip
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
-- Hint: if the completion menu is visible select next one
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }), -- i - insert mode; s - select mode
|
||||
["<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" }),
|
||||
['<Tab>'] = cmp.mapping.select_next_item(),
|
||||
['<S-Tab>'] = cmp.mapping.select_prev_item(),
|
||||
}),
|
||||
|
||||
-- Let's configure the item's appearance
|
||||
-- source: https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance
|
||||
formatting = {
|
||||
-- Set order from left to right
|
||||
-- kind: single letter indicating the type of completion
|
||||
-- abbr: abbreviation of "word"; when not empty it is used in the menu instead of "word"
|
||||
-- menu: extra text for the popup menu, displayed after "word" or "abbr"
|
||||
fields = { 'abbr', 'menu' },
|
||||
|
||||
-- customize the appearance of the completion menu
|
||||
format = function(entry, vim_item)
|
||||
vim_item.menu = ({
|
||||
nvim_lsp = '[Lsp]',
|
||||
luasnip = '[Luasnip]',
|
||||
buffer = '[File]',
|
||||
path = '[Path]',
|
||||
})[entry.source.name]
|
||||
return vim_item
|
||||
end,
|
||||
},
|
||||
|
||||
-- Set source precedence
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' }, -- For nvim-lsp
|
||||
{ name = 'luasnip' }, -- For luasnip user
|
||||
{ name = 'buffer' }, -- For buffer word completion
|
||||
{ name = 'path' }, -- For path completion
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' },
|
||||
}, {
|
||||
{ name = 'path' },
|
||||
})
|
||||
})
|
||||
|
||||
-- Configuration pour la ligne de commande
|
||||
cmp.setup.cmdline({ '/', '?' }, {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = 'buffer' }
|
||||
}
|
||||
})
|
||||
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }
|
||||
}, {
|
||||
{ name = 'cmdline' }
|
||||
})
|
||||
})
|
||||
|
||||
35
lua/lsp.lua
35
lua/lsp.lua
@@ -1,16 +1,25 @@
|
||||
require('mason').setup({
|
||||
ui = {
|
||||
icons = {
|
||||
package_installed = "✓",
|
||||
package_pending = "➜",
|
||||
package_uninstalled = "✗"
|
||||
}
|
||||
require('mason').setup()
|
||||
|
||||
-- Charger nvim-cmp en premier
|
||||
require('config.nvim-cmp')
|
||||
|
||||
local lspconfig = require('lspconfig')
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
|
||||
-- Configuration LSP
|
||||
lspconfig.lua_ls.setup({
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = { version = 'LuaJIT' },
|
||||
diagnostics = { globals = { 'vim' } },
|
||||
workspace = {
|
||||
library = vim.api.nvim_get_runtime_file("", true),
|
||||
checkThirdParty = false,
|
||||
},
|
||||
telemetry = { enable = false },
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
require('mason-lspconfig').setup({
|
||||
-- A list of servers to automatically install if they're not already installed
|
||||
ensure_installed = { 'pylsp', 'gopls', 'lua_ls', 'rust_analyzer', 'clangd' },
|
||||
})
|
||||
|
||||
|
||||
print("LSP with nvim-cmp loaded successfully")
|
||||
|
||||
@@ -32,43 +32,47 @@ vim.cmd([[
|
||||
-- ft = string or list, -- Specifies filetypes which load this plugin.
|
||||
-- run = string, function, or table, -- Specify operations to be run after successful installs/updates of a plugin
|
||||
return require('packer').startup(function(use)
|
||||
-- Packer can manage itself
|
||||
use 'wbthomason/packer.nvim'
|
||||
use 'tanvirtin/monokai.nvim'
|
||||
|
||||
-- LSP
|
||||
use { 'neovim/nvim-lspconfig' }
|
||||
use {
|
||||
"williamboman/mason.nvim",
|
||||
run = ":MasonUpdate" -- :MasonUpdate updates registry contents
|
||||
run = ":MasonUpdate"
|
||||
}
|
||||
use { 'williamboman/mason-lspconfig.nvim'}
|
||||
|
||||
use { 'neovim/nvim-lspconfig' }
|
||||
use { 'hrsh7th/nvim-cmp', config = [[require('config.nvim-cmp')]] }
|
||||
use { 'hrsh7th/cmp-nvim-lsp', after = 'nvim-cmp' }
|
||||
--use { 'hrsh7th/cmp-buffer', after = 'nvim-cmp' } -- buffer auto-completion
|
||||
use { 'hrsh7th/cmp-path', after = 'nvim-cmp' } -- path auto-completion
|
||||
use { 'hrsh7th/cmp-cmdline', after = 'nvim-cmp' } -- cmdline auto-completion
|
||||
-- Complétion - UNE SEULE déclaration de chaque plugin
|
||||
use 'hrsh7th/nvim-cmp'
|
||||
use 'hrsh7th/cmp-nvim-lsp'
|
||||
use 'hrsh7th/cmp-path'
|
||||
use 'hrsh7th/cmp-cmdline'
|
||||
use 'L3MON4D3/LuaSnip'
|
||||
use 'saadparwaiz1/cmp_luasnip'
|
||||
|
||||
-- Autres plugins
|
||||
use({
|
||||
"iamcco/markdown-preview.nvim",
|
||||
run = function() vim.fn["mkdp#util#install"]() end,
|
||||
})
|
||||
|
||||
-- File manager
|
||||
use {
|
||||
"luukvbaal/nnn.nvim",
|
||||
config = function() require("nnn").setup() end
|
||||
}
|
||||
|
||||
use { 'https://git.richoux.me/tfa/vim-log-highlighting', after = 'nvim-cmp' } -- cmdline auto-completion
|
||||
|
||||
use { 'https://git.plop.me/tfa/vim-log-highlighting' }
|
||||
use 'mzlogin/vim-markdown-toc'
|
||||
use 'dpelle/vim-LanguageTool'
|
||||
use {
|
||||
'hat0uma/csvview.nvim',
|
||||
config = function()
|
||||
require('csvview').setup({
|
||||
quote_char = '"',
|
||||
separator = ',',
|
||||
})
|
||||
end
|
||||
}
|
||||
|
||||
-- Automatically set up your configuration after cloning packer.nvim
|
||||
-- Put this at the end after all plugins
|
||||
if packer_bootstrap then
|
||||
require('packer').sync()
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user