diff --git a/.gitignore b/.gitignore index 5509150..8cb205e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1 @@ -./plugin/packer_compiled.lua - -plugin \ No newline at end of file +plugin diff --git a/ftplugin/markdown.lua b/ftplugin/markdown.lua new file mode 100644 index 0000000..1ab7de4 --- /dev/null +++ b/ftplugin/markdown.lua @@ -0,0 +1 @@ +vim.cmd("TableModeEnable") diff --git a/lua/basic.lua b/lua/basic.lua index 2a847b4..9d7f4de 100644 --- a/lua/basic.lua +++ b/lua/basic.lua @@ -3,7 +3,7 @@ local M = {} M.load_default_options = function() local set_options = { backup = false, -- creates a backup file - clipboard = "unnamedplus", -- allows neovim to access the system clipboard + clipboard = "unnamed", -- allows neovim to access the system clipboard cmdheight = 1, -- more space in the neovim command line for displaying messages completeopt = { "menuone", "noselect" }, conceallevel = 0, -- so that `` is visible in markdown files diff --git a/lua/keybindings.lua b/lua/keybindings.lua index 08edb90..ef676d5 100644 --- a/lua/keybindings.lua +++ b/lua/keybindings.lua @@ -28,7 +28,7 @@ wk.register({ -- markdown 表格 wk.register({ ["t"] = { - name = "+Table", + name = "", }, }) @@ -105,6 +105,7 @@ wk.register({ b = { ":bp", "Last buffer" }, n = { ":ls", "Buffer numbers" }, t = { ":b ", "To buffer" }, + c = { ":noh", "Cancel highlight" }, }, }) -- change left and right tab @@ -132,8 +133,16 @@ map("n", "f", ":Telescope find_files", opt) pluginKeys.cmp = function(cmp) return { -- next option - -- 下一个 - [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif require("luasnip").expand_or_jumpable() then + require("luasnip").expand_or_jump() + else + fallback() + end + end, { "i", "s" }), -- 下一个 + [""] = cmp.mapping.select_prev_item(), [""] = cmp.mapping.confirm({ diff --git a/lua/lsp/cmp.lua b/lua/lsp/cmp.lua index 73c8d7c..9c7c414 100644 --- a/lua/lsp/cmp.lua +++ b/lua/lsp/cmp.lua @@ -1,67 +1,80 @@ -local lspkind = require('lspkind') -local cmp = require'cmp' +local lspkind = require("lspkind") +local cmp = require("cmp") -cmp.setup { - -- 指定 snippet 引擎 - snippet = { - expand = function(args) - -- For `vsnip` users. - vim.fn["vsnip#anonymous"](args.body) +cmp.setup({ + -- 指定 snippet 引擎 + snippet = { + expand = function(args) + -- For `vsnip` users. + -- vim.fn["vsnip#anonymous"](args.body) - -- For `luasnip` users. - -- require('luasnip').lsp_expand(args.body) + -- For `luasnip` users. + require("luasnip").lsp_expand(args.body) - -- For `ultisnips` users. - -- vim.fn["UltiSnips#Anon"](args.body) + -- For `ultisnips` users. + -- vim.fn["UltiSnips#Anon"](args.body) - -- For `snippy` users. - -- require'snippy'.expand_snippet(args.body) - end, - }, - -- 来源 - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - -- For vsnip users. - { name = 'vsnip' }, - -- For luasnip users. - -- { name = 'luasnip' }, - --For ultisnips users. - -- { name = 'ultisnips' }, - -- -- For snippy users. - -- { name = 'snippy' }, - }, { { name = 'buffer' }, - { name = 'path' } - }), + -- For `snippy` users. + -- require'snippy'.expand_snippet(args.body) + end, + }, + -- 来源 + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + -- For vsnip users. + -- { name = "vsnip" }, + -- For luasnip users. + { name = "luasnip" }, + --For ultisnips users. + -- { name = 'ultisnips' }, + -- -- For snippy users. + -- { name = 'snippy' }, + }, { { name = "buffer" }, { name = "path" } }), - -- 快捷键 - mapping = require('keybindings').cmp(cmp), - -- 使用lspkind-nvim显示类型图标 - formatting = { - format = lspkind.cmp_format({ - with_text = true, -- do not show text alongside icons - maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) - before = function (entry, vim_item) - -- Source 显示提示来源 - vim_item.menu = "["..string.upper(entry.source.name).."]" - return vim_item - end - }) - }, -} + -- 快捷键 + mapping = require("keybindings").cmp(cmp), + -- 使用lspkind-nvim显示类型图标 + formatting = { + format = lspkind.cmp_format({ + with_text = true, -- do not show text alongside icons + maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) + before = function(entry, vim_item) + -- Source 显示提示来源 + vim_item.menu = "[" .. string.upper(entry.source.name) .. "]" + return vim_item + end, + }), + }, + experimental = { ghost_text = true }, +}) -- Use buffer source for `/`. -cmp.setup.cmdline('/', { - sources = { - { name = 'buffer' } - } +cmp.setup.cmdline("/", { + sources = { + { name = "buffer" }, + }, }) - -- Use cmdline & path source for ':'. -cmp.setup.cmdline(':', { - sources = cmp.config.sources({ - { name = 'path' } - }, { - { name = 'cmdline' } - }) +cmp.setup.cmdline(":", { + sources = cmp.config.sources({ + { name = "path" }, + }, { + { name = "cmdline" }, + }), }) + +-- 浮窗参数提示 +local signature_config = { + debug = true, + hint_enable = false, + handler_opts = { border = "single" }, + max_width = 80, +} + +require("lsp_signature").setup(signature_config) + +-- 补全时自动添加括号 +local cmp_autopairs = require("nvim-autopairs.completion.cmp") + +cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } })) diff --git a/lua/lsp/null-ls.lua b/lua/lsp/null-ls.lua index a69d98c..f4f1d14 100644 --- a/lua/lsp/null-ls.lua +++ b/lua/lsp/null-ls.lua @@ -1,7 +1,5 @@ local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) - --- 每次自动选择null-ls作为formatter --- auto choose null-ls as formatter +-- 每次自动选择null-ls作为formatter auto choose null-ls as formatter local lsp_formatting = function(bufnr) vim.lsp.buf.format({ filter = function(client) diff --git a/lua/plugin-config/lualine.lua b/lua/plugin-config/lualine.lua index 72b62d1..402f186 100644 --- a/lua/plugin-config/lualine.lua +++ b/lua/plugin-config/lualine.lua @@ -1,7 +1,7 @@ require("lualine").setup({ options = { icons_enabled = true, - theme = "", + -- theme = "auto", component_separators = { left = "", right = "" }, section_separators = { left = "", right = "" }, disabled_filetypes = { diff --git a/lua/plugin-config/notify.lua b/lua/plugin-config/notify.lua index 1b745ec..882de47 100644 --- a/lua/plugin-config/notify.lua +++ b/lua/plugin-config/notify.lua @@ -1,2 +1,10 @@ -require('notify').setup{ -} +require("notify").setup({}) + +local notify = vim.notify +vim.notify = function(msg, ...) + if msg:match("warning: multiple different client offset_encodings") then + return + end + + notify(msg, ...) +end diff --git a/lua/plugin-config/nvim-autopairs.lua b/lua/plugin-config/nvim-autopairs.lua index e617103..91e9491 100644 --- a/lua/plugin-config/nvim-autopairs.lua +++ b/lua/plugin-config/nvim-autopairs.lua @@ -1,3 +1,3 @@ -require('nvim-autopairs').setup({ - enable_check_bracket_line = true +require("nvim-autopairs").setup({ + enable_check_bracket_line = true, }) diff --git a/lua/plugins.lua b/lua/plugins.lua index 151e22d..ac9c64f 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -137,9 +137,12 @@ return require("packer").startup(function() -- 补全引擎 use("hrsh7th/nvim-cmp") -- Snippet 引擎 - use("hrsh7th/vim-vsnip") + use({ "L3MON4D3/LuaSnip" }) + -- use("hrsh7th/vim-vsnip") -- 补全源 - use("hrsh7th/cmp-vsnip") + -- use("hrsh7th/cmp-vsnip") + use({ "ray-x/lsp_signature.nvim" }) + use({ "saadparwaiz1/cmp_luasnip" }) use("hrsh7th/cmp-nvim-lsp") -- { name = nvim_lsp } use("hrsh7th/cmp-buffer") -- { name = 'buffer' }, use("hrsh7th/cmp-path") -- { name = 'path' }