change some buffers

This commit is contained in:
gameloader 2022-10-14 08:54:12 +08:00
parent c5128bda3c
commit 00b293c1d8
11 changed files with 116 additions and 63 deletions

View File

@ -17,6 +17,7 @@ require("plugin-config/nvim-autopairs")
require("plugin-config/table-mode") require("plugin-config/table-mode")
require("plugin-config/project") require("plugin-config/project")
require("plugin-config/dashboard") require("plugin-config/dashboard")
require("plugin-config/JABS")
require("plugin-config/toggleterm") require("plugin-config/toggleterm")
require("plugin-config/coderunner") require("plugin-config/coderunner")
require("plugin-config/lazygit") require("plugin-config/lazygit")

View File

@ -10,7 +10,7 @@ M.load_default_options = function()
fileencoding = "utf-8", -- the encoding written to a file fileencoding = "utf-8", -- the encoding written to a file
foldmethod = "manual", -- folding, set to "expr" for treesitter based folding foldmethod = "manual", -- folding, set to "expr" for treesitter based folding
foldexpr = "", -- set to "nvim_treesitter#foldexpr()" 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 background = "dark", -- set the background to light or dark
hidden = true, -- required to keep multiple buffers and open multiple buffers hidden = true, -- required to keep multiple buffers and open multiple buffers
hlsearch = true, -- highlight all matches on previous search pattern hlsearch = true, -- highlight all matches on previous search pattern

View File

@ -48,6 +48,7 @@ wk.register({
name = "+File", name = "+File",
p = { ":Telescope projects<CR>", "Open project" }, p = { ":Telescope projects<CR>", "Open project" },
r = { ":Telescope oldfiles<CR>", "Recent files" }, r = { ":Telescope oldfiles<CR>", "Recent files" },
f = { ":Telescope file_browser<CR>", "File browser" },
n = { ":enew<CR>", "New file" }, n = { ":enew<CR>", "New file" },
}, },
}) })
@ -84,7 +85,7 @@ map("v", "<", "<gv", opt)
map("v", ">", ">gv", opt) map("v", ">", ">gv", opt)
-- nvimTree -- nvimTree
map("n", "n", ":NvimTreeToggle<CR>", opt) map("n", "T", ":NvimTreeToggle<CR>", opt)
-- Packer -- Packer
wk.register({ wk.register({
@ -102,9 +103,8 @@ wk.register({
name = "+Buffer", name = "+Buffer",
k = { ":bd!<CR>", "Kill buffer" }, k = { ":bd!<CR>", "Kill buffer" },
o = { ":BufferLineCloseRight<CR>:BufferLineCloseLeft<CR>", "Close other buffer" }, o = { ":BufferLineCloseRight<CR>:BufferLineCloseLeft<CR>", "Close other buffer" },
b = { ":bp<CR>", "Last buffer" }, b = { ":JABSOpen<CR>", "Open buffers" },
n = { ":ls<CR>", "Buffer numbers" }, n = { ":ls<CR>", "Buffer numbers" },
t = { ":b ", "To buffer" },
c = { ":noh<CR>", "Cancel highlight" }, c = { ":noh<CR>", "Cancel highlight" },
}, },
}) })

View File

@ -1,6 +1,5 @@
local lspkind = require("lspkind") local lspkind = require("lspkind")
local cmp = require("cmp") local cmp = require("cmp")
cmp.setup({ cmp.setup({
-- 指定 snippet 引擎 -- 指定 snippet 引擎
snippet = { snippet = {
@ -78,3 +77,6 @@ require("lsp_signature").setup(signature_config)
local cmp_autopairs = require("nvim-autopairs.completion.cmp") local cmp_autopairs = require("nvim-autopairs.completion.cmp")
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } })) cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } }))
-- use friendly snippet
require("luasnip.loaders.from_vscode").lazy_load()

21
lua/lsp/config/gopls.lua Normal file
View File

@ -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,
}

View File

