diff --git a/nvim/init.lua b/nvim/init.lua index d515b94..9e2de4b 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -319,251 +319,6 @@ require('packer').startup(function(use) -- " end, -- "} - -- nvim-cmp - - use { - 'hrsh7th/vim-vsnip', - -- event = { 'InsertEnter' }, - config = function() - vim.cmd [[ - let g:vsnip_snippet_dir = "$HOME/.config/nvim/snippets" - autocmd User PumCompleteDone call vsnip_integ#on_complete_done(g:pum#completed_item) - imap vsnip#jumpable(-1) ? "(vsnip-jump-prev)" : "" - smap vsnip#jumpable(-1) ? "(vsnip-jump-prev)" : "" - - imap vsnip#expandable() ? "(vsnip-expand)" : "" - smap vsnip#expandable() ? "(vsnip-expand)" : "" - imap vsnip#jumpable(1) ? "(vsnip-jump-next)" : "" - smap vsnip#jumpable(1) ? "(vsnip-jump-next)" : "" - imap vsnip#jumpable(-1) ? "(vsnip-jump-prev)" : "" - smap vsnip#jumpable(-1) ? "(vsnip-jump-prev)" : "" - let g:vsnip_filetypes = {} - autocmd BufWritePre lua vim.lsp.buf.format({}, 10000) - ]] - end - } - - use { - "hrsh7th/nvim-cmp", - config = function() - 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 feedkey = function(key, mode) - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true) - end - - local icn = icons() - local kind_icons = icn.kind - - local cmp = require("cmp") - cmp.setup({ - snippet = { - expand = function(args) - vim.fn["vsnip#anonymous"](args.body) - end, - }, - formatting = { - fields = { "kind", "abbr", "menu" }, - format = function(entry, vim_item) - -- Kind icons - vim_item.kind = kind_icons[vim_item.kind] - - if entry.source.name == "copilot" then - vim_item.kind = icn.git.Octoface - vim_item.kind_hl_group = "CmpItemKindCopilot" - end - - if entry.source.name == "emoji" then - vim_item.kind = icn.misc.Smiley - vim_item.kind_hl_group = "CmpItemKindEmoji" - end - - if entry.source.name == "crates" then - vim_item.kind = icn.misc.Package - vim_item.kind_hl_group = "CmpItemKindCrate" - end - - if entry.source.name == "lab.quick_data" then - vim_item.kind = icn.misc.CircuitBoard - vim_item.kind_hl_group = "CmpItemKindConstant" - end - - -- NOTE: order matters - vim_item.menu = ({ - nvim_lsp = "", - nvim_lua = "", - luasnip = "", - buffer = "", - path = "", - emoji = "", - })[entry.source.name] - return vim_item - end, - }, - window = { - completion = cmp.config.window.bordered({ - border = 'double' - }), - documentation = cmp.config.window.bordered({ - border = 'double' - }), - }, - sources = { - { name = "nvim_lsp", priority = 10 }, - { name = 'vsnip', priority = 9 }, - { name = "path", priority = 8 }, - { name = "buffer", priority = 7 }, - { name = "nvim_lsp_signature_help", priority = 6 }, - -- { name = 'copilot', priority = 5 }, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.select_prev_item(), - [""] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.abort(), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.confirm { select = true }, - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif vim.fn["vsnip#available"](1) == 1 then - feedkey("(vsnip-expand-or-jump)", "") - elseif has_words_before() then - cmp.complete() - else - fallback() -- The fallback function sends a already mapped key. In this case, it's probably ``. - end - end, { "i", "s" }), - [""] = cmp.mapping(function() - if cmp.visible() then - cmp.select_prev_item() - elseif vim.fn["vsnip#jumpable"](-1) == 1 then - feedkey("(vsnip-jump-prev)", "") - end - end, { "i", "s" }), - }), - experimental = { - ghost_text = true, - }, - }) - - -- Set configuration for specific filetype. - cmp.setup.filetype('gitcommit', { - sources = cmp.config.sources({ - { name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it. - }, { - { name = 'buffer' }, - }) - }) - - -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). - cmp.setup.cmdline({ '/', '?' }, { - mapping = cmp.mapping.preset.cmdline(), - sources = { - { name = 'buffer' } - } - }) - - -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). - cmp.setup.cmdline(':', { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ - { name = 'path' } - }, { - { name = 'cmdline' } - }) - }) - end, - requires = { - -- { - -- 'hrsh7th/nvim-cmp', event = { 'InsertEnter', 'CmdlineEnter' } - -- }, - { - 'hrsh7th/cmp-nvim-lsp', - }, - { - 'hrsh7th/cmp-buffer', event = { 'InsertEnter' } - }, - { - 'hrsh7th/cmp-path', event = { 'InsertEnter' } - }, - { - 'hrsh7th/cmp-cmdline', event = { 'ModeChanged' } - }, - { - 'hrsh7th/cmp-nvim-lsp-signature-help', event = { 'InsertEnter' } - }, - { - 'hrsh7th/cmp-nvim-lsp-document-symbol', event = { 'InsertEnter' } - }, - { - 'hrsh7th/cmp-calc', event = { 'InsertEnter' } - }, - { - 'onsails/lspkind.nvim', event = { 'InsertEnter' } - }, - { - 'hrsh7th/cmp-vsnip', event = { 'InsertEnter' }, - }, - { - "github/copilot.vim", - event = { "InsertEnter" }, - setup = function() - vim.g.copilot_filetypes = { - gitcommit = true, - markdown = true, - yaml = true, - text = true, - } - vim.g.copilot_no_tab_map = true - end, - config = function() - local keymap = vim.keymap - keymap.set( - "i", - "", - 'copilot#Accept()', - { silent = true, expr = true, script = true, replace_keycodes = false } - ) - keymap.set( - "i", - "", - '(copilot-dismiss)' - ) - -- keymap("i", "", "(copilot-next)") - -- keymap("i", "", "(copilot-previous)") - -- keymap("i", "", "(copilot-dismiss)") - -- keymap("i", "", "(copilot-suggest)") - - local function append_diff() - -- Get the Git repository root directory - local git_dir = vim.fn.FugitiveGitDir() - local git_root = vim.fn.fnamemodify(git_dir, ':h') - -- Get the diff of the staged changes relative to the Git repository root - local diff = vim.fn.system('git -C ' .. git_root .. ' diff --cached') - -- Add a comment character to each line of the diff - local comment_diff = table.concat(vim.tbl_map(function(line) - return '# ' .. line - end, vim.split(diff, '\n')), "\n") - -- Append the diff to the commit message - vim.api.nvim_buf_set_lines(0, -1, -1, false, vim.split(comment_diff, '\n')) - end - vim.cmd [[ - autocmd BufReadPost COMMIT_EDITMSG call lua append_diff() - ]] - end, - }, - -- { - -- "hrsh7th/cmp-copilot", - -- event = { "InsertEnter" }, - -- }, - }, - } -- treesitter use { "nvim-treesitter/nvim-treesitter", -- knotmirror 0.0.1 From c921034c8a1d0a07dfebc1510b6fa9a09047873e Mon Sep 17 00:00:00 2001 From: ucpr Date: Sun, 16 Jul 2023 15:34:34 +0900 Subject: [PATCH 02/19] feat: add ddc and remove nvim-lsp --- nvim/init.lua | 181 +++++++++++++------------------------------------- 1 file changed, 48 insertions(+), 133 deletions(-) diff --git a/nvim/init.lua b/nvim/init.lua index 9e2de4b..2ef55b9 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -176,6 +176,54 @@ require('packer').startup(function(use) end } + -- ddc.vim + use { + "Shougo/ddc.vim", + -- event = { "InsertEnter", "CursorHold", "CmdlineEnter" }, + requires = { + use { + "Shougo/ddc-ui-native", + }, + use { + "Shougo/ddc-source-around", + }, + use { + "Shougo/ddc-matcher_head", + }, + use { + "Shougo/ddc-sorter_rank", + }, + }, + config = function() + vim.fn["ddc#custom#patch_global"]("ui", "native") + vim.fn["ddc#custom#patch_global"]("sources", { "around" }) + vim.fn["ddc#custom#patch_global"]('sourceOptions', { + _ = { + matchers = { 'matcher_head' }, + sorters = { 'sorter_rank' } + } + }) + vim.fn["ddc#custom#patch_global"]('sourceOptions', { + around = { mark = 'A' } + }) + vim.fn["ddc#custom#patch_global"]('sourceParams', { + around = { maxSize = 500 } + }) + vim.fn["ddc#custom#patch_filetype"]({ 'c', 'cpp' }, 'sources', { 'around', 'clangd' }) + vim.fn["ddc#custom#patch_filetype"]({ 'c', 'cpp' }, 'sourceOptions', { + clangd = { mark = 'C' } + }) + vim.fn["ddc#custom#patch_filetype"]('markdown', 'sourceParams', { + around = { maxSize = 100 } + }) + vim.api.nvim_set_keymap('i', '', + 'pumvisible() ? \'\' : (col(\'.\') <= 1 || getline(\'.\')[col(\'.\') - 2] =~# \'\\s\') ? \'\' : ddc#map#manual_complete()', + { silent = true, expr = true }) + vim.api.nvim_set_keymap('i', '', 'pumvisible() ? \'\' : \'\'', { expr = true }) + vim.fn["ddc#enable"]() + end, + } + -- etc use { "navarasu/onedark.nvim", @@ -436,139 +484,6 @@ require('packer').startup(function(use) } } - -- lsp - use { - "neovim/nvim-lspconfig", - requires = { - { - "williamboman/mason-lspconfig.nvim", - }, - { - "williamboman/mason.nvim", - module = { "lspconfig" }, - } - }, - config = function() - local on_attach = function(client, bufnr) - local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end - local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end - - local opts = { noremap = true, silent = true } - buf_set_keymap("n", "K", "lua vim.lsp.buf.hover()", opts) - buf_set_keymap("n", "gD", "lua vim.lsp.buf.declaration()", opts) - buf_set_keymap("n", "gd", "lua vim.lsp.buf.definition()", opts) - buf_set_keymap("n", "gi", "lua vim.lsp.buf.implementation()", opts) - buf_set_keymap("n", "gr", "lua vim.lsp.buf.references()", opts) - buf_set_keymap('n', 'gt', 'lua vim.lsp.buf.type_definition()', opts) - buf_set_keymap("n", "gn", "lua vim.lsp.buf.rename()", opts) - buf_set_keymap("n", "gf", "lua vim.lsp.buf.format { async = true }", opts) - buf_set_keymap('n', 'ge', 'lua vim.diagnostic.open_float()', opts) - buf_set_keymap("n", "", "lua vim.lsp.buf.signature_help()", opts) - buf_set_keymap("n", "wa", "lua vim.lsp.buf.add_workspace_folder()", opts) - buf_set_keymap("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()", opts) - buf_set_keymap("n", "wl", "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))", opts) - buf_set_keymap("n", "D", "lua vim.lsp.buf.type_definition()", opts) - buf_set_keymap("n", "ca", "lua vim.lsp.buf.code_action()", opts) - buf_set_keymap("n", "e", "lua vim.lsp.diagnostic.show_line_diagnostics()", opts) - buf_set_keymap("n", "[d", "lua vim.lsp.diagnostic.goto_prev()", opts) - buf_set_keymap("n", "]d", "lua vim.lsp.diagnostic.goto_next()", opts) - buf_set_keymap("n", "q", "lua vim.lsp.diagnostic.set_loclist()", opts) - end - - local capabilities = require('cmp_nvim_lsp').default_capabilities() - capabilities.textDocument.completion.completionItem.snippetSupport = true - - vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( - vim.lsp.diagnostic.on_publish_diagnostics, { - underline = true, - virtual_text = true, - signs = true, - update_in_insert = false, - } - ) - -- diagnostic sign setting - local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " } - for type, icon in pairs(signs) do - local hl = "DiagnosticSign" .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) - end - - local nvim_lsp = require("lspconfig") - require("mason").setup({ - ui = { - icons = { - package_installed = "✓", - package_pending = "➜", - package_uninstalled = "✗" - } - } - }) - require("mason-lspconfig").setup() - require("mason-lspconfig").setup_handlers { - function(server_name) - if server_name == "gopls" then - nvim_lsp[server_name].setup { - on_attach = on_attach, - flags = { - debounce_text_changes = 150, - }, - settings = { - gopls = { - env = { GOFLAGS = "-tags=integration,wireinject" }, - gofumpt = true, - }, - }, - } - -- elseif server_name == "denols" then - -- nvim_lsp[server_name].setup({ - -- root_dir = lspconfig.util.root_pattern("deno.json"), - -- init_options = { - -- lint = true, - -- unstable = true, - -- suggest = { - -- imports = { - -- hosts = { - -- ["https://deno.land"] = true, - -- ["https://cdn.nest.land"] = true, - -- ["https://crux.land"] = true, - -- }, - -- }, - -- }, - -- }, - -- }) - -- elseif server_name == "tsserver" then - -- nvim_lsp[server_name].setup({ - -- root_dir = lspconfig.util.root_pattern("package.json"), - -- autostart = false, - -- }) - else - nvim_lsp[server_name].setup { - on_attach = on_attach, - } - end - end - } - function OrgImports(wait_ms) - local params = vim.lsp.util.make_range_params() - params.context = { only = { "source.organizeImports" } } - local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, wait_ms) - for _, res in pairs(result or {}) do - for _, r in pairs(res.result or {}) do - if r.edit then - vim.lsp.util.apply_workspace_edit(r.edit, "UTF-8") - else - vim.lsp.buf.execute_command(r.command) - end - end - end - end - - vim.cmd [[ - autocmd User PumCompleteDone call vsnip_integ#on_complete_done(g:pum#completed_item) - ]] - end - } - -- nvim-dap use { "mfussenegger/nvim-dap", -- knotmirror 0.0.1 From 868eeee690981db393ce31e69a2edcb8003c4bd8 Mon Sep 17 00:00:00 2001 From: ucpr Date: Sun, 16 Jul 2023 15:35:06 +0900 Subject: [PATCH 03/19] chore: remove nvim-dap --- nvim/init.lua | 114 -------------------------------------------------- 1 file changed, 114 deletions(-) diff --git a/nvim/init.lua b/nvim/init.lua index 2ef55b9..96cf286 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -484,120 +484,6 @@ require('packer').startup(function(use) } } - -- nvim-dap - use { - "mfussenegger/nvim-dap", - requires = { - { - "rcarriga/nvim-dap-ui", - config = function() - require("dapui").setup({ - icons = { expanded = "▾", collapsed = "▸", current_frame = "▸" }, - mappings = { - -- Use a table to apply multiple mappings - expand = { "", "<2-LeftMouse>" }, - open = "o", - remove = "d", - edit = "e", - repl = "r", - toggle = "t", - }, - -- Expand lines larger than the window - -- Requires >= 0.7 - expand_lines = vim.fn.has("nvim-0.7") == 1, - -- Layouts define sections of the screen to place windows. - -- The position can be "left", "right", "top" or "bottom". - -- The size specifies the height/width depending on position. It can be an Int - -- or a Float. Integer specifies height/width directly (i.e. 20 lines/columns) while - -- Float value specifies percentage (i.e. 0.3 - 30% of available lines/columns) - -- Elements are the elements shown in the layout (in order). - -- Layouts are opened in order so that earlier layouts take priority in window sizing. - layouts = { - { - elements = { - -- Elements can be strings or table with id and size keys. - { id = "scopes", size = 0.25 }, - "breakpoints", - "stacks", - "watches", - }, - size = 40, -- 40 columns - position = "left", - }, - { - elements = { - "repl", - }, - size = 0.25, -- 25% of total lines - position = "bottom", - }, - }, - controls = { - -- Requires Neovim nightly (or 0.8 when released) - enabled = true, - -- Display controls in this element - element = "repl", - icons = { - pause = "", - play = "", - step_into = "", - step_over = "", - step_out = "", - step_back = "", - run_last = "↻", - terminate = "□", - }, - }, - floating = { - max_height = nil, -- These can be integers or a float between 0 and 1. - max_width = nil, -- Floats will be treated as percentage of your screen. - border = "single", -- Border style. Can be "single", "double" or "rounded" - mappings = { - close = { "q", "" }, - }, - }, - windows = { indent = 1 }, - render = { - max_type_length = nil, -- Can be integer or nil. - max_value_lines = 100, -- Can be integer or nil. - } - }) - end, - }, - { - "leoluz/nvim-dap-go", - config = function() - require("dap-go").setup { - dap_configurations = { - { - -- Must be "go" or it will be ignored by the plugin - type = "go", - name = "Attach remote", - mode = "remote", - request = "attach", - }, - }, - -- delve configurations - delve = { - -- the path to the executable dlv which will be used for debugging. - -- by default, this is the "dlv" executable on your PATH. - path = "dlv", - -- time to wait for delve to initialize the debug session. - -- default to 20 seconds - initialize_timeout_sec = 20, - -- a string that defines the port to start delve debugger. - -- default to string "${port}" which instructs nvim-dap - -- to start the process in a random available port - port = "${port}", - -- additional args to pass to dlv - args = {} - }, - } - end, - }, - }, - } - -- go use { "kyoh86/vim-go-coverage", ft = "go" } use { "mattn/vim-goaddtags", ft = "go" } -- knotmirror 0.0.1 From d9ebdbd4fac43acb4d4c077f0bdf7c9e41255dfa Mon Sep 17 00:00:00 2001 From: ucpr Date: Sun, 16 Jul 2023 17:03:27 +0900 Subject: [PATCH 04/19] feat: setup ddc --- nvim/init.lua | 227 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 195 insertions(+), 32 deletions(-) diff --git a/nvim/init.lua b/nvim/init.lua index 96cf286..d359c2d 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -179,51 +179,214 @@ require('packer').startup(function(use) -- ddc.vim use { "Shougo/ddc.vim", - -- event = { "InsertEnter", "CursorHold", "CmdlineEnter" }, + event = { "InsertEnter", "CursorHold", "CmdlineEnter" }, requires = { + -- ui + "Shougo/ddc-ui-pum", use { - "Shougo/ddc-ui-native", - }, - use { - "Shougo/ddc-source-around", - }, - use { - "Shougo/ddc-matcher_head", - }, - use { - "Shougo/ddc-sorter_rank", + "Shougo/pum.vim", + config = function() + vim.fn["pum#set_option"]({ + border = 'double', + item_orders = { "kind", "abbr", "menu" }, + }) + end, }, + + -- sources + "Shougo/ddc-source-around", + "LumaKernel/ddc-file", + "uga-rosa/ddc-source-vsnip", + "Shougo/ddc-source-nvim-lsp", + + -- filters + "tani/ddc-fuzzy", }, config = function() - vim.fn["ddc#custom#patch_global"]("ui", "native") - vim.fn["ddc#custom#patch_global"]("sources", { "around" }) - vim.fn["ddc#custom#patch_global"]('sourceOptions', { - _ = { - matchers = { 'matcher_head' }, - sorters = { 'sorter_rank' } - } + vim.fn["ddc#custom#patch_global"]("ui", "pum") + vim.fn["ddc#custom#patch_global"]("sources", { + "around", + "file", + "nvim-lsp", }) vim.fn["ddc#custom#patch_global"]('sourceOptions', { - around = { mark = 'A' } + _ = { + matchers = { 'matcher_fuzzy' }, + sorters = { 'sorter_fuzzy' }, + converters = { "converter_fuzzy" }, + }, + file = { + mark = 'file', + isVolatile = true, + forceCompletionPattern = '\\S/\\S*' + }, + vsnip = { + mark = 'snip', + minAutoCompleteLength = 1 + }, + around = { mark = 'A' }, + ['nvim-lsp'] = { + mark = 'lsp', + forceCompletionPattern = '\\.\\w*|:\\w*|-\\>\\w*', + minAutoCompleteLength = 1, + }, }) vim.fn["ddc#custom#patch_global"]('sourceParams', { - around = { maxSize = 500 } - }) - vim.fn["ddc#custom#patch_filetype"]({ 'c', 'cpp' }, 'sources', { 'around', 'clangd' }) - vim.fn["ddc#custom#patch_filetype"]({ 'c', 'cpp' }, 'sourceOptions', { - clangd = { mark = 'C' } + around = { maxSize = 500 }, + ['nvim-lsp'] = { + --snippetEngine = vim.fn['denops#callback#register'](function(body) + -- return vim.fn['vsnip#anonymous'](body) + --end), + enableResolveItem = true, + enableAdditionalTextEdit = true + }, }) + vim.fn["ddc#custom#patch_filetype"]('markdown', 'sourceParams', { around = { maxSize = 100 } }) - vim.api.nvim_set_keymap('i', '', - 'pumvisible() ? \'\' : (col(\'.\') <= 1 || getline(\'.\')[col(\'.\') - 2] =~# \'\\s\') ? \'\' : ddc#map#manual_complete()', - { silent = true, expr = true }) - vim.api.nvim_set_keymap('i', '', 'pumvisible() ? \'\' : \'\'', { expr = true }) + + -- vim.api.nvim_set_keymap('i', '', + -- 'pumvisible() ? \'\' : (col(\'.\') <= 1 || getline(\'.\')[col(\'.\') - 2] =~# \'\\s\') ? \'\' : ddc#map#manual_complete()', + -- { silent = true, expr = true }) + + -- vim.api.nvim_set_keymap('i', '', 'pumvisible() ? \'\' : \'\'', { expr = true }) + + -- vim.keymap.set("i", "", 'call pum#map#insert_relative(+1)') + -- vim.keymap.set("i", "", 'call pum#map#insert_relative(-1)') + -- vim.keymap.set("i", "", 'call pum#map#confirm()') + -- vim.keymap.set("i", "", 'call pum#map#cancel()') + -- vim.keymap.set("i", "", 'call pum#map#insert_relative_page(+1)') + -- vim.keymap.set("i", "", 'call pum#map#insert_relative_page(-1)') + + vim.cmd [[ + imap pum#visible() ? 'call pum#map#insert_relative(+1)' : vsnip#jumpable(1) ? '(vsnip-jump-next)' : '' + imap pum#visible() ? 'call pum#map#select_relative(+1)' : 'call ddc#map#manual_complete()call pum#map#select_relative(+1)' + smap vsnip#jumpable(1) ? '(vsnip-jump-next)' : '' + imap pum#visible() ? 'call pum#map#insert_relative(-1)' : vsnip#jumpable(-1) ? '(vsnip-jump-prev)' : '' + imap pum#visible() ? 'call pum#map#select_relative(-1)' : 'call ddc#map#manual_complete()call pum#map#select_relative(-1)' + smap vsnip#jumpable(-1) ? '(vsnip-jump-prev)' : '' + imap pum#visible() ? 'call pum#map#confirm()' : '' + ]] + -- enable ddc vim.fn["ddc#enable"]() end, } + -- lsp + use { + "neovim/nvim-lspconfig", + requires = { + { + "williamboman/mason-lspconfig.nvim", + }, + { + "williamboman/mason.nvim", + module = { "lspconfig" }, + } + }, + config = function() + local on_attach = function(_, bufnr) + local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end + -- local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end + local opts = { noremap = true, silent = true } + buf_set_keymap("n", "gD", "lua vim.lsp.buf.declaration()", opts) + buf_set_keymap("n", "gd", "lua vim.lsp.buf.definition()", opts) + buf_set_keymap("n", "K", "lua vim.lsp.buf.hover()", opts) + buf_set_keymap("n", "gi", "lua vim.lsp.buf.implementation()", opts) + buf_set_keymap("n", "", "lua vim.lsp.buf.signature_help()", opts) + buf_set_keymap("n", "wa", "lua vim.lsp.buf.add_workspace_folder()", opts) + buf_set_keymap("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()", opts) + buf_set_keymap("n", "wl", "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))", opts) + buf_set_keymap("n", "D", "lua vim.lsp.buf.type_definition()", opts) + buf_set_keymap("n", "rn", "lua vim.lsp.buf.rename()", opts) + buf_set_keymap("n", "ca", "lua vim.lsp.buf.code_action()", opts) + buf_set_keymap("n", "gr", "lua vim.lsp.buf.references()", opts) + buf_set_keymap("n", "e", "lua vim.lsp.diagnostic.show_line_diagnostics()", opts) + buf_set_keymap("n", "[d", "lua vim.lsp.diagnostic.goto_prev()", opts) + buf_set_keymap("n", "]d", "lua vim.lsp.diagnostic.goto_next()", opts) + buf_set_keymap("n", "q", "lua vim.lsp.diagnostic.set_loclist()", opts) + buf_set_keymap("n", "f", "lua vim.lsp.buf.format()", opts) + end + + -- local capabilities = vim.lsp.protocol.make_client_capabilities() + local capabilities = require("ddc_nvim_lsp").make_client_capabilities() + -- capabilities.textDocument.completion.completionItem.snippetSupport = true + + local nvim_lsp = require("lspconfig") + require("mason").setup({ + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗" + } + } + }) + require("mason-lspconfig").setup() + require("mason-lspconfig").setup_handlers { + function(server_name) + local opt = { + on_attach = on_attach, + capabilities = require("ddc_nvim_lsp").make_client_capabilities(), + } + if server_name == "gopls" then + opt.settings = { + gopls = { + env = { GOFLAGS = "-tags=integration,wireinject" }, + gofumpt = true, + }, + } + nvim_lsp[server_name].setup(opt) + else + nvim_lsp[server_name].setup(opt) + end + end + } + function OrgImports(wait_ms) + local params = vim.lsp.util.make_range_params() + params.context = { only = { "source.organizeImports" } } + local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, wait_ms) + for _, res in pairs(result or {}) do + for _, r in pairs(res.result or {}) do + if r.edit then + vim.lsp.util.apply_workspace_edit(r.edit, "UTF-8") + else + vim.lsp.buf.execute_command(r.command) + end + end + end + end + end + } + + -- snip + use { + "hrsh7th/vim-vsnip", + event = { "InsertEnter" }, + config = function() + vim.cmd [[ + let g:vsnip_snippet_dir = "$HOME/.config/nvim/snippets" + " autocmd User PumCompleteDone call vsnip_integ#on_complete_done(g:pum#completed_item) + imap vsnip#jumpable(-1) ? "(vsnip-jump-prev)" : "" + smap vsnip#jumpable(-1) ? "(vsnip-jump-prev)" : "" + + imap vsnip#expandable() ? "(vsnip-expand)" : "" + smap vsnip#expandable() ? "(vsnip-expand)" : "" + imap vsnip#jumpable(1) ? "(vsnip-jump-next)" : "" + smap vsnip#jumpable(1) ? "(vsnip-jump-next)" : "" + imap vsnip#jumpable(-1) ? "(vsnip-jump-prev)" : "" + smap vsnip#jumpable(-1) ? "(vsnip-jump-prev)" : "" + let g:vsnip_filetypes = {} + autocmd BufWritePre lua vim.lsp.buf.format({}, 10000) + ]] + end + } + use { + "hrsh7th/vim-vsnip-integ", + event = { "InsertEnter" }, + } + -- etc use { "navarasu/onedark.nvim", @@ -379,7 +542,7 @@ require('packer').startup(function(use) highlight = { enable = true, -- disable = { "c", "rust" }, - disable = function(lang, buf) + disable = function(_, buf) local max_filesize = 100 * 1024 -- 100 KB local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) if ok and stats and stats.size > max_filesize then @@ -454,7 +617,7 @@ require('packer').startup(function(use) disable_virtual_lines_ft = { 'yaml' }, min_rows = 1, min_rows_ft = {}, - custom_parser = function(node, ft, opts) + custom_parser = function(node, _, _) local utils = require('nvim_context_vt.utils') if node:type() == 'function' then @@ -464,7 +627,7 @@ require('packer').startup(function(use) return '--> ' .. utils.get_node_text(node)[1] end, - custom_validator = function(node, ft, opts) + custom_validator = function(node, ft, _) local default_validator = require('nvim_context_vt.utils').default_validator if default_validator(node, ft) then if node:type() == 'function' then @@ -475,7 +638,7 @@ require('packer').startup(function(use) return true end, - custom_resolver = function(nodes, ft, opts) + custom_resolver = function(nodes, _, _) return nodes[#nodes] end, }) -- knotmirror 0.0.1 From 74f7e272c2777da4121ab7210eb1dbb104334e61 Mon Sep 17 00:00:00 2001 From: ucpr Date: Sun, 16 Jul 2023 17:17:36 +0900 Subject: [PATCH 05/19] feat: add vsnip setting --- nvim/init.lua | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/nvim/init.lua b/nvim/init.lua index d359c2d..fe063dc 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -183,15 +183,7 @@ require('packer').startup(function(use) requires = { -- ui "Shougo/ddc-ui-pum", - use { - "Shougo/pum.vim", - config = function() - vim.fn["pum#set_option"]({ - border = 'double', - item_orders = { "kind", "abbr", "menu" }, - }) - end, - }, + "Shougo/pum.vim", -- sources "Shougo/ddc-source-around", @@ -208,6 +200,7 @@ require('packer').startup(function(use) "around", "file", "nvim-lsp", + "vsnip", }) vim.fn["ddc#custom#patch_global"]('sourceOptions', { _ = { @@ -222,7 +215,6 @@ require('packer').startup(function(use) }, vsnip = { mark = 'snip', - minAutoCompleteLength = 1 }, around = { mark = 'A' }, ['nvim-lsp'] = { @@ -234,9 +226,9 @@ require('packer').startup(function(use) vim.fn["ddc#custom#patch_global"]('sourceParams', { around = { maxSize = 500 }, ['nvim-lsp'] = { - --snippetEngine = vim.fn['denops#callback#register'](function(body) - -- return vim.fn['vsnip#anonymous'](body) - --end), + snippetEngine = vim.fn['denops#callback#register'](function(body) + return vim.fn['vsnip#anonymous'](body) + end), enableResolveItem = true, enableAdditionalTextEdit = true }, -- knotmirror 0.0.1 From d0de6efce823ba06ea2167eab45999de7b980484 Mon Sep 17 00:00:00 2001 From: ucpr Date: Sun, 16 Jul 2023 23:17:35 +0900 Subject: [PATCH 06/19] chore: remove unnesessary codes --- nvim/init.lua | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/nvim/init.lua b/nvim/init.lua index fe063dc..e6e8c35 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -179,7 +179,7 @@ require('packer').startup(function(use) -- ddc.vim use { "Shougo/ddc.vim", - event = { "InsertEnter", "CursorHold", "CmdlineEnter" }, + -- event = { "InsertEnter", "CursorHold", "CmdlineEnter" }, requires = { -- ui "Shougo/ddc-ui-pum", @@ -234,23 +234,6 @@ require('packer').startup(function(use) }, }) - vim.fn["ddc#custom#patch_filetype"]('markdown', 'sourceParams', { - around = { maxSize = 100 } - }) - - -- vim.api.nvim_set_keymap('i', '', - -- 'pumvisible() ? \'\' : (col(\'.\') <= 1 || getline(\'.\')[col(\'.\') - 2] =~# \'\\s\') ? \'\' : ddc#map#manual_complete()', - -- { silent = true, expr = true }) - - -- vim.api.nvim_set_keymap('i', '', 'pumvisible() ? \'\' : \'\'', { expr = true }) - - -- vim.keymap.set("i", "", 'call pum#map#insert_relative(+1)') - -- vim.keymap.set("i", "", 'call pum#map#insert_relative(-1)') - -- vim.keymap.set("i", "", 'call pum#map#confirm()') - -- vim.keymap.set("i", "", 'call pum#map#cancel()') - -- vim.keymap.set("i", "", 'call pum#map#insert_relative_page(+1)') - -- vim.keymap.set("i", "", 'call pum#map#insert_relative_page(-1)') - vim.cmd [[ imap pum#visible() ? 'call pum#map#insert_relative(+1)' : vsnip#jumpable(1) ? '(vsnip-jump-next)' : '' imap pum#visible() ? 'call pum#map#select_relative(+1)' : 'call ddc#map#manual_complete()call pum#map#select_relative(+1)' -- knotmirror 0.0.1 From ba46db616cda8f2649a5e7e741ecfa88c9c94de4 Mon Sep 17 00:00:00 2001 From: ucpr Date: Mon, 17 Jul 2023 05:13:05 +0900 Subject: [PATCH 07/19] fix: fix vsnip setting --- nvim/init.lua | 310 ++++++++++++++++++++++++++------------------------ 1 file changed, 162 insertions(+), 148 deletions(-) diff --git a/nvim/init.lua b/nvim/init.lua index e6e8c35..63752c5 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -38,6 +38,8 @@ local options = { laststatus = 2, showtabline = 2, statusline = '%f %y%m %r%h%w%=[%{&fileencoding!=""?&fileencoding:&encoding},%{&ff}] [Pos %02l,%02c] [%p%%/%L]', + pumblend = 10, + winblend = 10, -- syntax tabstop = 2, shiftwidth = 2, @@ -93,158 +95,211 @@ local packer_bootstrap = ensure_packer() require('packer').startup(function(use) use 'wbthomason/packer.nvim' - -- telescope - use "nvim-lua/plenary.nvim" + -- ddu.vim use { - "nvim-telescope/telescope.nvim", - module = { "telescope" }, + "Shougo/ddu.vim", requires = { - { - "nvim-telescope/telescope-file-browser.nvim", - opt = true, - }, - { - "nvim-telescope/telescope-live-grep-args.nvim", - opt = true, - }, - { - "LinArcX/telescope-env.nvim", - opt = true, - }, - { - "nvim-telescope/telescope-fzf-native.nvim", - run = "make", - opt = true, - }, + use { "Shougo/ddu-ui-ff" }, + use { "Shougo/ddu-kind-file" }, + use { "Shougo/ddu-filter-matcher_substring" }, }, - wants = { - "telescope-fzf-native.nvim", - "telescope-file-browser.nvim", - "telescope-live-grep-args.nvim", - "telescope-fzf-native.nvim", - "telescope-env.nvim", - }, - setup = function() - local function builtin(name) - return function(opt) - return function() - return require("telescope.builtin")[name](opt or {}) - end - end - end - - local function extensions(name, prop) - return function(opt) - return function() - local telescope = require "telescope" - telescope.load_extension(name) - return telescope.extensions[name][prop](opt or {}) - end - end - end - - vim.keymap.set("n", "b", builtin("buffers") {}) - vim.keymap.set("n", "fb", extensions("file_browser", "file_browser") {}) - vim.keymap.set("n", "ff", builtin("find_files") {}) - vim.keymap.set("n", "lg", extensions("live_grep_args", "live_grep_args") {}) - end, config = function() - local telescope = require "telescope" - telescope.setup { - defaults = { - file_ignore_patterns = { - "vendor", "vendor/*", "./vendor", "./vendor/*", - "node_modules", + vim.fn['ddu#custom#patch_global']({ + ui = 'ff', + uiParams = { + ff = { + -- split = "floating", + startFilter = true, }, }, - extensions = { - fzf = { - fuzzy = true, - override_generic_sorter = true, - override_file_sorter = true, - case_mode = "smart_case", - }, - file_browser = { - hijack_netrw = true, - }, - live_grep_args = { - auto_quoting = true, - }, - }, - } - telescope.load_extension("fzf") - end + }) + + vim.fn['ddu#custom#patch_global']({ + kindOptions = { + file = { + defaultAction = 'open' + } + } + }) + + vim.fn['ddu#custom#patch_global']({ + sourceOptions = { + ['_'] = { + matchers = { 'matcher_substring' } + } + } + }) + end, } -- ddc.vim use { "Shougo/ddc.vim", - -- event = { "InsertEnter", "CursorHold", "CmdlineEnter" }, + event = { "InsertEnter", "CursorHold", "CmdlineEnter" }, requires = { -- ui - "Shougo/ddc-ui-pum", - "Shougo/pum.vim", + use { "Shougo/ddc-ui-pum" }, + use { + "Shougo/pum.vim", + config = function() + vim.fn["pum#set_option"]({ + border = 'double', + item_orders = { "abbr", "kind", "menu" }, + padding = true, + }) + end, + }, -- sources - "Shougo/ddc-source-around", - "LumaKernel/ddc-file", - "uga-rosa/ddc-source-vsnip", - "Shougo/ddc-source-nvim-lsp", + use { "Shougo/ddc-source-around" }, + use { "LumaKernel/ddc-file" }, + use { "Shougo/ddc-source-nvim-lsp" }, + use { "uga-rosa/ddc-source-vsnip" }, -- filters - "tani/ddc-fuzzy", + use { "tani/ddc-fuzzy" }, + use { "Shougo/ddc-filter-sorter_rank" }, + use { "Shougo/ddc-converter_remove_overlap" }, + + -- etc + use { "matsui54/denops-popup-preview.vim" }, + use { "matsui54/denops-signature_help" }, + use { + 'hrsh7th/vim-vsnip', + config = function() + vim.g.vsnip_snippet_dir = "$HOME/.config/nvim/snippets" + vim.cmd [[ + "autocmd User PumCompleteDone call vsnip_integ#on_complete_done(g:pum#completed_item) + autocmd BufWritePre lua vim.lsp.buf.format({}, 10000) + ]] + end + }, + -- use { + -- "hrsh7th/vim-vsnip-integ", + -- config = function() + -- vim.cmd [[ + -- ]] + -- end + -- }, }, config = function() vim.fn["ddc#custom#patch_global"]("ui", "pum") vim.fn["ddc#custom#patch_global"]("sources", { - "around", - "file", - "nvim-lsp", "vsnip", + "nvim-lsp", + "file", + "around", }) vim.fn["ddc#custom#patch_global"]('sourceOptions', { _ = { matchers = { 'matcher_fuzzy' }, - sorters = { 'sorter_fuzzy' }, - converters = { "converter_fuzzy" }, + sorters = { 'sorter_rank' }, + converters = { "converter_remove_overlap" }, + minAutoCompleteLength = 1, }, file = { - mark = 'file', + mark = '[file]', isVolatile = true, forceCompletionPattern = '\\S/\\S*' }, + around = { + mark = '[around]', + }, vsnip = { - mark = 'snip', + mark = '[snip]', + keywordPattern = "\\S*", }, - around = { mark = 'A' }, ['nvim-lsp'] = { - mark = 'lsp', - forceCompletionPattern = '\\.\\w*|:\\w*|-\\>\\w*', - minAutoCompleteLength = 1, + mark = '[lsp]', + forceCompletionPattern = "\\.\\w*|::\\w*|->\\w*", + -- dup = "force", }, }) + vim.fn["ddc#custom#patch_global"]('sourceParams', { - around = { maxSize = 500 }, + around = { maxSize = 100 }, + vsnip = { menu = false }, ['nvim-lsp'] = { snippetEngine = vim.fn['denops#callback#register'](function(body) return vim.fn['vsnip#anonymous'](body) end), - enableResolveItem = true, - enableAdditionalTextEdit = true + enableResolveItem = false, + enableAdditionalTextEdit = false, + confirmBehavior = "replace", }, }) vim.cmd [[ - imap pum#visible() ? 'call pum#map#insert_relative(+1)' : vsnip#jumpable(1) ? '(vsnip-jump-next)' : '' - imap pum#visible() ? 'call pum#map#select_relative(+1)' : 'call ddc#map#manual_complete()call pum#map#select_relative(+1)' - smap vsnip#jumpable(1) ? '(vsnip-jump-next)' : '' - imap pum#visible() ? 'call pum#map#insert_relative(-1)' : vsnip#jumpable(-1) ? '(vsnip-jump-prev)' : '' - imap pum#visible() ? 'call pum#map#select_relative(-1)' : 'call ddc#map#manual_complete()call pum#map#select_relative(-1)' - smap vsnip#jumpable(-1) ? '(vsnip-jump-prev)' : '' - imap pum#visible() ? 'call pum#map#confirm()' : '' + " autocmd User PumCompleteDone call vsnip_integ#on_complete_done(g:pum#completed_item) + inoremap + \ pum#visible() ? 'call pum#map#insert_relative(+1)' : + \ (col('.') <= 1 getline('.')[col('.') - 2] =~# '\s') ? + \ '' : ddc#manual_complete() + inoremap call pum#map#insert_relative(-1) + inoremap call pum#map#select_relative(+1) + inoremap call pum#map#select_relative(-1) + inoremap call pum#map#confirm() + inoremap call pum#map#cancel() ]] + + vim.g.signature_help_config = { + contentsStyle = "full", + viewStyle = "floating" + } + -- enable ddc vim.fn["ddc#enable"]() + vim.fn["popup_preview#enable"]() + vim.fn["signature_help#enable"]() + end, + } + + use { + "github/copilot.vim", + event = { "InsertEnter" }, + setup = function() + vim.g.copilot_filetypes = { + gitcommit = true, + markdown = true, + yaml = true, + text = true, + } + vim.g.copilot_no_tab_map = true + end, + config = function() + local keymap = vim.keymap + keymap.set( + "i", + "", + 'copilot#Accept()', + { silent = true, expr = true, script = true, replace_keycodes = false } + ) + keymap.set( + "i", + "", + '(copilot-dismiss)' + ) + -- keymap("i", "", "(copilot-next)") + -- keymap("i", "", "(copilot-previous)") + -- keymap("i", "", "(copilot-dismiss)") + -- keymap("i", "", "(copilot-suggest)") + + local function append_diff() + -- Get the Git repository root directory + local git_dir = vim.fn.FugitiveGitDir() + local git_root = vim.fn.fnamemodify(git_dir, ':h') + -- Get the diff of the staged changes relative to the Git repository root + local diff = vim.fn.system('git -C ' .. git_root .. ' diff --cached') + -- Add a comment character to each line of the diff + local comment_diff = table.concat(vim.tbl_map(function(line) + return '# ' .. line + end, vim.split(diff, '\n')), "\n") + -- Append the diff to the commit message + vim.api.nvim_buf_set_lines(0, -1, -1, false, vim.split(comment_diff, '\n')) + end + vim.cmd [[ + autocmd BufReadPost COMMIT_EDITMSG call lua append_diff() + ]] end, } @@ -284,9 +339,10 @@ require('packer').startup(function(use) buf_set_keymap("n", "f", "lua vim.lsp.buf.format()", opts) end + -- local capabilities = vim.lsp.protocol.make_client_capabilities() local capabilities = require("ddc_nvim_lsp").make_client_capabilities() - -- capabilities.textDocument.completion.completionItem.snippetSupport = true + capabilities.textDocument.completion.completionItem.snippetSupport = true local nvim_lsp = require("lspconfig") require("mason").setup({ @@ -303,7 +359,7 @@ require('packer').startup(function(use) function(server_name) local opt = { on_attach = on_attach, - capabilities = require("ddc_nvim_lsp").make_client_capabilities(), + capabilities = capabilities, } if server_name == "gopls" then opt.settings = { @@ -318,49 +374,8 @@ require('packer').startup(function(use) end end } - function OrgImports(wait_ms) - local params = vim.lsp.util.make_range_params() - params.context = { only = { "source.organizeImports" } } - local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, wait_ms) - for _, res in pairs(result or {}) do - for _, r in pairs(res.result or {}) do - if r.edit then - vim.lsp.util.apply_workspace_edit(r.edit, "UTF-8") - else - vim.lsp.buf.execute_command(r.command) - end - end - end - end - end - } - - -- snip - use { - "hrsh7th/vim-vsnip", - event = { "InsertEnter" }, - config = function() - vim.cmd [[ - let g:vsnip_snippet_dir = "$HOME/.config/nvim/snippets" - " autocmd User PumCompleteDone call vsnip_integ#on_complete_done(g:pum#completed_item) - imap vsnip#jumpable(-1) ? "(vsnip-jump-prev)" : "" - smap vsnip#jumpable(-1) ? "(vsnip-jump-prev)" : "" - - imap vsnip#expandable() ? "(vsnip-expand)" : "" - smap vsnip#expandable() ? "(vsnip-expand)" : "" - imap vsnip#jumpable(1) ? "(vsnip-jump-next)" : "" - smap vsnip#jumpable(1) ? "(vsnip-jump-next)" : "" - imap vsnip#jumpable(-1) ? "(vsnip-jump-prev)" : "" - smap vsnip#jumpable(-1) ? "(vsnip-jump-prev)" : "" - let g:vsnip_filetypes = {} - autocmd BufWritePre lua vim.lsp.buf.format({}, 10000) - ]] end } - use { - "hrsh7th/vim-vsnip-integ", - event = { "InsertEnter" }, - } -- etc use { @@ -556,7 +571,6 @@ require('packer').startup(function(use) }, rust = { 'impl_item', - }, terraform = { 'block', -- knotmirror 0.0.1 From d9a5f9556543855c724fdebae63c55fb6c3b433a Mon Sep 17 00:00:00 2001 From: ucpr Date: Mon, 17 Jul 2023 05:15:33 +0900 Subject: [PATCH 08/19] chore: formatting --- nvim/init.lua | 37 ++++++------------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/nvim/init.lua b/nvim/init.lua index 63752c5..02e285c 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -95,6 +95,11 @@ local packer_bootstrap = ensure_packer() require('packer').startup(function(use) use 'wbthomason/packer.nvim' + -- denops + use "vim-denops/denops.vim" + use "yuki-yano/fuzzy-motion.vim" + use "lambdalisue/guise.vim" + -- ddu.vim use { "Shougo/ddu.vim", @@ -174,13 +179,6 @@ require('packer').startup(function(use) ]] end }, - -- use { - -- "hrsh7th/vim-vsnip-integ", - -- config = function() - -- vim.cmd [[ - -- ]] - -- end - -- }, }, config = function() vim.fn["ddc#custom#patch_global"]("ui", "pum") @@ -212,7 +210,7 @@ require('packer').startup(function(use) ['nvim-lsp'] = { mark = '[lsp]', forceCompletionPattern = "\\.\\w*|::\\w*|->\\w*", - -- dup = "force", + dup = "force", }, }) @@ -339,7 +337,6 @@ require('packer').startup(function(use) buf_set_keymap("n", "f", "lua vim.lsp.buf.format()", opts) end - -- local capabilities = vim.lsp.protocol.make_client_capabilities() local capabilities = require("ddc_nvim_lsp").make_client_capabilities() capabilities.textDocument.completion.completionItem.snippetSupport = true @@ -497,28 +494,6 @@ require('packer').startup(function(use) "tpope/vim-fugitive", event = "InsertEnter", } - -- denops - use "vim-denops/denops.vim" - use "yuki-yano/fuzzy-motion.vim" - use "lambdalisue/guise.vim" - -- use { - -- "vim-skk/skkeleton", - -- event = { 'InsertEnter' }, - -- config = function() - -- vim.cmd [[ - -- "call skkeleton#config({ 'globalJisyo': '/Users/s11591/.skk/SKK-JISYO.L' }) - - -- "imap (skkeleton-toggle) - -- "cmap (skkeleton-toggle) - -- ]] - -- end, - -- } - -- "use { - -- " "delphinus/skkeleton_indicator.nvim", - -- " config = function() - -- " require 'skkeleton_indicator'.setup {} - -- " end, - -- "} -- treesitter use { -- knotmirror 0.0.1 From 20147a0e402366fa37b90648074fd5f70b3bcfb4 Mon Sep 17 00:00:00 2001 From: ucpr Date: Mon, 17 Jul 2023 05:30:14 +0900 Subject: [PATCH 09/19] fix: fix option --- nvim/init.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/nvim/init.lua b/nvim/init.lua index 02e285c..45bdcff 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -179,6 +179,7 @@ require('packer').startup(function(use) ]] end }, + -- use { "hrsh7th/vim-vsnip-integ" } }, config = function() vim.fn["ddc#custom#patch_global"]("ui", "pum") @@ -221,8 +222,8 @@ require('packer').startup(function(use) snippetEngine = vim.fn['denops#callback#register'](function(body) return vim.fn['vsnip#anonymous'](body) end), - enableResolveItem = false, - enableAdditionalTextEdit = false, + enableResolveItem = true, + enableAdditionalTextEdit = true, confirmBehavior = "replace", }, }) @@ -245,6 +246,13 @@ require('packer').startup(function(use) viewStyle = "floating" } + vim.g.popup_preview_config = { + border = false, + supportVsnip = true, + supportInfo = true, + delay = 60, + } + -- enable ddc vim.fn["ddc#enable"]() vim.fn["popup_preview#enable"]() -- knotmirror 0.0.1 From d098b378f0e6c108bf6799a598b7425a1628d394 Mon Sep 17 00:00:00 2001 From: ucpr Date: Tue, 18 Jul 2023 01:21:23 +0900 Subject: [PATCH 10/19] feat: add ddu settings --- nvim/init.lua | 46 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/nvim/init.lua b/nvim/init.lua index 45bdcff..2a13c37 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -106,6 +106,8 @@ require('packer').startup(function(use) requires = { use { "Shougo/ddu-ui-ff" }, use { "Shougo/ddu-kind-file" }, + use { "Shougo/ddu-source-file_rec" }, + use { "shun/ddu-source-rg" }, use { "Shougo/ddu-filter-matcher_substring" }, }, config = function() @@ -113,26 +115,48 @@ require('packer').startup(function(use) ui = 'ff', uiParams = { ff = { - -- split = "floating", + split = "floating", startFilter = true, + prompt = "> ", + }, + }, + sources = { + { + name = "file_rec", + params = { + ignoredDirectories = { ".git", "node_modules", "vendor" }, + }, + } + }, + sourceOptions = { + ['_'] = { + matchers = { 'matcher_substring' } + } + }, + filterParams = { + matcher_substring = { + -- ignoreCase = true, + highlightMatched = "Title", }, }, - }) - - vim.fn['ddu#custom#patch_global']({ kindOptions = { file = { defaultAction = 'open' } - } + }, }) - vim.fn['ddu#custom#patch_global']({ - sourceOptions = { - ['_'] = { - matchers = { 'matcher_substring' } - } - } + vim.fn['ddu#custom#patch_local']("grep", { + sourceParams = { + rg = { + args = { "--column", "--no-heading", "--color", "never" }, + }, + }, + uiParams = { + ff = { + startFilter = false, + }, + }, }) end, } -- knotmirror 0.0.1 From 1314fdd9edce17ac5af748b74e08967e5984dfc3 Mon Sep 17 00:00:00 2001 From: ucpr Date: Tue, 18 Jul 2023 02:08:43 +0900 Subject: [PATCH 11/19] feat: fix keymap --- nvim/init.lua | 67 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 15 deletions(-) diff --git a/nvim/init.lua b/nvim/init.lua index 2a13c37..aa32c7b 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -197,6 +197,14 @@ require('packer').startup(function(use) 'hrsh7th/vim-vsnip', config = function() vim.g.vsnip_snippet_dir = "$HOME/.config/nvim/snippets" + + vim.keymap.set('i', '', function() + return vim.fn['vsnip#jumpable'](1) ~= 0 and '(vsnip-jump-next)' or '' + end, { expr = true }) + vim.keymap.set('i', '', function() + return vim.fn['vsnip#jumpable'](-1) ~= 0 and '(vsnip-jump-prev)' or '' + end, { expr = true }) + vim.cmd [[ "autocmd User PumCompleteDone call vsnip_integ#on_complete_done(g:pum#completed_item) autocmd BufWritePre lua vim.lsp.buf.format({}, 10000) @@ -252,18 +260,42 @@ require('packer').startup(function(use) }, }) - vim.cmd [[ - " autocmd User PumCompleteDone call vsnip_integ#on_complete_done(g:pum#completed_item) - inoremap - \ pum#visible() ? 'call pum#map#insert_relative(+1)' : - \ (col('.') <= 1 getline('.')[col('.') - 2] =~# '\s') ? - \ '' : ddc#manual_complete() - inoremap call pum#map#insert_relative(-1) - inoremap call pum#map#select_relative(+1) - inoremap call pum#map#select_relative(-1) - inoremap call pum#map#confirm() - inoremap call pum#map#cancel() - ]] + --vim.cmd [[ + -- " autocmd User PumCompleteDone call vsnip_integ#on_complete_done(g:pum#completed_item) + -- inoremap + -- \ pum#visible() ? 'call pum#map#insert_relative(+1)' : + -- \ (col('.') <= 1 getline('.')[col('.') - 2] =~# '\s') ? + -- \ '' : ddc#manual_complete() + -- inoremap call pum#map#insert_relative(-1) + -- inoremap call pum#map#select_relative(+1) + -- inoremap call pum#map#select_relative(-1) + -- inoremap call pum#map#confirm() + -- inoremap call pum#map#cancel() + --]] + + local feedkey = function(key, mode) + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true) + end + vim.keymap.set('i', '', function() + if vim.fn["pum#visible"]() then + vim.fn["pum#map#select_relative"](1) + elseif vim.fn.col('.') <= 1 or string.match(vim.fn.getline('.'), '^%s*$') then + return '' + elseif vim.fn["vsnip#available"](1) then + feedkey("(vsnip-expand-or-jump)", "") + else + vim.fn['ddc#manual_complete']() + end + end, { silent = true, expr = true }) + -- vim.keymap.set('i', "", function() vim.fn["pum#map#confirm"]() end) + -- vim.keymap.set({ "i", "c" }, "", function() vim.fn["pum#map#confirm"]() end) + vim.keymap.set({ "i", "c" }, "", function() vim.fn["pum#map#confirm"]() end) + -- vim.keymap.set( + -- { "i", "c" }, + -- "", + -- function() return complete_or_select(-1) end, + -- { silent = true, expr = true, replace_keycodes = false } + -- ) vim.g.signature_help_config = { contentsStyle = "full", @@ -327,9 +359,13 @@ require('packer').startup(function(use) -- Append the diff to the commit message vim.api.nvim_buf_set_lines(0, -1, -1, false, vim.split(comment_diff, '\n')) end - vim.cmd [[ - autocmd BufReadPost COMMIT_EDITMSG call lua append_diff() - ]] + --vim.cmd [[ + -- autocmd BufReadPost COMMIT_EDITMSG call lua append_diff() + -- ]] + vim.api.nvim_create_autocmd({ "BufReadPost" }, { + pattern = "COMMIT_EDITMSG", + callback = append_diff, + }) end, } @@ -670,6 +706,7 @@ end) local keymap = vim.keymap keymap.set("n", "s", ":FuzzyMotion") keymap.set("n", "", ":q!") +keymap.set("n", "", ":w") -- buffer keymap.set("n", ",", ":bprev") -- knotmirror 0.0.1 From 6c6568c489c416920df9f1792ddb145a3c99c2e9 Mon Sep 17 00:00:00 2001 From: ucpr Date: Tue, 18 Jul 2023 02:31:16 +0900 Subject: [PATCH 12/19] fix: fix ddc keymap --- nvim/init.lua | 44 +++++++++++--------------------------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/nvim/init.lua b/nvim/init.lua index aa32c7b..6366f4e 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -206,7 +206,6 @@ require('packer').startup(function(use) end, { expr = true }) vim.cmd [[ - "autocmd User PumCompleteDone call vsnip_integ#on_complete_done(g:pum#completed_item) autocmd BufWritePre lua vim.lsp.buf.format({}, 10000) ]] end @@ -260,48 +259,30 @@ require('packer').startup(function(use) }, }) - --vim.cmd [[ - -- " autocmd User PumCompleteDone call vsnip_integ#on_complete_done(g:pum#completed_item) - -- inoremap - -- \ pum#visible() ? 'call pum#map#insert_relative(+1)' : - -- \ (col('.') <= 1 getline('.')[col('.') - 2] =~# '\s') ? - -- \ '' : ddc#manual_complete() - -- inoremap call pum#map#insert_relative(-1) - -- inoremap call pum#map#select_relative(+1) - -- inoremap call pum#map#select_relative(-1) - -- inoremap call pum#map#confirm() - -- inoremap call pum#map#cancel() - --]] - - local feedkey = function(key, mode) - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true) + 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 - vim.keymap.set('i', '', function() + local complete_or_select = function(n) if vim.fn["pum#visible"]() then - vim.fn["pum#map#select_relative"](1) + vim.fn["pum#map#select_relative"](n) + elseif has_words_before() then + vim.fn['ddc#manual_complete']() elseif vim.fn.col('.') <= 1 or string.match(vim.fn.getline('.'), '^%s*$') then return '' - elseif vim.fn["vsnip#available"](1) then - feedkey("(vsnip-expand-or-jump)", "") else vim.fn['ddc#manual_complete']() end - end, { silent = true, expr = true }) - -- vim.keymap.set('i', "", function() vim.fn["pum#map#confirm"]() end) - -- vim.keymap.set({ "i", "c" }, "", function() vim.fn["pum#map#confirm"]() end) + end + vim.keymap.set({ "i", "c" }, '', function() complete_or_select(1) end, { silent = true, expr = true }) + vim.keymap.set({ "i", "c" }, '', function() complete_or_select(-1) end, { silent = true, expr = true }) vim.keymap.set({ "i", "c" }, "", function() vim.fn["pum#map#confirm"]() end) - -- vim.keymap.set( - -- { "i", "c" }, - -- "", - -- function() return complete_or_select(-1) end, - -- { silent = true, expr = true, replace_keycodes = false } - -- ) vim.g.signature_help_config = { contentsStyle = "full", viewStyle = "floating" } - vim.g.popup_preview_config = { border = false, supportVsnip = true, @@ -359,9 +340,6 @@ require('packer').startup(function(use) -- Append the diff to the commit message vim.api.nvim_buf_set_lines(0, -1, -1, false, vim.split(comment_diff, '\n')) end - --vim.cmd [[ - -- autocmd BufReadPost COMMIT_EDITMSG call lua append_diff() - -- ]] vim.api.nvim_create_autocmd({ "BufReadPost" }, { pattern = "COMMIT_EDITMSG", callback = append_diff, -- knotmirror 0.0.1 From a1a6fa72938d9e4083d821fcc85affe99ec004ac Mon Sep 17 00:00:00 2001 From: ucpr Date: Tue, 18 Jul 2023 02:40:03 +0900 Subject: [PATCH 13/19] feat: add event --- nvim/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/nvim/init.lua b/nvim/init.lua index 6366f4e..4d76da6 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -195,6 +195,7 @@ require('packer').startup(function(use) use { "matsui54/denops-signature_help" }, use { 'hrsh7th/vim-vsnip', + event = { "InsertEnter" }, config = function() vim.g.vsnip_snippet_dir = "$HOME/.config/nvim/snippets" -- knotmirror 0.0.1 From d5b42505fce5ab48713a9ba1dfe1914b204ba929 Mon Sep 17 00:00:00 2001 From: ucpr Date: Tue, 18 Jul 2023 04:48:07 +0900 Subject: [PATCH 14/19] chore: remove unused code --- nvim/init.lua | 230 -------------------------------------------------- 1 file changed, 230 deletions(-) diff --git a/nvim/init.lua b/nvim/init.lua index 4d76da6..4e8b8c1 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -800,236 +800,6 @@ end -- }}} --- {{{ icons - -vim.g.use_nerd_icons = false -function icons() - if vim.fn.has "mac" == 1 or vim.g.use_nerd_icons then - return { - kind = { - -- Text = "", - Text = "✏︎", - Method = "m", - Function = "λ", - Constructor = "", - -- Method = "", - -- Function = "", - -- Constructor = "", - Field = "", - -- Variable = "", - Variable = "", - -- Class = "", - Class = "c", - Interface = "", - Module = "", - -- Module = "", - Property = "", - Unit = "", - -- Value = "", - Value = "v", - Enum = "", - -- Keyword = "", - Keyword = "", - Snippet = "", - -- Snippet = "", - Color = "", - File = "", - Reference = "", - Folder = "", - EnumMember = "", - Constant = "", - Struct = "", - Event = "", - Operator = "", - TypeParameter = "", - }, - type = { - -- Array = "", - Array = "🗃", - Number = "", - -- String = "", - String = "📖", - Boolean = "蘒", - -- Object = "", - Object = "🗂", - }, - documents = { - File = "", - Files = "", - Folder = "", - OpenFolder = "", - }, - git = { - Add = "", - Mod = "", - Remove = "", - Ignore = "", - Rename = "", - Diff = "", - Repo = "", - Octoface = "", - }, - ui = { - ArrowClosed = "", - ArrowOpen = "", - Lock = "", - Circle = "", - BigCircle = "", - BigUnfilledCircle = "", - Close = "", - NewFile = "", - Search = "", - Lightbulb = "", - Project = "", - Dashboard = "", - History = "", - Comment = "", - Bug = "", - Code = "", - Telescope = "", - Gear = "", - Package = "", - List = "", - SignIn = "", - SignOut = "", - Check = "", - Fire = "", - Note = "", - BookMark = "", - Pencil = "", - -- ChevronRight = "", - ChevronRight = ">", - Table = "", - Calendar = "", - CloudDownload = "", - }, - diagnostics = { - Error = "", - Warning = "", - Information = "", - Question = "", - Hint = "", - }, - misc = { - Robot = "ﮧ", - Squirrel = "", - Tag = "", - Watch = "", - Smiley = "ﲃ", - Package = "", - CircuitBoard = "", - }, - } - else - --   פּ ﯟ   蘒練 some other good icons - return { - kind = { - Text = " ", - Method = " ", - Function = " ", - Constructor = " ", - Field = " ", - Variable = " ", - Class = " ", - Interface = " ", - Module = " ", - Property = " ", - Unit = " ", - Value = " ", - Enum = " ", - Keyword = " ", - Snippet = " ", - Color = " ", - File = " ", - Reference = " ", - Folder = " ", - EnumMember = " ", - Constant = " ", - Struct = " ", - Event = " ", - Operator = " ", - TypeParameter = " ", - Misc = " ", - }, - type = { - Array = " ", - Number = " ", - String = " ", - Boolean = " ", - Object = " ", - }, - documents = { - File = " ", - Files = " ", - Folder = " ", - OpenFolder = " ", - }, - git = { - Add = " ", - Mod = " ", - Remove = " ", - Ignore = " ", - Rename = " ", - Diff = " ", - Repo = " ", - Octoface = " ", - }, - ui = { - ArrowClosed = "", - ArrowOpen = "", - Lock = " ", - Circle = " ", - BigCircle = " ", - BigUnfilledCircle = " ", - Close = " ", - NewFile = " ", - Search = " ", - Lightbulb = " ", - Project = " ", - Dashboard = " ", - History = " ", - Comment = " ", - Bug = " ", - Code = " ", - Telescope = " ", - Gear = " ", - Package = " ", - List = " ", - SignIn = " ", - SignOut = " ", - NoteBook = " ", - Check = " ", - Fire = " ", - Note = " ", - BookMark = " ", - Pencil = " ", - ChevronRight = "", - Table = " ", - Calendar = " ", - CloudDownload = " ", - }, - diagnostics = { - Error = " ", - Warning = " ", - Information = " ", - Question = " ", - Hint = " ", - }, - misc = { - Robot = " ", - Squirrel = " ", - Tag = " ", - Watch = " ", - Smiley = " ", - Package = " ", - CircuitBoard = " ", - }, - } - end -end - --- }}} - -- vim.cmd [[ -- set runtimepath^=~/.ghq/github.com/ucpr/denops-covcolor -- -- knotmirror 0.0.1 From 1c9039a0cc2885ff85bd78f8e276ae32205841eb Mon Sep 17 00:00:00 2001 From: ucpr Date: Tue, 18 Jul 2023 06:14:42 +0900 Subject: [PATCH 15/19] feat: add cmdline setting --- nvim/init.lua | 88 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 84 insertions(+), 4 deletions(-) diff --git a/nvim/init.lua b/nvim/init.lua index 4e8b8c1..af9d208 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -164,7 +164,7 @@ require('packer').startup(function(use) -- ddc.vim use { "Shougo/ddc.vim", - event = { "InsertEnter", "CursorHold", "CmdlineEnter" }, + event = { "InsertEnter", "CursorHold", "CmdlineEnter", "VimEnter" }, requires = { -- ui use { "Shougo/ddc-ui-pum" }, @@ -181,9 +181,12 @@ require('packer').startup(function(use) -- sources use { "Shougo/ddc-source-around" }, + use { "matsui54/ddc-buffer" }, use { "LumaKernel/ddc-file" }, use { "Shougo/ddc-source-nvim-lsp" }, use { "uga-rosa/ddc-source-vsnip" }, + use { "Shougo/ddc-source-cmdline" }, + use { "Shougo/ddc-source-cmdline-history" }, -- filters use { "tani/ddc-fuzzy" }, @@ -220,6 +223,7 @@ require('packer').startup(function(use) "nvim-lsp", "file", "around", + "buffer", }) vim.fn["ddc#custom#patch_global"]('sourceOptions', { _ = { @@ -236,13 +240,16 @@ require('packer').startup(function(use) around = { mark = '[around]', }, + buffer = { + mark = "[buffer]", + }, vsnip = { mark = '[snip]', keywordPattern = "\\S*", }, ['nvim-lsp'] = { mark = '[lsp]', - forceCompletionPattern = "\\.\\w*|::\\w*|->\\w*", + forceCompletionPattern = [[\.\w*|:\w*|->\w*]], dup = "force", }, }) @@ -250,6 +257,12 @@ require('packer').startup(function(use) vim.fn["ddc#custom#patch_global"]('sourceParams', { around = { maxSize = 100 }, vsnip = { menu = false }, + buffer = { + requireSameFiletype = false, + limitBytes = 500000, + fromAltBuf = true, + forceCollect = true, + }, ['nvim-lsp'] = { snippetEngine = vim.fn['denops#callback#register'](function(body) return vim.fn['vsnip#anonymous'](body) @@ -267,11 +280,13 @@ require('packer').startup(function(use) end local complete_or_select = function(n) if vim.fn["pum#visible"]() then - vim.fn["pum#map#select_relative"](n) + vim.fn["pum#map#insert_relative"](n) elseif has_words_before() then vim.fn['ddc#manual_complete']() + --elseif vim.fn.col "." <= 1 or vim.fn.getline("."):sub(col - 1):match "%s" then + -- return "" elseif vim.fn.col('.') <= 1 or string.match(vim.fn.getline('.'), '^%s*$') then - return '' + return "" else vim.fn['ddc#manual_complete']() end @@ -295,6 +310,71 @@ require('packer').startup(function(use) vim.fn["ddc#enable"]() vim.fn["popup_preview#enable"]() vim.fn["signature_help#enable"]() + + -- setup cmdline + vim.cmd [[ + nnoremap : call CommandlinePre(): + + function! CommandlinePre() abort + " Overwrite sources + let s:prev_buffer_config = ddc#custom#get_buffer() + call ddc#custom#patch_buffer('sources', ['cmdline', 'cmdline-history']) + call ddc#custom#patch_buffer('autoCompleteEvents', ['CmdlineChanged']) + call ddc#custom#patch_buffer('sourceOptions', #{ + \ _: #{ + \ ignoreCase: v:true, + \ matchers: ['matcher_fuzzy'], + \ sorters: ['sorter_fuzzy'], + \ converters: ['converter_fuzzy'] + \ }, + \ cmdline: #{ mark: '[cmd]' }, + \ cmdline-history: #{ mark: '[cmd-hist]' }, + \ }) + + autocmd CmdlineLeave ++once call CommandlinePost() + + " Enable command line completion + call ddc#enable_cmdline_completion() + endfunction + function! CommandlinePost() abort + " Restore sources + call ddc#custom#set_buffer(s:prev_buffer_config) + endfunction + ]] + + -- なんか動かなくなるので後で直す + -- local command_line_post = function(prev_buffer_config) + -- vim.fn["ddc#custom#set_buffer"](prev_buffer_config) + -- end + -- local command_line_pre = function() + -- local prev_buffer_config = vim.fn["ddc#custom#get_buffer"]() + -- vim.fn["ddc#custom#patch_buffer"]("sources", { "cmdline", "cmdline-history" }) + -- vim.fn["ddc#custom#patch_buffer"]("autoCompleteEvents", { "CmdlineChanged" }) + -- vim.fn["ddc#custom#patch_buffer"]("sourceOptions", { + -- _ = { + -- ignoreCase = true, + -- matchers = { "matcher_fuzzy" }, + -- sorters = { "sorter_fuzzy" }, + -- converters = { "converter_fuzzy" }, + -- }, + -- cmdline = { + -- mark = '[cmd]', + -- }, + -- ["cmdline-history"] = { + -- mark = '[history]', + -- }, + -- }) + -- vim.cmd [[ autocmd CmdlineLeave ++once lua command_line_post(prev_buffer_config) ]] + + -- vim.api.nvim_create_autocmd("CmdlineLeave", { + -- pattern = '*', + -- -- once = true, + -- callback = function() + -- command_line_post(prev_buffer_config) + -- end, + -- }) + -- end + -- vim.keymap.set("n", ":", function() command_line_pre() end) end, } -- knotmirror 0.0.1 From 81f38f7fbda72e2c524d66ec3b6d66da71e64ae1 Mon Sep 17 00:00:00 2001 From: ucpr Date: Tue, 18 Jul 2023 06:56:24 +0900 Subject: [PATCH 16/19] fix: fix conflict keymap --- nvim/init.lua | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/nvim/init.lua b/nvim/init.lua index af9d208..ba76c14 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -202,13 +202,6 @@ require('packer').startup(function(use) config = function() vim.g.vsnip_snippet_dir = "$HOME/.config/nvim/snippets" - vim.keymap.set('i', '', function() - return vim.fn['vsnip#jumpable'](1) ~= 0 and '(vsnip-jump-next)' or '' - end, { expr = true }) - vim.keymap.set('i', '', function() - return vim.fn['vsnip#jumpable'](-1) ~= 0 and '(vsnip-jump-prev)' or '' - end, { expr = true }) - vim.cmd [[ autocmd BufWritePre lua vim.lsp.buf.format({}, 10000) ]] @@ -281,14 +274,15 @@ require('packer').startup(function(use) local complete_or_select = function(n) if vim.fn["pum#visible"]() then vim.fn["pum#map#insert_relative"](n) + return "" elseif has_words_before() then vim.fn['ddc#manual_complete']() - --elseif vim.fn.col "." <= 1 or vim.fn.getline("."):sub(col - 1):match "%s" then - -- return "" - elseif vim.fn.col('.') <= 1 or string.match(vim.fn.getline('.'), '^%s*$') then + return "" + elseif vim.fn.col "." <= 1 or vim.fn.getline("."):sub(col - 1):match "%s" then return "" else vim.fn['ddc#manual_complete']() + return "" end end vim.keymap.set({ "i", "c" }, '', function() complete_or_select(1) end, { silent = true, expr = true }) @@ -316,7 +310,6 @@ require('packer').startup(function(use) nnoremap : call CommandlinePre(): function! CommandlinePre() abort - " Overwrite sources let s:prev_buffer_config = ddc#custom#get_buffer() call ddc#custom#patch_buffer('sources', ['cmdline', 'cmdline-history']) call ddc#custom#patch_buffer('autoCompleteEvents', ['CmdlineChanged']) @@ -332,12 +325,9 @@ require('packer').startup(function(use) \ }) autocmd CmdlineLeave ++once call CommandlinePost() - - " Enable command line completion call ddc#enable_cmdline_completion() endfunction function! CommandlinePost() abort - " Restore sources call ddc#custom#set_buffer(s:prev_buffer_config) endfunction ]] @@ -431,6 +421,7 @@ require('packer').startup(function(use) -- lsp use { "neovim/nvim-lspconfig", + event = { "VimEnter" }, requires = { { "williamboman/mason-lspconfig.nvim", -- knotmirror 0.0.1 From b82088d3443b12e5a5a8c75bd522515c8c294da0 Mon Sep 17 00:00:00 2001 From: ucpr Date: Tue, 18 Jul 2023 06:58:51 +0900 Subject: [PATCH 17/19] chore: remove history --- nvim/init.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/nvim/init.lua b/nvim/init.lua index ba76c14..666274b 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -186,7 +186,6 @@ require('packer').startup(function(use) use { "Shougo/ddc-source-nvim-lsp" }, use { "uga-rosa/ddc-source-vsnip" }, use { "Shougo/ddc-source-cmdline" }, - use { "Shougo/ddc-source-cmdline-history" }, -- filters use { "tani/ddc-fuzzy" }, @@ -311,7 +310,7 @@ require('packer').startup(function(use) function! CommandlinePre() abort let s:prev_buffer_config = ddc#custom#get_buffer() - call ddc#custom#patch_buffer('sources', ['cmdline', 'cmdline-history']) + call ddc#custom#patch_buffer('sources', ['cmdline']) call ddc#custom#patch_buffer('autoCompleteEvents', ['CmdlineChanged']) call ddc#custom#patch_buffer('sourceOptions', #{ \ _: #{ @@ -321,7 +320,6 @@ require('packer').startup(function(use) \ converters: ['converter_fuzzy'] \ }, \ cmdline: #{ mark: '[cmd]' }, - \ cmdline-history: #{ mark: '[cmd-hist]' }, \ }) autocmd CmdlineLeave ++once call CommandlinePost() -- knotmirror 0.0.1 From e2cf6d1dbd3e53beb837b734913331657ef0a95c Mon Sep 17 00:00:00 2001 From: ucpr Date: Tue, 18 Jul 2023 07:04:28 +0900 Subject: [PATCH 18/19] chore: add minAutoCompleteLength --- nvim/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/nvim/init.lua b/nvim/init.lua index 666274b..f4adf3e 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -238,6 +238,7 @@ require('packer').startup(function(use) vsnip = { mark = '[snip]', keywordPattern = "\\S*", + minAutoCompleteLength = 1, }, ['nvim-lsp'] = { mark = '[lsp]', -- knotmirror 0.0.1 From f571e0303c51b2ad96216fdd011a9090bc235b53 Mon Sep 17 00:00:00 2001 From: ucpr Date: Tue, 18 Jul 2023 07:10:10 +0900 Subject: [PATCH 19/19] chore: restore telescope --- nvim/init.lua | 120 +++++++++++++++++++++++++++++--------------------- 1 file changed, 71 insertions(+), 49 deletions(-) diff --git a/nvim/init.lua b/nvim/init.lua index f4adf3e..f64acb6 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -100,65 +100,87 @@ require('packer').startup(function(use) use "yuki-yano/fuzzy-motion.vim" use "lambdalisue/guise.vim" - -- ddu.vim + -- telescope + use "nvim-lua/plenary.nvim" use { - "Shougo/ddu.vim", + "nvim-telescope/telescope.nvim", + module = { "telescope" }, requires = { - use { "Shougo/ddu-ui-ff" }, - use { "Shougo/ddu-kind-file" }, - use { "Shougo/ddu-source-file_rec" }, - use { "shun/ddu-source-rg" }, - use { "Shougo/ddu-filter-matcher_substring" }, + { + "nvim-telescope/telescope-file-browser.nvim", + opt = true, + }, + { + "nvim-telescope/telescope-live-grep-args.nvim", + opt = true, + }, + { + "LinArcX/telescope-env.nvim", + opt = true, + }, + { + "nvim-telescope/telescope-fzf-native.nvim", + run = "make", + opt = true, + }, + }, + wants = { + "telescope-fzf-native.nvim", + "telescope-file-browser.nvim", + "telescope-live-grep-args.nvim", + "telescope-fzf-native.nvim", + "telescope-env.nvim", }, + setup = function() + local function builtin(name) + return function(opt) + return function() + return require("telescope.builtin")[name](opt or {}) + end + end + end + + local function extensions(name, prop) + return function(opt) + return function() + local telescope = require "telescope" + telescope.load_extension(name) + return telescope.extensions[name][prop](opt or {}) + end + end + end + + vim.keymap.set("n", "b", builtin("buffers") {}) + vim.keymap.set("n", "fb", extensions("file_browser", "file_browser") {}) + vim.keymap.set("n", "ff", builtin("find_files") {}) + vim.keymap.set("n", "lg", extensions("live_grep_args", "live_grep_args") {}) + end, config = function() - vim.fn['ddu#custom#patch_global']({ - ui = 'ff', - uiParams = { - ff = { - split = "floating", - startFilter = true, - prompt = "> ", + local telescope = require "telescope" + telescope.setup { + defaults = { + file_ignore_patterns = { + "vendor", "vendor/*", "./vendor", "./vendor/*", + "node_modules", }, }, - sources = { - { - name = "file_rec", - params = { - ignoredDirectories = { ".git", "node_modules", "vendor" }, - }, - } - }, - sourceOptions = { - ['_'] = { - matchers = { 'matcher_substring' } - } - }, - filterParams = { - matcher_substring = { - -- ignoreCase = true, - highlightMatched = "Title", + extensions = { + fzf = { + fuzzy = true, + override_generic_sorter = true, + override_file_sorter = true, + case_mode = "smart_case", }, - }, - kindOptions = { - file = { - defaultAction = 'open' - } - }, - }) - - vim.fn['ddu#custom#patch_local']("grep", { - sourceParams = { - rg = { - args = { "--column", "--no-heading", "--color", "never" }, + file_browser = { + hijack_netrw = true, }, - }, - uiParams = { - ff = { - startFilter = false, + live_grep_args = { + auto_quoting = true, }, }, - }) - end, + } + telescope.load_extension("fzf") + end } -- ddc.vim