add pyright and buffer code folder, markdwon use mdflow

This commit is contained in:
gameloader 2022-11-13 10:33:18 +08:00
parent e9d69cba33
commit 3eee395fbf
18 changed files with 201 additions and 76 deletions

3
.gitignore vendored
View File

@ -1 +1,4 @@
plugin
.DS_Store
snippets/go.json

View File

@ -1 +1 @@
vim.cmd("TableModeEnable")
-- vim.cmd("TableModeEnable")

View File

@ -14,7 +14,9 @@ require("plugin-config/mason")
require("plugin-config/lua_line")
require("plugin-config/notify")
require("plugin-config/nvim-autopairs")
require("plugin-config/lua_snip")
require("plugin-config/table-mode")
require("plugin-config/mkdnflow")
require("plugin-config/orgmode")
require("plugin-config/project")
require("plugin-config/dashboard")
@ -28,6 +30,7 @@ require("plugin-config/coderunner")
require("plugin-config/lazygit")
-- require("plugin-config/neogit")
require("autocmd")
require("lsp")
require("lsp.cmp")
require("lsp.null-ls")

26
lua/autocmd.lua Normal file
View File

@ -0,0 +1,26 @@
local vim = vim
local api = vim.api
local M = {}
-- function to create a list of commands and convert them to autocommands
-------- This function is taken from https://github.com/norcalli/nvim_utils
function M.nvim_create_augroups(definitions)
for group_name, definition in pairs(definitions) do
api.nvim_command("augroup " .. group_name)
api.nvim_command("autocmd!")
for _, def in ipairs(definition) do
local command = table.concat(vim.tbl_flatten({ "autocmd", def }), " ")
api.nvim_command(command)
end
api.nvim_command("augroup END")
end
end
local autoCommands = {
-- other autocommands
open_folds = {
{ "BufEnter", "*", "normal zx" },
{ "BufEnter", "*", "normal zR" },
},
}
M.nvim_create_augroups(autoCommands)

View File

@ -8,8 +8,6 @@ M.load_default_options = function()
completeopt = { "menuone", "noselect" },
conceallevel = 0, -- so that `` is visible in markdown files
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 = "FiraCode Nerd Font:h20", -- the font used in graphical neovim applications
background = "light", -- set the background to light or dark
hidden = true, -- required to keep multiple buffers and open multiple buffers
@ -27,6 +25,10 @@ M.load_default_options = function()
autochdir = true, -- auto change working directory
termguicolors = true, -- set term gui colors (most terminals support this)
timeoutlen = 1000, -- time to wait for a mapped sequence to complete (in milliseconds)
-- foldmethod = "manual", -- folding, set to "expr" for treesitter based folding
-- foldexpr = "", -- set to "nvim_treesitter#foldexpr()" for treesitter based folding
foldmethod = "expr",
foldexpr = "nvim_treesitter#foldexpr()",
title = true, -- set the title of window to the value of the titlestring
-- opt.titlestring = "%<%F%=%l/%L - nvim" -- what the title of the window will be set to
-- undodir = undodir, -- set an undo directory
@ -39,6 +41,7 @@ M.load_default_options = function()
cursorline = true, -- highlight the current line
number = true, -- set numbered lines
numberwidth = 4, -- set number column width to 2 {default 4}
relativenumber = true, -- set relative numbered lines
signcolumn = "yes", -- always show the sign column, otherwise it would shift the text each time
wrap = true, -- display lines as one long line
-- shadafile = join_paths(get_cache_dir(), "lvim.shada"),

View File

