luasnip
This commit is contained in:
parent
8b4719f8a9
commit
5e2503b12a
34
init.lua
34
init.lua
|
|
@ -692,7 +692,9 @@ do
|
||||||
-- See `:help lsp-config` for information about keys and how to configure
|
-- See `:help lsp-config` for information about keys and how to configure
|
||||||
---@type table<string, vim.lsp.Config>
|
---@type table<string, vim.lsp.Config>
|
||||||
local servers = {
|
local servers = {
|
||||||
-- clangd = {},
|
clangd = {
|
||||||
|
cmd = { 'clangd', '--background-index' },
|
||||||
|
},
|
||||||
-- gopls = {},
|
-- gopls = {},
|
||||||
-- pyright = {},
|
-- pyright = {},
|
||||||
-- rust_analyzer = {},
|
-- rust_analyzer = {},
|
||||||
|
|
@ -824,6 +826,11 @@ do
|
||||||
default_format_opts = {
|
default_format_opts = {
|
||||||
lsp_format = 'fallback', -- Use external formatters if configured below, otherwise use LSP formatting. Set to `false` to disable LSP formatting entirely.
|
lsp_format = 'fallback', -- Use external formatters if configured below, otherwise use LSP formatting. Set to `false` to disable LSP formatting entirely.
|
||||||
},
|
},
|
||||||
|
formatters = {
|
||||||
|
['pretty-php'] = {
|
||||||
|
prepend_args = { '-s2' },
|
||||||
|
},
|
||||||
|
},
|
||||||
-- You can also specify external formatters in here.
|
-- You can also specify external formatters in here.
|
||||||
formatters_by_ft = {
|
formatters_by_ft = {
|
||||||
-- rust = { 'rustfmt' },
|
-- rust = { 'rustfmt' },
|
||||||
|
|
@ -872,12 +879,20 @@ do
|
||||||
vim.pack.add { { src = gh 'L3MON4D3/LuaSnip', version = vim.version.range '2.*' } }
|
vim.pack.add { { src = gh 'L3MON4D3/LuaSnip', version = vim.version.range '2.*' } }
|
||||||
require('luasnip').setup {}
|
require('luasnip').setup {}
|
||||||
|
|
||||||
|
local ls = require 'luasnip'
|
||||||
|
ls.config.set_config {
|
||||||
|
store_selection_keys = '<tab>',
|
||||||
|
}
|
||||||
|
ls.filetype_extend('svelte', { 'typescript', 'html' })
|
||||||
|
|
||||||
-- `friendly-snippets` contains a variety of premade snippets.
|
-- `friendly-snippets` contains a variety of premade snippets.
|
||||||
-- See the README about individual language/framework/plugin snippets:
|
-- See the README about individual language/framework/plugin snippets:
|
||||||
-- https://github.com/rafamadriz/friendly-snippets
|
-- https://github.com/rafamadriz/friendly-snippets
|
||||||
--
|
--
|
||||||
-- vim.pack.add { gh 'rafamadriz/friendly-snippets' }
|
-- vim.pack.add { gh 'rafamadriz/friendly-snippets' }
|
||||||
-- require('luasnip.loaders.from_vscode').lazy_load()
|
require('luasnip.loaders.from_vscode').load {
|
||||||
|
paths = { '~/git/friendly-snippets' },
|
||||||
|
}
|
||||||
|
|
||||||
-- [[ Autocomplete Engine ]]
|
-- [[ Autocomplete Engine ]]
|
||||||
vim.pack.add { { src = gh 'saghen/blink.cmp', version = vim.version.range '1.*' } }
|
vim.pack.add { { src = gh 'saghen/blink.cmp', version = vim.version.range '1.*' } }
|
||||||
|
|
@ -940,6 +955,19 @@ do
|
||||||
-- Shows a signature help window while you type arguments for a function
|
-- Shows a signature help window while you type arguments for a function
|
||||||
signature = { enabled = true },
|
signature = { enabled = true },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- Luasnip choice node navigation
|
||||||
|
vim.keymap.set({ 'i', 's' }, '<C-l>', function()
|
||||||
|
if require('luasnip').choice_active() then
|
||||||
|
require('luasnip').change_choice(1)
|
||||||
|
end
|
||||||
|
end, { desc = 'LuaSnip: next choice' })
|
||||||
|
|
||||||
|
vim.keymap.set({ 'i', 's' }, '<C-h>', function()
|
||||||
|
if require('luasnip').choice_active() then
|
||||||
|
require('luasnip').change_choice(-1)
|
||||||
|
end
|
||||||
|
end, { desc = 'LuaSnip: previous choice' })
|
||||||
end
|
end
|
||||||
|
|
||||||
-- ============================================================
|
-- ============================================================
|
||||||
|
|
@ -955,6 +983,8 @@ do
|
||||||
-- NOTE: You can also specify a branch or a specific commit
|
-- NOTE: You can also specify a branch or a specific commit
|
||||||
vim.pack.add { { src = gh 'nvim-treesitter/nvim-treesitter', version = 'main' } }
|
vim.pack.add { { src = gh 'nvim-treesitter/nvim-treesitter', version = 'main' } }
|
||||||
|
|
||||||
|
require('nvim-treesitter.install').compilers = { 'clang', 'gcc', 'zig' }
|
||||||
|
|
||||||
-- Ensure basic parsers are installed
|
-- Ensure basic parsers are installed
|
||||||
local parsers = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }
|
local parsers = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }
|
||||||
require('nvim-treesitter').install(parsers)
|
require('nvim-treesitter').install(parsers)
|
||||||
|
|
|
||||||
|
|
@ -126,4 +126,42 @@ vim.opt.sessionoptions = {
|
||||||
'terminal', -- save terminal state
|
'terminal', -- save terminal state
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
-- Folding
|
||||||
|
vim.o.foldmethod = 'indent'
|
||||||
|
|
||||||
|
-- Save folds between sessions
|
||||||
|
local viewdir = vim.fn.stdpath 'state' .. '/view'
|
||||||
|
vim.o.viewdir = viewdir
|
||||||
|
vim.o.viewoptions = 'cursor,folds'
|
||||||
|
vim.fn.mkdir(viewdir, 'p')
|
||||||
|
|
||||||
|
-- Close certain windows with x
|
||||||
|
vim.api.nvim_create_autocmd('FileType', {
|
||||||
|
pattern = { 'checkhealth', 'fugitive*', 'git', 'help', 'lspinfo', 'netrw', 'notify', 'qf', 'query' },
|
||||||
|
callback = function()
|
||||||
|
vim.keymap.set('n', 'x', vim.cmd.close, {
|
||||||
|
desc = 'Close the current buffer',
|
||||||
|
buffer = true,
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Remember folds between sessions
|
||||||
|
vim.api.nvim_create_augroup('remember_folds', { clear = true })
|
||||||
|
vim.api.nvim_create_autocmd('BufWinLeave', {
|
||||||
|
group = 'remember_folds',
|
||||||
|
pattern = '*',
|
||||||
|
callback = function()
|
||||||
|
vim.cmd 'silent! mkview'
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
vim.api.nvim_create_autocmd('BufWinEnter', {
|
||||||
|
group = 'remember_folds',
|
||||||
|
pattern = '*',
|
||||||
|
callback = function()
|
||||||
|
pcall(vim.cmd, 'silent! loadview')
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
return {}
|
return {}
|
||||||
Loading…
Reference in New Issue