Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusandre committed May 16, 2024
1 parent 7240967 commit d285eb0
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 62 deletions.
1 change: 1 addition & 0 deletions nvim/lazy-lock.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"LuaSnip": { "branch": "master", "commit": "78296bfabf756dbb6c7134aa219e75564dddf40f" },
"SchemaStore.nvim": { "branch": "main", "commit": "3c32d6a7bc56d56d4e3cc16fb21b59465a527aeb" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
Expand Down
5 changes: 5 additions & 0 deletions nvim/lua/m/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ vim.opt.listchars = {
-- Preview substitutions live, as you type!
vim.opt.inccommand = 'split'

-- Completion Settings
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
---@diagnostic disable-next-line: param-type-mismatch
vim.opt.shortmess:append('c')

-- Show which line your cursor is on
vim.opt.cursorline = true

Expand Down
108 changes: 46 additions & 62 deletions nvim/lua/plugins/cmp.lua
Original file line number Diff line number Diff line change
@@ -1,85 +1,69 @@
return {
'hrsh7th/nvim-cmp',
event = 'InsertEnter',
lazy = false,
priority = 100,
dependencies = {
{
'L3MON4D3/LuaSnip',
build = (function()
if vim.fn.has('win32') == 1 then return end
return 'make install_jsregexp'
end)(),
},
'saadparwaiz1/cmp_luasnip',

-- Completion capabilities.
'hrsh7th/cmp-nvim-lsp',
-- sources
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-path',

-- Pre-configured snippets
-- snippets
{ 'L3MON4D3/LuaSnip', build = 'make install_jsregexp' },
'saadparwaiz1/cmp_luasnip',
'rafamadriz/friendly-snippets',

-- Further information for cmp list
-- icons
'onsails/lspkind.nvim',
},
config = function()
local cmp = require('cmp')
local luasnip = require('luasnip')
local lspkind = require('lspkind')
luasnip.config.setup({})
lspkind.init()

require('luasnip.loaders.from_vscode').load()
local cmp = require('cmp')

cmp.setup({
snippet = {
expand = function(args) luasnip.lsp_expand(args.body) end,
},
completion = { completeopt = 'menu,menuone,noinsert' },
formatting = {
format = lspkind.cmp_format({}),
},

mapping = cmp.mapping.preset.insert({
['<C-Space>'] = cmp.mapping.complete({}),
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
-- ['<C-n>'] = cmp.mapping.select_next_item(),
-- ['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-y>'] = cmp.mapping.confirm({ select = true }),
['<C-l>'] = cmp.mapping(function()
if luasnip.expand_or_locally_jumpable() then luasnip.expand_or_jump() end
end, { 'i', 's' }),
['<C-h>'] = cmp.mapping(function()
if luasnip.locally_jumpable(-1) then luasnip.jump(-1) end
end, { 'i', 's' }),
['<C-n>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { 'i', 's' }),
['<C-p>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { 'i', 's' }),
}),
sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'path' },
{ name = 'buffer', keyword_length = 3 },
{ name = 'buffer' },
},
experimental = {
ghost_text = true,
mapping = {
['<C-n>'] = cmp.mapping.select_next_item({
behavior = cmp.SelectBehavior.Insert,
}),
['<C-p>'] = cmp.mapping.select_prev_item({
behavior = cmp.SelectBehavior.Insert,
}),
['<C-y>'] = cmp.mapping(
cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true,
}),
{ 'i', 'c' }
),
},
snippet = {
expand = function(args) require('luasnip').lsp_expand(args.body) end,
},
})

local ls = require('luasnip')
ls.config.set_config({
history = false,
updateevents = 'TextChanged,TextChangedI',
})

-- for _, ft_path in ipairs(vim.api.nvim_get_runtime_file('lua/custom/snippets/*.lua', true)) do
-- loadfile(ft_path)()
-- end

vim.keymap.set({ 'i', 's' }, '<c-k>', function()
if ls.expand_or_jumpable() then ls.expand_or_jump() end
end, { silent = true })

vim.keymap.set({ 'i', 's' }, '<c-j>', function()
if ls.jumpable(-1) then ls.jump(-1) end
end, { silent = true })
end,
}
26 changes: 26 additions & 0 deletions nvim/lua/plugins/lspconfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ return { -- LSP Configuration & Plugins
-- Depend on Telescope for keybindings
'nvim-telescope/telescope.nvim',

-- Schema information
'b0o/SchemaStore.nvim',

-- Useful status updates for LSP.
{ 'j-hui/fidget.nvim', opts = {} },
},
Expand All @@ -22,6 +25,8 @@ return { -- LSP Configuration & Plugins
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('man-lsp-attach', { clear = true }),
callback = function(event)
vim.opt_local.omnifunc = 'v:lua.vim.lsp.omnifunc'

local map = function(keys, func, desc) vim.keymap.set('n', keys, func, { buffer = event.buf, desc = desc }) end

map('<leader>lS', builtin.lsp_dynamic_workspace_symbols, 'Workspace Symbols')
Expand Down Expand Up @@ -141,6 +146,27 @@ return { -- LSP Configuration & Plugins
},
},

jsonls = {
settings = {
json = {
schemas = require('schemastore').json.schemas(),
validate = { enable = true },
},
},
},

yamlls = {
settings = {
yaml = {
schemaStore = {
enable = false,
url = '',
},
schemas = require('schemastore').yaml.schemas(),
},
},
},

eslint = {
on_attach = function(_, bufnr)
vim.api.nvim_create_autocmd('BufWritePre', {
Expand Down

0 comments on commit d285eb0

Please sign in to comment.