@ -9,7 +9,7 @@ local wk = require("which-key")
-- basic operation for write and quit
-- 文件写入退出基本操作
wk.register({
["<Leader>s"] = { ":w<CR>", "Save File" },
["<Leader>s"] = { ":w!<CR>", "Save File" },
["<Leader>q"] = { ":qa<CR>", "Quit All" },
["<Leader>S"] = { ":wa<CR>", "Save All" },
})
@ -25,6 +25,8 @@ pluginKeys.maplsp = function(mapbuf)
-- diagnostic
mapbuf("n", "]p", "<cmd>lua vim.diagnostic.goto_prev()<CR>", opt)
mapbuf("n", "]n", "<cmd>lua vim.diagnostic.goto_next()<CR>", opt)
mapbuf("n", "]a", "<cmd>lua vim.lsp.buf.code_action()<CR>", opt)
mapbuf("n", "]h", "<cmd>lua vim.lsp.buf.hover()<CR>", opt)
end
-- code related
@ -37,14 +39,6 @@ wk.register({
["<Leader>m"] = { ":MarkdownPreview<CR>", "Markdown preview" },
})
-- markdown table
-- markdown 表格
wk.register({
["<Leader>t"] = {
name = "",
},
})
-- git related
-- git 相关
wk.register({
@ -61,9 +55,10 @@ wk.register({
name = "+File",
p = { ":Telescope projects<CR>", "Open project" },
r = { ":Telescope oldfiles<CR>", "Recent files" },
f = { ":Telescope file_browser<CR>", "File browser" },
b = { ":Telescope file_browser<CR>", "File browser" },
n = { ":AdvancedNewFile<CR>", "New file" },
s = { ":Telescope live_grep<CR>", "Search in project" },
f = { ":Telescope find_files<CR>", "Search file" },
},
})
@ -123,7 +118,11 @@ wk.register({
s = { ":Telescope current_buffer_fuzzy_find<CR>", "Searching in buffer" },
},
})
wk.register({
["<Leader>j"] = { ":HopLineStart<CR>", "Quick jump line" },
})
map("n", "<Tab>", "za", opt)
-- insert 模式下ctrl a e跳转开头结尾
map("i", "<C-a>", "<C-o>I", opt)
map("i", "<C-e>", "<C-o>A", opt)
@ -142,15 +141,14 @@ wk.register({
i = { ":LspInstall<CR>", "Install lsp" },
I = { ":MasonInstall ", "Install any" },
r = { ":LspRestart<CR>", "Lsp restart" },
l = { ":Mason<CR>", "Mason info" },
m = { ":Mason<CR>", "Mason info" },
u = { ":MasonUninstall<CR>", "Uninstall lsp" },
U = { ":MasonUninstallAll<CR>", "Unistall all" },
l = { ":LspInfo<CR>", "Lsp infos" },
R = { vim.lsp.buf.rename, "Buffer var rename" },
},
})
-- Telescope
map("n", "f", ":Telescope find_files<CR>", opt)
-- cmpeletion keys
-- 补全快捷键
pluginKeys.cmp = function(cmp)

View File

@ -81,3 +81,4 @@ cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex =
-- use friendly snippet
require("luasnip.loaders.from_vscode").lazy_load()
require("luasnip.loaders.from_vscode").lazy_load({ paths = "~/.config/nvim/snippets" })

View File

