This commit is contained in:
Young Xu 2023-03-27 01:02:15 +08:00
parent 08749c5930
commit 9e029254ed
Signed by: xuthus5
GPG Key ID: A23CF9620CBB55F9
17 changed files with 157 additions and 63 deletions

View File

@ -20,6 +20,7 @@ npm install eslint --global
npm install -g typescript typescript-language-server
npm install -g @volar/vue-language-server
npm install -g eslint_d
go install github.com/yoheimuta/protolint/cmd/protolint@latest
```
### 记忆项

105
ftplugin/proto.vim Normal file
View File

@ -0,0 +1,105 @@
" Protocol Buffers - Google's data interchange format
" Copyright 2008 Google Inc. All rights reserved.
" https://developers.google.com/protocol-buffers/
"
" Redistribution and use in source and binary forms, with or without
" modification, are permitted provided that the following conditions are
" met:
"
" * Redistributions of source code must retain the above copyright
" notice, this list of conditions and the following disclaimer.
" * Redistributions in binary form must reproduce the above
" copyright notice, this list of conditions and the following disclaimer
" in the documentation and/or other materials provided with the
" distribution.
" * Neither the name of Google Inc. nor the names of its
" contributors may be used to endorse or promote products derived from
" this software without specific prior written permission.
"
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
" This is the Vim syntax file for Google Protocol Buffers.
"
" Usage:
"
" 1. cp proto.vim ~/.vim/syntax/
" 2. Add the following to ~/.vimrc:
"
" augroup filetype
" au! BufRead,BufNewFile *.proto setfiletype proto
" augroup end
"
" Or just create a new file called ~/.vim/ftdetect/proto.vim with the
" previous lines on it.
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
syn case match
syn keyword pbTodo contained TODO FIXME XXX
syn cluster pbCommentGrp contains=pbTodo
syn keyword pbSyntax syntax import option
syn keyword pbStructure package message group oneof
syn keyword pbRepeat optional required repeated
syn keyword pbDefault default
syn keyword pbExtend extend extensions to max reserved
syn keyword pbRPC service rpc returns
syn keyword pbType int32 int64 uint32 uint64 sint32 sint64
syn keyword pbType fixed32 fixed64 sfixed32 sfixed64
syn keyword pbType float double bool string bytes
syn keyword pbTypedef enum
syn keyword pbBool true false
syn match pbInt /-\?\<\d\+\>/
syn match pbInt /\<0[xX]\x+\>/
syn match pbFloat /\<-\?\d*\(\.\d*\)\?/
syn region pbComment start="\/\*" end="\*\/" contains=@pbCommentGrp,@Spell
syn region pbComment start="//" skip="\\$" end="$" keepend contains=@pbCommentGrp,@Spell
syn region pbString start=/"/ skip=/\\./ end=/"/ contains=@Spell
syn region pbString start=/'/ skip=/\\./ end=/'/ contains=@Spell
if version >= 508 || !exists("did_proto_syn_inits")
if version < 508
let did_proto_syn_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
HiLink pbTodo Todo
HiLink pbSyntax Include
HiLink pbStructure Structure
HiLink pbRepeat Repeat
HiLink pbDefault Keyword
HiLink pbExtend Keyword
HiLink pbRPC Keyword
HiLink pbType Type
HiLink pbTypedef Typedef
HiLink pbBool Boolean
HiLink pbInt Number
HiLink pbFloat Float
HiLink pbComment Comment
HiLink pbString String
delcommand HiLink
endif
let b:current_syntax = "proto"

View File

@ -11,11 +11,11 @@ map.set({ "n", "v", "x" }, "=", "<cmd>lua vim.lsp.buf.format()<cr>", noreopt)
-- fine cmdline
map.set("n", ":", "<cmd>FineCmdline<CR>", noreopt)
-- telescope
map.set("n", "<leader>ff", "<cmd>Telescope find_files<cr>") -- find files within current working directory, respects .gitignore
map.set("n", "<leader>fs", "<cmd>Telescope live_grep<cr>") -- find string in current working directory as you type
map.set("n", "<leader>fc", "<cmd>Telescope grep_string<cr>") -- find string under cursor in current working directory
map.set("n", "<leader>fb", "<cmd>Telescope buffers<cr>") -- list open buffers in current neovim instance
map.set("n", "<leader>fh", "<cmd>Telescope help_tags<cr>") -- list available help tags
map.set("n", "<leader>ff", "<cmd>Telescope find_files<cr>") -- find files within current working directory, respects .gitignore
map.set("n", "<leader>fs", "<cmd>Telescope live_grep<cr>") -- find string in current working directory as you type
map.set("n", "<leader>fc", "<cmd>Telescope grep_string<cr>") -- find string under cursor in current working directory
map.set("n", "<leader>fb", "<cmd>Telescope buffers<cr>") -- list open buffers in current neovim instance
map.set("n", "<leader>fh", "<cmd>Telescope help_tags<cr>") -- list available help tags
map.set("n", "<leader>lds", "<cmd>Telescope lsp_document_symbols<cr>") -- list all functions/structs/classes/modules in the current buffer
-- 重置窗口大小
map.set("n", "<C-Up>", ":resize -2<CR>", noreopt)
@ -31,9 +31,9 @@ map.set("n", "<C-l>", "<C-w>l", noreopt)
map.set("n", "<leader>sv", ":vsp<CR>", noreopt)
map.set("n", "<leader>sh", ":sp<CR>", noreopt)
-- 代码块选择和移动
map.set({"n", "v"}, "L", "$", noreopt) -- 快速行尾
map.set({"n", "v"}, "H", "^", noreopt) -- 快速行首
map.set({"n", "v", "i"}, "<C-a>", "gg<S-v>G", noreopt) -- 全选
map.set({ "n", "v" }, "L", "$", noreopt) -- 快速行尾
map.set({ "n", "v" }, "H", "^", noreopt) -- 快速行首
map.set({ "n", "v", "i" }, "<C-a>", "gg<S-v>G", noreopt) -- 全选
map.set("n", "<A-j>", "<Esc>:m .+1<CR>==gi", noreopt)
map.set("n", "<A-k>", "<Esc>:m .-2<CR>==gi", noreopt)
map.set("v", "<", "<gv", noreopt)

View File

@ -79,4 +79,3 @@ vim.wo.foldexpr = "nvim_treesitter#foldexpr()"
-- 默认不要折叠
-- https://stackoverflow.com/questions/8316139/how-to-set-the-default-to-unfolded-when-you-open-a-file
vim.wo.foldlevel = 99

View File

@ -1 +1 @@
vim.cmd[[colorscheme tokyonight-storm]]
vim.cmd([[colorscheme tokyonight-storm]])

View File

@ -10,6 +10,7 @@ lsp_status.config({
})
require("lspconfig").clangd.setup({
filetypes = { "c", "cpp", "objc", "objcpp", "cuda" },
handlers = lsp_status.extensions.clangd.setup(),
init_options = {
clangdFileStatus = true,

View File

@ -9,8 +9,3 @@ require("lspconfig").jsonls.setup({
require("lspconfig").taplo.setup({})
require("lspconfig").yamlls.setup({})
require("lspconfig").bufls.setup({
capabilities = capabilities,
on_attach = common_lsp_on_attach,
})

View File

@ -1,19 +1,19 @@
require("bufferline").setup({
options = {
options = {
-- 使用 nvim 内置lsp
diagnostics = "nvim_lsp",
diagnostics = "nvim_lsp",
diagnostics_indicator = function(count, level, diagnostics_dict)
return "("..count..")"
end,
always_show_bufferline = false,
-- 左侧让出 nvim-tree 的位置
offsets = {
{
filetype = "NvimTree",
text = "File Explorer",
highlight = "Directory",
text_align = "left",
},
},
},
return "(" .. count .. ")"
end,
always_show_bufferline = false,
-- 左侧让出 nvim-tree 的位置
offsets = {
{
filetype = "NvimTree",
text = "File Explorer",
highlight = "Directory",
text_align = "left",
},
},
},
})

View File

@ -27,7 +27,7 @@ require("nvim-tree").setup({
renderer = {
group_empty = true,
},
})
})
local function open_nvim_tree(data)
-- buffer is a directory

View File

@ -1,9 +1,9 @@
require("go").setup()
local format_sync_grp = vim.api.nvim_create_augroup("GoImport", {})
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*.go",
callback = function()
require("go.format").goimport()
end,
group = format_sync_grp,
pattern = "*.go",
callback = function()
require("go.format").goimport()
end,
group = format_sync_grp,
})

View File

@ -3,8 +3,8 @@ vim.opt.listchars:append("space:⋅")
vim.opt.listchars:append("eol:↴")
require("indent_blankline").setup({
show_current_context = true,
show_current_context_start = true,
show_end_of_line = true,
space_char_blankline = " ",
show_current_context = true,
show_current_context_start = true,
show_end_of_line = true,
space_char_blankline = " ",
})

View File

@ -2,11 +2,11 @@ require("leap").add_default_mappings()
require("leap").opts.highlight_unlabeled_phase_one_targets = true
require("flit").setup({
keys = { f = "f", F = "F", t = "t", T = "T" },
-- A string like "nv", "nvo", "o", etc.
labeled_modes = "v",
multiline = true,
-- Like `leap`s similar argument (call-specific overrides).
-- E.g.: opts = { equivalence_classes = {} }
opts = {},
keys = { f = "f", F = "F", t = "t", T = "T" },
-- A string like "nv", "nvo", "o", etc.
labeled_modes = "v",
multiline = true,
-- Like `leap`s similar argument (call-specific overrides).
-- E.g.: opts = { equivalence_classes = {} }
opts = {},
})

View File

@ -11,5 +11,3 @@ require("lsp-colors").setup({
Information = "#0db9d7",
Hint = "#10B981",
})

View File

@ -20,7 +20,7 @@ require("lualine").setup({
sections = {
lualine_a = { "mode" },
lualine_b = { "branch", "diff", "diagnostics" },
lualine_c = { "filename", "lsp_progress" },
lualine_c = { "filename" },
lualine_x = { "encoding", "fileformat", "filetype" },
lualine_y = { "progress" },
lualine_z = { "location" },
@ -33,14 +33,7 @@ require("lualine").setup({
lualine_y = {},
lualine_z = {},
},
tabline = {
lualine_a = {},
lualine_b = { "branch" },
lualine_c = {},
lualine_x = {},
lualine_y = {},
lualine_z = {},
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {},

View File

@ -31,8 +31,6 @@ require("mason-lspconfig").setup({
"docker_compose_language_service",
"eslint",
"html",
"bufls",
},
automatic_installation = true,
})

View File

@ -1,11 +1,13 @@
local null_ls = require("null-ls")
null_ls.setup({
sources = {
null_ls.builtins.formatting.stylua,
sources = {
null_ls.builtins.formatting.stylua,
null_ls.builtins.formatting.gofmt,
null_ls.builtins.formatting.eslint_d,
null_ls.builtins.formatting.protolint,
-- 诊断
null_ls.builtins.diagnostics.eslint_d,
}
null_ls.builtins.diagnostics.protolint,
},
})

View File

@ -214,6 +214,8 @@ return require("packer").startup(function(use)
"mrjones2014/legendary.nvim",
requires = "kkharji/sqlite.lua",
})
-- protobuf 识别
use("wfxr/protobuf.vim")
-- 自动保存
if packer_bootstrap then
require("packer").sync()