From 98c76f67f2d82e5426c1a4dfb14d427ee3fb1bc0 Mon Sep 17 00:00:00 2001 From: hyper Date: Sun, 6 Oct 2024 16:05:50 +0800 Subject: [PATCH] fix cmp & invert ff/fb & conform --- lua/plugins/editing.lua | 4 ++-- lua/plugins/tsdev.lua | 30 +++++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/lua/plugins/editing.lua b/lua/plugins/editing.lua index 6682c6d..01f72ba 100644 --- a/lua/plugins/editing.lua +++ b/lua/plugins/editing.lua @@ -69,8 +69,8 @@ return { vim.keymap.set('n', 'cr', builtin.lsp_references, { desc = 'Telescope lsp references' }) vim.keymap.set('n', 'cs', builtin.treesitter, { desc = 'Telescope treesitter' }) - vim.keymap.set('n', 'ff', builtin.find_files, { desc = 'Telescope find files' }) - vim.keymap.set('n', 'fb', function() + vim.keymap.set('n', 'fp', builtin.find_files, { desc = 'Telescope find in project' }) + vim.keymap.set('n', 'ff', function() builtin.find_files({ cwd = utils.buffer_dir() }) end, { desc = 'Telescope find in buffer dir' }) diff --git a/lua/plugins/tsdev.lua b/lua/plugins/tsdev.lua index 4801e50..4e2637e 100644 --- a/lua/plugins/tsdev.lua +++ b/lua/plugins/tsdev.lua @@ -15,7 +15,8 @@ return { "hrsh7th/cmp-path", }, config = function() - require('cmp').setup({ + local cmp = require('cmp') + cmp.setup({ completion = { keyword_length = 1, max_item_count = 6 @@ -24,6 +25,11 @@ return { { name = "nvim_lsp", keyword_length = 1, max_item_count = 6 }, { name = "buffer", keyword_length = 1, max_item_count = 6 }, { name = "path", keyword_length = 1, max_item_count = 6 }, + }, + mapping = { + [''] = cmp.mapping(cmp.mapping.select_next_item(), {'i', 'c'}), + [''] = cmp.mapping(cmp.mapping.select_prev_item(), {'i', 'c'}), + [''] = cmp.mapping.confirm({ select = true }), -- accept currently selected item } }) end @@ -40,6 +46,28 @@ return { indent = { enable = true }, }) end + }, + { + 'stevearc/conform.nvim', + opts = {}, + config = function() + require("conform").setup({ + formatters_by_ft = { + -- lua = { "stylua" }, + -- Conform will run multiple formatters sequentially + -- python = { "isort", "black" }, + -- You can customize some of the format options for the filetype (:help conform.format) + -- rust = { "rustfmt", lsp_format = "fallback" }, + -- Conform will run the first available formatter + javascript = { "prettierd" }, + typescript = { "prettierd" }, + css = { "prettierd" }, + less = { "prettierd" }, + html = { "prettierd" }, + }, + }) + end } + }