@ -11,6 +11,7 @@ local servers = {
eslint = require("lsp.config.eslint"),
-- bashls = require("lsp.config.bash"),
pyright = require("lsp.config.pyright"),
-- jedi_language_server = require("lsp.config.jedi"),
vuels = require("lsp.config.vue"),
-- html = require("lsp.config.html"),
-- cssls = require("lsp.config.css"),

View File

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

View File

@ -15,7 +15,7 @@ db.custom_center = {
icon = "",
desc = "Find File ",
action = "Telescope find_files find_command=rg,--hidden,--files",
shortcut = " f",
shortcut = "SPC f f",
},
{
icon = "",
@ -33,6 +33,6 @@ db.custom_center = {
icon = "",
desc = "File Browser ",
action = "Telescope file_browser",
shortcut = "SPC f f",
shortcut = "SPC f b",
},
}

View File

@ -2,9 +2,10 @@ require("hop").setup({})
--- place this in one of your configuration file(s)
local hop = require("hop")
local directions = require("hop.hint").HintDirection
-- vim.keymap.set("", "f", function()
-- hop.hint_char1({ direction = directions.AFTER_CURSOR, current_line_only = true })
-- end, { remap = true })
vim.keymap.set("", "f", function()
hop.hint_patterns({ direction = directions.AFTER_CURSOR, current_line_only = true }, "\\u")
end, { remap = true })
vim.keymap.set("", "F", function()
hop.hint_char1({ direction = directions.BEFORE_CURSOR, current_line_only = true })
end, { remap = true })

View File

@ -0,0 +1,60 @@
local ls = require("luasnip")
local s = ls.snippet
local sn = ls.snippet_node
local isn = ls.indent_snippet_node
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local c = ls.choice_node
local d = ls.dynamic_node
local r = ls.restore_node
local events = require("luasnip.util.events")
local ai = require("luasnip.nodes.absolute_indexer")
local extras = require("luasnip.extras")
local l = extras.lambda
local rep = extras.rep
local p = extras.partial
local m = extras.match
local n = extras.nonempty
local dl = extras.dynamic_lambda
local fmt = require("luasnip.extras.fmt").fmt
local fmta = require("luasnip.extras.fmt").fmta
local conds = require("luasnip.extras.expand_conditions")
local postfix = require("luasnip.extras.postfix").postfix
local types = require("luasnip.util.types")
local parse = require("luasnip.util.parser").parse_snippet
local date = function()
return { os.date("%Y-%m-%d") }
end
ls.add_snippets("all", {
s({
trig = "date",
name = "Date",
dscr = "Date in the form of YYYY-MM-DD",
}, {
f(date, {}),
}),
})
ls.add_snippets("markdown", {
s({ trig = "meta", name = "Metadata", dscr = "Yaml metadata format for markdown" }, {
t({ "---", "title: " }),
i(1, "note_title"),
t({ "", "author: " }),
i(2, "Logic"),
t({ "", "date: " }),
f(date, {}),
t({ "", 'categories: ["' }),
i(3, ""),
t({ '"]', "tags: [" }),
i(4),
t({ "]", "draft: " }),
i(5, "false"),
t({ "", "", "---", "" }),
i(0),
}),
})
require("luasnip.loaders.from_lua").lazy_load({ include = { "all", "markdown" } })

View File

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

View File

@ -1,5 +1,5 @@
local let_table_settings = {}
-- local let_table_settings = {}
for k, v in pairs(let_table_settings) do
vim.g[k] = v
end
-- for k, v in pairs(let_table_settings) do
-- vim.g[k] = v
-- end

View File

@ -1,4 +1,4 @@
require'nvim-treesitter.configs'.setup {
require("nvim-treesitter.configs").setup({
-- A list of parser names, or "all"
ensure_installed = {},
@ -22,7 +22,7 @@ require'nvim-treesitter.configs'.setup {
-- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is
-- the name of the parser)
-- list of language that will be disabled
disable = { "c", "rust" },
-- disable = { "c", "rust" },
-- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files
disable = function(lang, buf)
local max_filesize = 100 * 1024 -- 100 KB
@ -52,4 +52,4 @@ require'nvim-treesitter.configs'.setup {
json = "",
},
},
}
})

View File

@ -47,11 +47,15 @@ return require("packer").startup(function()
-- markdown table
-- 优化markdown添加表格
use("dhruvasagar/vim-table-mode")
-- use("dhruvasagar/vim-table-mode")
-- nvim-markdown
-- markdown 增强
use("ixru/nvim-markdown")
-- use("ixru/nvim-markdown")
-- markdown flow and enhance
-- markdown 流程和增强
use({ "jakewvincent/mkdnflow.nvim" })
-- orgmode support
-- orgmode 支持
@ -127,6 +131,7 @@ return require("packer").startup(function()
"phaazon/hop.nvim",
branch = "v2", -- optional but strongly recommended
})
-- lualine for bottom stausline
-- 底部状态栏
use({

View File

@ -44,6 +44,7 @@
| \<leader>s | 保存当前文件 |
| \<leader>S | 保存所有文件 |
| \<leader><tab> | 切换回上一个buffer,用于两buffer间来回切换 |
| \<leader>j | 快速进行行跳转 |
| , | 运行当前文件代码,需要自行配置各种语言 |
| Ctrl-\\ | 打开终端 |
@ -133,3 +134,5 @@

19
snippets/package.json Normal file
View File

@ -0,0 +1,19 @@
{
"name":"my-snippets",
"contributes":{
"snippets":[
{
"language":[
"go"
],
"path":"./go.json"
},
{
"language":[
"markdown"
],
"path":"./markdown.json"
}
]
}
}