fix luasnip error
This commit is contained in:
parent
85ae713bf5
commit
4fdc9e9b88
190
init.lua
190
init.lua
@ -2,7 +2,7 @@ vim.g.mapleader = " "
|
|||||||
vim.g.maplocalleader = " "
|
vim.g.maplocalleader = " "
|
||||||
|
|
||||||
-- If possible use 24 Bit Colors
|
-- If possible use 24 Bit Colors
|
||||||
if vim.fn.has('termguicolors') == 1 then
|
if vim.fn.has("termguicolors") == 1 then
|
||||||
vim.o.termguicolors = true
|
vim.o.termguicolors = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ require("lazy").setup({
|
|||||||
keymap("n", "<leader>hu", "<cmd>Gitsigns undo_stage_hunk<CR>", "[h]unk [u]ndo stage")
|
keymap("n", "<leader>hu", "<cmd>Gitsigns undo_stage_hunk<CR>", "[h]unk [u]ndo stage")
|
||||||
keymap("n", "<leader>hR", "<cmd>Gitsigns reset_buffer<CR>", "[h]unk [R]eset buffer")
|
keymap("n", "<leader>hR", "<cmd>Gitsigns reset_buffer<CR>", "[h]unk [R]eset buffer")
|
||||||
keymap("n", "<leader>hp", "<cmd>Gitsigns preview_hunk<CR>", "[h]unk [p]review")
|
keymap("n", "<leader>hp", "<cmd>Gitsigns preview_hunk<CR>", "[h]unk [p]review")
|
||||||
keymap("n", '<leader>ht', '<cmd>Gitsigns toggle_deleted<CR>', "[h]unk [t]oggle deleted")
|
keymap("n", "<leader>ht", "<cmd>Gitsigns toggle_deleted<CR>", "[h]unk [t]oggle deleted")
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -402,12 +402,12 @@ require("lazy").setup({
|
|||||||
|
|
||||||
-- TODO: Setup DAP
|
-- TODO: Setup DAP
|
||||||
-- use { "mfussenegger/nvim-dap", config_name="dap" }
|
-- use { "mfussenegger/nvim-dap", config_name="dap" }
|
||||||
-- use { "rcarriga/nvim-dap-ui", requires = "mfussenegger/nvim-dap", config=[[require('dapui').setup()]] }
|
-- use { "rcarriga/nvim-dap-ui", requires = "mfussenegger/nvim-dap", config=[[require("dapui").setup()]] }
|
||||||
-- use 'simrat39/rust-tools.nvim'
|
-- use "simrat39/rust-tools.nvim"
|
||||||
-- use {
|
-- use {
|
||||||
-- 'theHamsta/nvim-dap-virtual-text',
|
-- "theHamsta/nvim-dap-virtual-text",
|
||||||
-- requires = {"mfussenegger/nvim-dap", "nvim-treesitter/nvim-treesitter"},
|
-- requires = {"mfussenegger/nvim-dap", "nvim-treesitter/nvim-treesitter"},
|
||||||
-- config=[[require('nvim-dap-virtual-text')]]
|
-- config=[[require("nvim-dap-virtual-text")]]
|
||||||
-- }
|
-- }
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -464,7 +464,7 @@ do
|
|||||||
-- pattern = {"*"},
|
-- pattern = {"*"},
|
||||||
-- callback = function()
|
-- callback = function()
|
||||||
-- -- TODO: Port this to lua
|
-- -- TODO: Port this to lua
|
||||||
-- vim.cmd [[if mode() != 'c' | checktime | endif]]
|
-- vim.cmd [[if mode() != "c" | checktime | endif]]
|
||||||
-- end
|
-- end
|
||||||
-- })
|
-- })
|
||||||
-- vim.api.nvim_create_autocmd({"FileChangedShellPost"}, {
|
-- vim.api.nvim_create_autocmd({"FileChangedShellPost"}, {
|
||||||
@ -476,7 +476,7 @@ do
|
|||||||
-- end
|
-- end
|
||||||
-- })
|
-- })
|
||||||
-- autocmd("auto-reload", {
|
-- autocmd("auto-reload", {
|
||||||
-- [[FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif]],
|
-- [[FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != "c" | checktime | endif]],
|
||||||
-- [[FileChangedShellPost * echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None]]
|
-- [[FileChangedShellPost * echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None]]
|
||||||
-- }, true)
|
-- }, true)
|
||||||
end
|
end
|
||||||
@ -489,7 +489,7 @@ do
|
|||||||
vim.g.zig_fmt_autosave = 0
|
vim.g.zig_fmt_autosave = 0
|
||||||
|
|
||||||
-- Folding options
|
-- Folding options
|
||||||
vim.o.foldmethod = 'indent'
|
vim.o.foldmethod = "indent"
|
||||||
vim.o.foldlevelstart = 99
|
vim.o.foldlevelstart = 99
|
||||||
|
|
||||||
-- Identation/Tab settings
|
-- Identation/Tab settings
|
||||||
@ -540,13 +540,13 @@ do
|
|||||||
vim.wo.relativenumber = true
|
vim.wo.relativenumber = true
|
||||||
|
|
||||||
-- Enable mouse mode
|
-- Enable mouse mode
|
||||||
vim.o.mouse = 'a'
|
vim.o.mouse = "a"
|
||||||
|
|
||||||
-- Skip redrawing window while executing macro
|
-- Skip redrawing window while executing macro
|
||||||
vim.o.lazyredraw = true
|
vim.o.lazyredraw = true
|
||||||
|
|
||||||
-- Sync clipboard between OS and Neovim.
|
-- Sync clipboard between OS and Neovim.
|
||||||
vim.o.clipboard = 'unnamedplus'
|
vim.o.clipboard = "unnamedplus"
|
||||||
|
|
||||||
-- Enable break indent
|
-- Enable break indent
|
||||||
vim.o.breakindent = true
|
vim.o.breakindent = true
|
||||||
@ -555,7 +555,7 @@ do
|
|||||||
vim.o.undofile = true
|
vim.o.undofile = true
|
||||||
|
|
||||||
-- Keep signcolumn on by default
|
-- Keep signcolumn on by default
|
||||||
vim.wo.signcolumn = 'yes'
|
vim.wo.signcolumn = "yes"
|
||||||
|
|
||||||
-- Decrease update time
|
-- Decrease update time
|
||||||
vim.o.updatetime = 250
|
vim.o.updatetime = 250
|
||||||
@ -565,14 +565,14 @@ do
|
|||||||
vim.o.splitbelow = true
|
vim.o.splitbelow = true
|
||||||
vim.o.splitright = true
|
vim.o.splitright = true
|
||||||
|
|
||||||
-- By default don't wrap text
|
-- By default don"t wrap text
|
||||||
vim.o.wrap = false
|
vim.o.wrap = false
|
||||||
|
|
||||||
-- Remove cmdline when not used
|
-- Remove cmdline when not used
|
||||||
vim.o.cmdheight = 0
|
vim.o.cmdheight = 0
|
||||||
|
|
||||||
-- Set completeopt to have a better completion experience
|
-- Set completeopt to have a better completion experience
|
||||||
vim.o.completeopt = 'menuone,noselect'
|
vim.o.completeopt = "menuone,noselect"
|
||||||
|
|
||||||
-- Scale neovide a bit
|
-- Scale neovide a bit
|
||||||
if vim.g.neovide then
|
if vim.g.neovide then
|
||||||
@ -586,31 +586,31 @@ end
|
|||||||
do
|
do
|
||||||
-- Keymaps for better default experience
|
-- Keymaps for better default experience
|
||||||
-- See `:help vim.keymap.set()`
|
-- See `:help vim.keymap.set()`
|
||||||
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
|
vim.keymap.set({ "n", "v" }, "<Space>", "<Nop>", { silent = true })
|
||||||
|
|
||||||
-- Remap for dealing with word wrap
|
-- Remap for dealing with word wrap
|
||||||
vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
|
vim.keymap.set("n", "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
|
||||||
vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
|
vim.keymap.set("n", "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
|
||||||
|
|
||||||
-- Better movement between tabs
|
-- Better movement between tabs
|
||||||
vim.keymap.set('n', '<C-Left>', ':tabprevious<cr>', { silent = true })
|
vim.keymap.set("n", "<C-Left>", ":tabprevious<cr>", { silent = true })
|
||||||
vim.keymap.set('n', '<C-Right>', ':tabnext<cr>', { silent = true })
|
vim.keymap.set("n", "<C-Right>", ":tabnext<cr>", { silent = true })
|
||||||
|
|
||||||
-- Better indenting
|
-- Better indenting
|
||||||
vim.keymap.set('v', '<', '<gv')
|
vim.keymap.set("v", "<", "<gv")
|
||||||
vim.keymap.set('v', '>', '>gv')
|
vim.keymap.set("v", ">", ">gv")
|
||||||
|
|
||||||
-- Save file
|
-- Save file
|
||||||
vim.keymap.set('n', '<C-s>', ':w<cr>', { silent = true })
|
vim.keymap.set("n", "<C-s>", ":w<cr>", { silent = true })
|
||||||
|
|
||||||
-- Disable Ex mode
|
-- Disable Ex mode
|
||||||
vim.keymap.set('n', 'Q', '<nop>')
|
vim.keymap.set("n", "Q", "<nop>")
|
||||||
|
|
||||||
-- Window movement
|
-- Window movement
|
||||||
vim.keymap.set('n', '<c-h>', '<c-w>h')
|
vim.keymap.set("n", "<c-h>", "<c-w>h")
|
||||||
vim.keymap.set('n', '<c-j>', '<c-w>j')
|
vim.keymap.set("n", "<c-j>", "<c-w>j")
|
||||||
vim.keymap.set('n', '<c-k>', '<c-w>k')
|
vim.keymap.set("n", "<c-k>", "<c-w>k")
|
||||||
vim.keymap.set('n', '<c-l>', '<c-w>l')
|
vim.keymap.set("n", "<c-l>", "<c-w>l")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Change c file comment string
|
-- Change c file comment string
|
||||||
@ -642,23 +642,23 @@ vim.api.nvim_create_autocmd({ "BufWritePre" }, {
|
|||||||
-- Move between windows easier in terminal windows
|
-- Move between windows easier in terminal windows
|
||||||
function _G.set_terminal_keymaps()
|
function _G.set_terminal_keymaps()
|
||||||
local opts = {buffer = 0}
|
local opts = {buffer = 0}
|
||||||
vim.keymap.set('t', '<C-w>', [[<C-\><C-n>]], opts)
|
vim.keymap.set("t", "<C-w>", [[<C-\><C-n>]], opts)
|
||||||
vim.keymap.set('t', '<C-h>', [[<Cmd>wincmd h<CR>]], opts)
|
vim.keymap.set("t", "<C-h>", [[<Cmd>wincmd h<CR>]], opts)
|
||||||
vim.keymap.set('t', '<C-j>', [[<Cmd>wincmd j<CR>]], opts)
|
vim.keymap.set("t", "<C-j>", [[<Cmd>wincmd j<CR>]], opts)
|
||||||
vim.keymap.set('t', '<C-k>', [[<Cmd>wincmd k<CR>]], opts)
|
vim.keymap.set("t", "<C-k>", [[<Cmd>wincmd k<CR>]], opts)
|
||||||
vim.keymap.set('t', '<C-l>', [[<Cmd>wincmd l<CR>]], opts)
|
vim.keymap.set("t", "<C-l>", [[<Cmd>wincmd l<CR>]], opts)
|
||||||
end
|
end
|
||||||
vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()')
|
vim.cmd("autocmd! TermOpen term://* lua set_terminal_keymaps()")
|
||||||
|
|
||||||
-- [[ Highlight on yank ]]
|
-- [[ Highlight on yank ]]
|
||||||
-- See `:help vim.highlight.on_yank()`
|
-- See `:help vim.highlight.on_yank()`
|
||||||
local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true })
|
local highlight_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true })
|
||||||
vim.api.nvim_create_autocmd('TextYankPost', {
|
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.highlight.on_yank()
|
vim.highlight.on_yank()
|
||||||
end,
|
end,
|
||||||
group = highlight_group,
|
group = highlight_group,
|
||||||
pattern = '*',
|
pattern = "*",
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Add abbreviation for != => ~= in lua files
|
-- Add abbreviation for != => ~= in lua files
|
||||||
@ -672,7 +672,7 @@ vim.api.nvim_create_autocmd("BufEnter", {
|
|||||||
|
|
||||||
-- [[ Configure Treesitter ]]
|
-- [[ Configure Treesitter ]]
|
||||||
-- See `:help nvim-treesitter`
|
-- See `:help nvim-treesitter`
|
||||||
-- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}'
|
-- Defer Treesitter setup after first render to improve startup time of "nvim {filename}"
|
||||||
vim.defer_fn(function()
|
vim.defer_fn(function()
|
||||||
require("nvim-treesitter.configs").setup {
|
require("nvim-treesitter.configs").setup {
|
||||||
-- Add languages to be installed here that you want installed for treesitter
|
-- Add languages to be installed here that you want installed for treesitter
|
||||||
@ -740,65 +740,65 @@ vim.defer_fn(function()
|
|||||||
end, 0)
|
end, 0)
|
||||||
|
|
||||||
-- Diagnostic keymaps
|
-- Diagnostic keymaps
|
||||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
|
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, { desc = "Go to previous diagnostic message" })
|
||||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
|
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, { desc = "Go to next diagnostic message" })
|
||||||
--vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
|
vim.keymap.set("n", "<leader>dm", vim.diagnostic.open_float, { desc = "Open floating diagnostic message" })
|
||||||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
|
vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist, { desc = "Open diagnostics list" })
|
||||||
|
|
||||||
-- [[ Configure LSP ]]
|
-- [[ Configure LSP ]]
|
||||||
-- This function gets run when an LSP connects to a particular buffer.
|
-- This function gets run when an LSP connects to a particular buffer.
|
||||||
local on_attach = function(_, bufnr)
|
local on_attach = function(_, bufnr)
|
||||||
-- NOTE: Remember that lua is a real programming language, and as such it is possible
|
-- NOTE: Remember that lua is a real programming language, and as such it is possible
|
||||||
-- to define small helper and utility functions so you don't have to repeat yourself
|
-- to define small helper and utility functions so you don"t have to repeat yourself
|
||||||
-- many times.
|
-- many times.
|
||||||
--
|
--
|
||||||
-- In this case, we create a function that lets us more easily define mappings specific
|
-- In this case, we create a function that lets us more easily define mappings specific
|
||||||
-- for LSP related items. It sets the mode, buffer and description for us each time.
|
-- for LSP related items. It sets the mode, buffer and description for us each time.
|
||||||
local nmap = function(keys, func, desc)
|
local nmap = function(keys, func, desc)
|
||||||
if desc then
|
if desc then
|
||||||
desc = 'LSP: ' .. desc
|
desc = "LSP: " .. desc
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
|
vim.keymap.set("n", keys, func, { buffer = bufnr, desc = desc })
|
||||||
end
|
end
|
||||||
|
|
||||||
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
|
nmap("<leader>rn", vim.lsp.buf.rename, "[R]e[n]ame")
|
||||||
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
|
nmap("<leader>ca", vim.lsp.buf.code_action, "[C]ode [A]ction")
|
||||||
|
|
||||||
nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
|
nmap("gd", vim.lsp.buf.definition, "[G]oto [D]efinition")
|
||||||
nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
|
nmap("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences")
|
||||||
nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
|
nmap("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation")
|
||||||
nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
|
nmap("<leader>D", vim.lsp.buf.type_definition, "Type [D]efinition")
|
||||||
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
|
nmap("<leader>ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols")
|
||||||
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
|
nmap("<leader>ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols")
|
||||||
|
|
||||||
-- See `:help K` for why this keymap
|
-- See `:help K` for why this keymap
|
||||||
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
|
nmap("K", vim.lsp.buf.hover, "Hover Documentation")
|
||||||
--nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
|
--nmap("<C-k>", vim.lsp.buf.signature_help, "Signature Documentation")
|
||||||
|
|
||||||
-- Lesser used LSP functionality
|
-- Lesser used LSP functionality
|
||||||
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
|
nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
|
||||||
nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
|
nmap("<leader>wa", vim.lsp.buf.add_workspace_folder, "[W]orkspace [A]dd Folder")
|
||||||
nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
|
nmap("<leader>wr", vim.lsp.buf.remove_workspace_folder, "[W]orkspace [R]emove Folder")
|
||||||
nmap('<leader>wl', function()
|
nmap("<leader>wl", function()
|
||||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||||
end, '[W]orkspace [L]ist Folders')
|
end, "[W]orkspace [L]ist Folders")
|
||||||
|
|
||||||
-- Create a command `:Format` local to the LSP buffer
|
-- Create a command `:Format` local to the LSP buffer
|
||||||
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
|
vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_)
|
||||||
vim.lsp.buf.format()
|
vim.lsp.buf.format()
|
||||||
end, { desc = 'Format current buffer with LSP' })
|
end, { desc = "Format current buffer with LSP" })
|
||||||
end
|
end
|
||||||
|
|
||||||
-- document existing key chains
|
-- document existing key chains
|
||||||
require('which-key').register({
|
require("which-key").register({
|
||||||
['<leader>c'] = { name = '[C]ode', _ = 'which_key_ignore' },
|
["<leader>c"] = { name = "[C]ode", _ = "which_key_ignore" },
|
||||||
['<leader>d'] = { name = '[D]ocument', _ = 'which_key_ignore' },
|
["<leader>d"] = { name = "[D]ocument", _ = "which_key_ignore" },
|
||||||
['<leader>g'] = { name = '[G]it', _ = 'which_key_ignore' },
|
["<leader>g"] = { name = "[G]it", _ = "which_key_ignore" },
|
||||||
['<leader>h'] = { name = 'More git', _ = 'which_key_ignore' },
|
["<leader>h"] = { name = "More git", _ = "which_key_ignore" },
|
||||||
['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
|
["<leader>r"] = { name = "[R]ename", _ = "which_key_ignore" },
|
||||||
['<leader>s'] = { name = '[S]earch', _ = 'which_key_ignore' },
|
["<leader>s"] = { name = "[S]earch", _ = "which_key_ignore" },
|
||||||
['<leader>w'] = { name = '[W]orkspace', _ = 'which_key_ignore' },
|
["<leader>w"] = { name = "[W]orkspace", _ = "which_key_ignore" },
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Enable the following language servers
|
-- Enable the following language servers
|
||||||
@ -808,14 +808,14 @@ require('which-key').register({
|
|||||||
-- the `settings` field of the server config. You must look up that documentation yourself.
|
-- the `settings` field of the server config. You must look up that documentation yourself.
|
||||||
--
|
--
|
||||||
-- If you want to override the default filetypes that your language server will attach to you can
|
-- If you want to override the default filetypes that your language server will attach to you can
|
||||||
-- define the property 'filetypes' to the map in question.
|
-- define the property "filetypes" to the map in question.
|
||||||
local servers = {
|
local servers = {
|
||||||
-- clangd = {},
|
-- clangd = {},
|
||||||
-- gopls = {},
|
-- gopls = {},
|
||||||
-- pyright = {},
|
-- pyright = {},
|
||||||
-- rust_analyzer = {},
|
-- rust_analyzer = {},
|
||||||
-- tsserver = {},
|
-- tsserver = {},
|
||||||
-- html = { filetypes = { 'html', 'twig', 'hbs'} },
|
-- html = { filetypes = { "html", "twig", "hbs"} },
|
||||||
|
|
||||||
lua_ls = {
|
lua_ls = {
|
||||||
Lua = {
|
Lua = {
|
||||||
@ -826,14 +826,14 @@ local servers = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- Setup neovim lua configuration
|
-- Setup neovim lua configuration
|
||||||
require('neodev').setup()
|
require("neodev").setup()
|
||||||
|
|
||||||
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
|
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
|
capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
|
||||||
|
|
||||||
-- Ensure the servers above are installed
|
-- Ensure the servers above are installed
|
||||||
local mason_lspconfig = require 'mason-lspconfig'
|
local mason_lspconfig = require "mason-lspconfig"
|
||||||
|
|
||||||
mason_lspconfig.setup {
|
mason_lspconfig.setup {
|
||||||
ensure_installed = vim.tbl_keys(servers),
|
ensure_installed = vim.tbl_keys(servers),
|
||||||
@ -841,7 +841,7 @@ mason_lspconfig.setup {
|
|||||||
|
|
||||||
mason_lspconfig.setup_handlers {
|
mason_lspconfig.setup_handlers {
|
||||||
function(server_name)
|
function(server_name)
|
||||||
require('lspconfig')[server_name].setup {
|
require("lspconfig")[server_name].setup {
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
settings = servers[server_name],
|
settings = servers[server_name],
|
||||||
@ -852,12 +852,12 @@ mason_lspconfig.setup_handlers {
|
|||||||
|
|
||||||
-- [[ Configure nvim-cmp ]]
|
-- [[ Configure nvim-cmp ]]
|
||||||
-- See `:help cmp`
|
-- See `:help cmp`
|
||||||
local cmp = require 'cmp'
|
local cmp = require "cmp"
|
||||||
local luasnip = require 'luasnip'
|
local luasnip = require "luasnip"
|
||||||
require('luasnip.loaders.from_vscode').lazy_load()
|
require("luasnip.loaders.from_vscode").lazy_load()
|
||||||
luasnip.config.setup {}
|
luasnip.config.setup {}
|
||||||
|
|
||||||
local lspkind = require('lspkind')
|
local lspkind = require("lspkind")
|
||||||
lspkind.init()
|
lspkind.init()
|
||||||
|
|
||||||
cmp.setup {
|
cmp.setup {
|
||||||
@ -867,16 +867,16 @@ cmp.setup {
|
|||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
mapping = cmp.mapping.preset.insert {
|
mapping = cmp.mapping.preset.insert {
|
||||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
["<C-n>"] = cmp.mapping.select_next_item(),
|
||||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
["<C-p>"] = cmp.mapping.select_prev_item(),
|
||||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||||
['<C-Space>'] = cmp.mapping.complete {},
|
["<C-Space>"] = cmp.mapping.complete {},
|
||||||
['<CR>'] = cmp.mapping.confirm {
|
["<CR>"] = cmp.mapping.confirm {
|
||||||
behavior = cmp.ConfirmBehavior.Replace,
|
behavior = cmp.ConfirmBehavior.Replace,
|
||||||
select = true,
|
select = true,
|
||||||
},
|
},
|
||||||
['<Tab>'] = cmp.mapping(function(fallback)
|
["<Tab>"] = cmp.mapping(function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_next_item()
|
cmp.select_next_item()
|
||||||
elseif luasnip.expand_or_locally_jumpable() then
|
elseif luasnip.expand_or_locally_jumpable() then
|
||||||
@ -884,8 +884,8 @@ cmp.setup {
|
|||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
end, { 'i', 's' }),
|
end, { "i", "s" }),
|
||||||
['<S-Tab>'] = cmp.mapping(function(fallback)
|
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_prev_item()
|
cmp.select_prev_item()
|
||||||
elseif luasnip.locally_jumpable(-1) then
|
elseif luasnip.locally_jumpable(-1) then
|
||||||
@ -893,13 +893,13 @@ cmp.setup {
|
|||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
end, { 'i', 's' }),
|
end, { "i", "s" }),
|
||||||
},
|
},
|
||||||
sources = {
|
sources = {
|
||||||
{ name = 'nvim_lsp' },
|
{ name = "nvim_lsp" },
|
||||||
{ name = 'luasnip' },
|
{ name = "luasnip" },
|
||||||
{ name = 'path' },
|
{ name = "path" },
|
||||||
{ name = 'buffer', max_item_count = 10, keyword_length = 5 },
|
{ name = "buffer", max_item_count = 10, keyword_length = 5 },
|
||||||
},
|
},
|
||||||
formatting = {
|
formatting = {
|
||||||
format = lspkind.cmp_format{ with_text = true }
|
format = lspkind.cmp_format{ with_text = true }
|
||||||
@ -911,9 +911,9 @@ cmp.setup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- Use buffer source for `/`.
|
-- Use buffer source for `/`.
|
||||||
cmp.setup.cmdline('/', {
|
cmp.setup.cmdline("/", {
|
||||||
sources = {
|
sources = {
|
||||||
{ name = 'buffer' }
|
{ name = "buffer" }
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -32,57 +32,57 @@ return {
|
|||||||
return stdout
|
return stdout
|
||||||
end
|
end
|
||||||
|
|
||||||
ls.config.set_config {
|
-- ls.config.set_config {
|
||||||
history = true,
|
-- history = true,
|
||||||
updateevents = "TextChanged,TextChangedI",
|
-- updateevents = "TextChanged,TextChangedI",
|
||||||
enable_autosnippets = true
|
-- enable_autosnippets = true
|
||||||
}
|
-- }
|
||||||
|
|
||||||
vim.keymap.set({"i", "s"}, "<c-k>", function()
|
-- vim.keymap.set({"i", "s"}, "<c-k>", function()
|
||||||
if ls.expand_or_jumpable() then
|
-- if ls.expand_or_jumpable() then
|
||||||
ls.expand_or_jump()
|
-- ls.expand_or_jump()
|
||||||
end
|
-- end
|
||||||
end, { silent = true })
|
-- end, { silent = true })
|
||||||
|
|
||||||
vim.keymap.set({ "i", "s" }, "<c-j>", function()
|
-- vim.keymap.set({ "i", "s" }, "<c-j>", function()
|
||||||
if ls.jumpable(-1) then ls.jump(-1) end
|
-- if ls.jumpable(-1) then ls.jump(-1) end
|
||||||
end, { silent = -1 })
|
-- end, { silent = -1 })
|
||||||
|
|
||||||
vim.keymap.set({"i"}, "<c-l>", function()
|
-- vim.keymap.set({"i"}, "<c-l>", function()
|
||||||
if ls.choice_active() then ls.change_choice(1) end
|
-- if ls.choice_active() then ls.change_choice(1) end
|
||||||
end)
|
-- end)
|
||||||
|
|
||||||
ls.add_snippets("all", {
|
ls.add_snippets("all", {
|
||||||
s("MIT", {
|
s("MIT", {
|
||||||
t({"The MIT License (MIT)", "Copyright © "}),
|
t({"The MIT License (MIT)", "Copyright © "}),
|
||||||
f(getCurrentYear, {}),
|
f(getCurrentYear, {}),
|
||||||
t(" "),
|
t(" "),
|
||||||
d(1, function()
|
d(1, function()
|
||||||
return sn(nil, {
|
return sn(nil, {
|
||||||
i(1, getGitUsername() or "<copyright holders>")
|
i(1, getGitUsername() or "<copyright holders>")
|
||||||
})
|
})
|
||||||
end, {}),
|
end, {}),
|
||||||
t{
|
t{
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"Permission is hereby granted, free of charge, to any person obtaining a copy of",
|
"Permission is hereby granted, free of charge, to any person obtaining a copy of",
|
||||||
"this software and associated documentation files (the “Software”), to deal in",
|
"this software and associated documentation files (the “Software”), to deal in",
|
||||||
"the Software without restriction, including without limitation the rights to",
|
"the Software without restriction, including without limitation the rights to",
|
||||||
"use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies",
|
"use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies",
|
||||||
"of the Software, and to permit persons to whom the Software is furnished to do",
|
"of the Software, and to permit persons to whom the Software is furnished to do",
|
||||||
"so, subject to the following conditions:",
|
"so, subject to the following conditions:",
|
||||||
"",
|
"",
|
||||||
"The above copyright notice and this permission notice shall be included in all",
|
"The above copyright notice and this permission notice shall be included in all",
|
||||||
"copies or substantial portions of the Software.",
|
"copies or substantial portions of the Software.",
|
||||||
"",
|
"",
|
||||||
"THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR",
|
"THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR",
|
||||||
"IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,",
|
"IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,",
|
||||||
"FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE",
|
"FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE",
|
||||||
"AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER",
|
"AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER",
|
||||||
"LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,",
|
"LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,",
|
||||||
"OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE",
|
"OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE",
|
||||||
"SOFTWARE.",
|
"SOFTWARE.",
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user