@ -7,6 +7,7 @@ local lspconfig = require("lspconfig")
local servers = { local servers = {
sumneko_lua = require("lsp.config.lua"), -- lua/lsp/config/lua.lua sumneko_lua = require("lsp.config.lua"), -- lua/lsp/config/lua.lua
clangd = require("lsp.config.clangd"), clangd = require("lsp.config.clangd"),
gopls = require("lsp.config.gopls"),
-- bashls = require("lsp.config.bash"), -- bashls = require("lsp.config.bash"),
pyright = require("lsp.config.pyright"), pyright = require("lsp.config.pyright"),
-- html = require("lsp.config.html"), -- html = require("lsp.config.html"),

View File

@ -14,6 +14,7 @@ require("null-ls").setup({
sources = { sources = {
require("null-ls").builtins.formatting.stylua, require("null-ls").builtins.formatting.stylua,
require("null-ls").builtins.formatting.clang_format, require("null-ls").builtins.formatting.clang_format,
require("null-ls").builtins.formatting.gofmt,
}, },
-- you can reuse a shared lspconfig on_attach callback here -- you can reuse a shared lspconfig on_attach callback here
on_attach = function(client, bufnr) on_attach = function(client, bufnr)

View File

@ -0,0 +1 @@
require("jabs").setup({})

View File

@ -1,4 +1,4 @@
require('telescope').setup{ require("telescope").setup({
defaults = { defaults = {
-- Default configuration for telescope goes here: -- Default configuration for telescope goes here:
-- config_key = value, -- config_key = value,
@ -7,9 +7,9 @@ require('telescope').setup{
-- map actions.which_key to <C-h> (default: <C-/>) -- map actions.which_key to <C-h> (default: <C-/>)
-- actions.which_key shows the mappings for your picker, -- actions.which_key shows the mappings for your picker,
-- e.g. git_{create, delete, ...}_branch for the git_branches picker -- e.g. git_{create, delete, ...}_branch for the git_branches picker
["<C-h>"] = "which_key" ["<C-h>"] = "which_key",
} },
} },
}, },
pickers = { pickers = {
-- Default configuration for builtin pickers goes here: -- Default configuration for builtin pickers goes here:
@ -21,12 +21,26 @@ require('telescope').setup{
-- builtin picker -- builtin picker
}, },
extensions = { 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: -- Your extension configuration goes here:
-- extension_name = { -- extension_name = {
-- extension_config_key = value, -- extension_config_key = value,
-- } -- }
-- please take a look at the readme of the extension you want to configure -- 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")

View File

@ -60,6 +60,9 @@ return require("packer").startup(function()
-- 顶部状态栏 -- 顶部状态栏
use({ "akinsho/bufferline.nvim", requires = "kyazdani42/nvim-web-devicons" }) use({ "akinsho/bufferline.nvim", requires = "kyazdani42/nvim-web-devicons" })
-- 更方便的切换buffer
use({ "matbme/JABS.nvim" })
-- treesitter -- treesitter
use({ use({
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
@ -68,15 +71,18 @@ return require("packer").startup(function()
end, end,
}) })
--------------------- file related -------------------------------
-- telescope -- telescope
use({ use({
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
requires = { { "nvim-lua/plenary.nvim" } }, requires = { { "nvim-lua/plenary.nvim" } },
}) })
-- telescope-file-browser
use({ "nvim-telescope/telescope-file-browser.nvim" })
-- project -- project
-- 项目管理 -- 项目管理
-- Lua
use({ use({
"ahmedkhalf/project.nvim", "ahmedkhalf/project.nvim",
}) })

View File

@ -35,7 +35,7 @@
### 常用 ### 常用
| key | function | | key | function |
|----------------|-------------------------------------------| |----------------|-------------------------------------------|
| n | 打开nvim-tree文件浏览 | | T | 打开nvim-tree文件浏览 |
| f | 打开telescope进行文件查找 | | f | 打开telescope进行文件查找 |
| Ctrl-h | 切换到左标签栏 | | Ctrl-h | 切换到左标签栏 |
| Ctrl-l | 切换到右标签栏 | | Ctrl-l | 切换到右标签栏 |
@ -75,10 +75,16 @@
| \<Ctrl-n> | step into | | \<Ctrl-n> | step into |
| \<Ctrl-o> | step over | | \<Ctrl-o> | step over |
### buffer
| key | function |
|-------------|----------------|
| \<leader>bb | 打开某个buffer |
| \<leader>bk | 关闭当前buffer |
## 问题
### 根据文件类型启动某些功能
可以在ftplugin文件夹中放入对应文件类型的lua文件,如markdown.lua对应markdown文件.写入要执行的命令即可.例子可见ftplugin/markdown中启动markdown table mode