diff --git a/init.lua b/init.lua index f840f19..18bbcab 100644 --- a/init.lua +++ b/init.lua @@ -17,6 +17,7 @@ require("plugin-config/nvim-autopairs") require("plugin-config/table-mode") require("plugin-config/project") require("plugin-config/dashboard") +require("plugin-config/JABS") require("plugin-config/toggleterm") require("plugin-config/coderunner") require("plugin-config/lazygit") diff --git a/lua/basic.lua b/lua/basic.lua index 9d7f4de..b4b7218 100644 --- a/lua/basic.lua +++ b/lua/basic.lua @@ -10,7 +10,7 @@ M.load_default_options = function() fileencoding = "utf-8", -- the encoding written to a file foldmethod = "manual", -- folding, set to "expr" for treesitter based folding foldexpr = "", -- set to "nvim_treesitter#foldexpr()" for treesitter based folding - guifont = "monospace:h17", -- the font used in graphical neovim applications + guifont = "Menlo:h17", -- the font used in graphical neovim applications background = "dark", -- set the background to light or dark hidden = true, -- required to keep multiple buffers and open multiple buffers hlsearch = true, -- highlight all matches on previous search pattern diff --git a/lua/keybindings.lua b/lua/keybindings.lua index ef676d5..3cf0d4d 100644 --- a/lua/keybindings.lua +++ b/lua/keybindings.lua @@ -48,6 +48,7 @@ wk.register({ name = "+File", p = { ":Telescope projects", "Open project" }, r = { ":Telescope oldfiles", "Recent files" }, + f = { ":Telescope file_browser", "File browser" }, n = { ":enew", "New file" }, }, }) @@ -84,7 +85,7 @@ map("v", "<", "", ">gv", opt) -- nvimTree -map("n", "n", ":NvimTreeToggle", opt) +map("n", "T", ":NvimTreeToggle", opt) -- Packer wk.register({ @@ -102,9 +103,8 @@ wk.register({ name = "+Buffer", k = { ":bd!", "Kill buffer" }, o = { ":BufferLineCloseRight:BufferLineCloseLeft", "Close other buffer" }, - b = { ":bp", "Last buffer" }, + b = { ":JABSOpen", "Open buffers" }, n = { ":ls", "Buffer numbers" }, - t = { ":b ", "To buffer" }, c = { ":noh", "Cancel highlight" }, }, }) diff --git a/lua/lsp/cmp.lua b/lua/lsp/cmp.lua index 9c7c414..8cdcbc5 100644 --- a/lua/lsp/cmp.lua +++ b/lua/lsp/cmp.lua @@ -1,6 +1,5 @@ local lspkind = require("lspkind") local cmp = require("cmp") - cmp.setup({ -- 指定 snippet 引擎 snippet = { @@ -78,3 +77,6 @@ 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 = "" } })) + +-- use friendly snippet +require("luasnip.loaders.from_vscode").lazy_load() diff --git a/lua/lsp/config/gopls.lua b/lua/lsp/config/gopls.lua new file mode 100644 index 0000000..15bdd57 --- /dev/null +++ b/lua/lsp/config/gopls.lua @@ -0,0 +1,21 @@ +return { + on_setup = function(server) + server.setup({ + flags = { + debounce_text_changes = 150, + }, + on_attach = function(client, bufnr) + -- 禁用格式化功能,交给专门插件插件处理 + client.server_capabilities.document_formatting = false + client.server_capabilities.document_range_formatting = false + + -- 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 + -- 绑定快捷键 + -- require("keybindings").mapLSP(buf_set_keymap) + end, + }) + end, +} diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index fdf65dd..3b1c0a6 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -5,26 +5,27 @@ local lspconfig = require("lspconfig") -- key 必须为下列网址列出的 server name,不可以随便写 -- https://github.com/williamboman/nvim-lsp-installer#available-lsps local servers = { - sumneko_lua = require("lsp.config.lua"), -- lua/lsp/config/lua.lua - clangd = require("lsp.config.clangd"), - -- bashls = require("lsp.config.bash"), - pyright = require("lsp.config.pyright"), - -- html = require("lsp.config.html"), - -- cssls = require("lsp.config.css"), - -- emmet_ls = require("lsp.config.emmet"), - -- jsonls = require("lsp.config.json"), - -- tsserver = require("lsp.config.ts"), - -- rust_analyzer = require("lsp.config.rust"), - -- yamlls = require("lsp.config.yamlls"), - -- remark_ls = require("lsp.config.markdown"), + sumneko_lua = require("lsp.config.lua"), -- lua/lsp/config/lua.lua + clangd = require("lsp.config.clangd"), + gopls = require("lsp.config.gopls"), + -- bashls = require("lsp.config.bash"), + pyright = require("lsp.config.pyright"), + -- html = require("lsp.config.html"), + -- cssls = require("lsp.config.css"), + -- emmet_ls = require("lsp.config.emmet"), + -- jsonls = require("lsp.config.json"), + -- tsserver = require("lsp.config.ts"), + -- rust_analyzer = require("lsp.config.rust"), + -- yamlls = require("lsp.config.yamlls"), + -- remark_ls = require("lsp.config.markdown"), } for name, config in pairs(servers) do - if config ~= nil and type(config) == "table" then - -- 自定义初始化配置文件必须实现on_setup 方法 - config.on_setup(lspconfig[name]) - else - -- 使用默认参数 - lspconfig[name].setup({}) - end + if config ~= nil and type(config) == "table" then + -- 自定义初始化配置文件必须实现on_setup 方法 + config.on_setup(lspconfig[name]) + else + -- 使用默认参数 + lspconfig[name].setup({}) + end end diff --git a/lua/lsp/null-ls.lua b/lua/lsp/null-ls.lua index f4f1d14..28c675b 100644 --- a/lua/lsp/null-ls.lua +++ b/lua/lsp/null-ls.lua @@ -14,6 +14,7 @@ require("null-ls").setup({ sources = { require("null-ls").builtins.formatting.stylua, require("null-ls").builtins.formatting.clang_format, + require("null-ls").builtins.formatting.gofmt, }, -- you can reuse a shared lspconfig on_attach callback here on_attach = function(client, bufnr) diff --git a/lua/plugin-config/JABS.lua b/lua/plugin-config/JABS.lua new file mode 100644 index 0000000..bb9cde3 --- /dev/null +++ b/lua/plugin-config/JABS.lua @@ -0,0 +1 @@ +require("jabs").setup({}) diff --git a/lua/plugin-config/telescope.lua b/lua/plugin-config/telescope.lua index 0d430ef..73435d0 100644 --- a/lua/plugin-config/telescope.lua +++ b/lua/plugin-config/telescope.lua @@ -1,32 +1,46 @@ -require('telescope').setup{ - defaults = { - -- Default configuration for telescope goes here: - -- config_key = value, - mappings = { - i = { - -- map actions.which_key to (default: ) - -- actions.which_key shows the mappings for your picker, - -- e.g. git_{create, delete, ...}_branch for the git_branches picker - [""] = "which_key" - } - } - }, - pickers = { - -- Default configuration for builtin pickers goes here: - -- picker_name = { - -- picker_config_key = value, - -- ... - -- } - -- Now the picker_config_key will be applied every time you call this - -- builtin picker - }, - extensions = { - -- Your extension configuration goes here: - -- extension_name = { - -- extension_config_key = value, - -- } - -- please take a look at the readme of the extension you want to configure - } -} +require("telescope").setup({ + defaults = { + -- Default configuration for telescope goes here: + -- config_key = value, + mappings = { + i = { + -- map actions.which_key to (default: ) + -- actions.which_key shows the mappings for your picker, + -- e.g. git_{create, delete, ...}_branch for the git_branches picker + [""] = "which_key", + }, + }, + }, + pickers = { + -- Default configuration for builtin pickers goes here: + -- picker_name = { + -- picker_config_key = value, + -- ... + -- } + -- Now the picker_config_key will be applied every time you call this + -- builtin picker + }, + extensions = { + file_browser = { + theme = "ivy", + -- disables netrw and use telescope-file-browser in its place + hijack_netrw = true, + mappings = { + ["i"] = { + -- your custom insert mode mappings + }, + ["n"] = { + -- your custom normal mode mappings + }, + -- Your extension configuration goes here: + -- extension_name = { + -- extension_config_key = value, + -- } + -- please take a look at the readme of the extension you want to configure + }, + }, + }, +}) -require('telescope').load_extension('projects') +require("telescope").load_extension("projects") +require("telescope").load_extension("file_browser") diff --git a/lua/plugins.lua b/lua/plugins.lua index ac9c64f..3d5f1f5 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -60,6 +60,9 @@ return require("packer").startup(function() -- 顶部状态栏 use({ "akinsho/bufferline.nvim", requires = "kyazdani42/nvim-web-devicons" }) + -- 更方便的切换buffer + use({ "matbme/JABS.nvim" }) + -- treesitter use({ "nvim-treesitter/nvim-treesitter", @@ -68,15 +71,18 @@ return require("packer").startup(function() end, }) + --------------------- file related ------------------------------- -- telescope use({ "nvim-telescope/telescope.nvim", requires = { { "nvim-lua/plenary.nvim" } }, }) + -- telescope-file-browser + use({ "nvim-telescope/telescope-file-browser.nvim" }) + -- project -- 项目管理 - -- Lua use({ "ahmedkhalf/project.nvim", }) diff --git a/readme.md b/readme.md index f9f767f..761611c 100644 --- a/readme.md +++ b/readme.md @@ -35,7 +35,7 @@ ### 常用 | key | function | |----------------|-------------------------------------------| -| n | 打开nvim-tree文件浏览 | +| T | 打开nvim-tree文件浏览 | | f | 打开telescope进行文件查找 | | Ctrl-h | 切换到左标签栏 | | Ctrl-l | 切换到右标签栏 | @@ -73,12 +73,18 @@ | \dc | 清理断点 | | \dr | 开始debug | | \ | step into | -| \ | step over | - - - - - +| \ | step over | + +### buffer +| key | function | +|-------------|----------------| +| \bb | 打开某个buffer | +| \bk | 关闭当前buffer | + +## 问题 + +### 根据文件类型启动某些功能 +可以在ftplugin文件夹中放入对应文件类型的lua文件,如markdown.lua对应markdown文件.写入要执行的命令即可.例子可见ftplugin/markdown中启动markdown table mode