From f299be3a65d7e7d06c05bd315dac54e09355bba8 Mon Sep 17 00:00:00 2001 From: gameloader Date: Mon, 12 Jun 2023 10:47:26 +0800 Subject: [PATCH] add autoinstall lsp and auto choose colortheme --- coc-settings.json | 0 init.lua | 6 +- lua/autocmd.lua | 14 ++++ lua/basic.lua | 3 +- lua/keybindings.lua | 10 ++- lua/lsp/config/csharp.lua | 1 + lua/lsp/config/r.lua | 1 + lua/lsp/init.lua | 3 + lua/lsp/null-ls.lua | 6 +- lua/plugin-config/dashboard.lua | 115 ++++++++++++++++++++++---------- lua/plugin-config/mason.lua | 5 +- lua/plugin-config/neotree.lua | 5 ++ lua/plugins.lua | 48 ++++++------- 13 files changed, 141 insertions(+), 76 deletions(-) create mode 100644 coc-settings.json create mode 100644 lua/lsp/config/csharp.lua create mode 100644 lua/lsp/config/r.lua create mode 100644 lua/plugin-config/neotree.lua diff --git a/coc-settings.json b/coc-settings.json new file mode 100644 index 0000000..e69de29 diff --git a/init.lua b/init.lua index 74cf420..0ce75f3 100644 --- a/init.lua +++ b/init.lua @@ -19,9 +19,10 @@ require("plugin-config/table-mode") require("plugin-config/mkdnflow") require("plugin-config/orgmode") require("plugin-config/project") -require("plugin-config/dashboard") -require("plugin-config/neoscroll") +-- require("plugin-config/dashboard") +-- require("plugin-config/neoscroll") require("plugin-config/hop") +require("plugin-config/neotree") require("plugin-config/live_command") require("plugin-config/jaq") require("plugin-config/toggleterm") @@ -31,6 +32,7 @@ require("plugin-config/lazygit") require("autocmd") require("lsp") require("lsp.cmp") +-- require("lsp.coc") require("lsp.null-ls") require("lsp.ui") diff --git a/lua/autocmd.lua b/lua/autocmd.lua index 6358daf..313f75c 100644 --- a/lua/autocmd.lua +++ b/lua/autocmd.lua @@ -15,11 +15,25 @@ function M.nvim_create_augroups(definitions) end end +function set_colorscheme() + local colorschemes = vim.fn.getcompletion("", "color") + local desired_colorscheme = "tokyonight-day" + + if vim.tbl_contains(colorschemes, desired_colorscheme) then + vim.cmd("colorscheme " .. desired_colorscheme) + else + vim.cmd("colorscheme default") + end +end + local autoCommands = { -- other autocommands open_folds = { { "FileReadPost", "*.md", "normal zx" }, }, + set_colorscheme = { + { "VimEnter", "*", "lua set_colorscheme()" }, + }, } M.nvim_create_augroups(autoCommands) diff --git a/lua/basic.lua b/lua/basic.lua index 1ca3588..a9b936d 100644 --- a/lua/basic.lua +++ b/lua/basic.lua @@ -8,6 +8,7 @@ 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 + fileencodings = "utf-8,cp936,gb18030,big5", 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 @@ -71,8 +72,6 @@ M.load_default_options = function() for k, v in pairs(let_options) do vim.g[k] = v end - - vim.cmd("colorscheme onenord") end return M diff --git a/lua/keybindings.lua b/lua/keybindings.lua index 1502eb9..1a3ba1e 100644 --- a/lua/keybindings.lua +++ b/lua/keybindings.lua @@ -82,12 +82,6 @@ wk.register({ }, }) ---一般映射方式 ---map("n", "wh", "h", opt) ---map("n", "wj", "j", opt) ---map("n", "wk", "k", opt) ---map("n", "wl", "l", opt) - -- base operation for visual mode -- 可视模式下基本操作 map("v", "<", "j"] = { ":HopLineStart", "Quick jump line" }, }) +-- 快速切换主题 +wk.register({ + ["c"] = { ":Telescope colorscheme", "Quick change colortheme" }, +}) map("n", "", "za", opt) -- insert 模式下ctrl a e跳转开头结尾 map("i", "", "I", opt) diff --git a/lua/lsp/config/csharp.lua b/lua/lsp/config/csharp.lua new file mode 100644 index 0000000..723c978 --- /dev/null +++ b/lua/lsp/config/csharp.lua @@ -0,0 +1 @@ +return require("lsp.config.basic_config") diff --git a/lua/lsp/config/r.lua b/lua/lsp/config/r.lua new file mode 100644 index 0000000..723c978 --- /dev/null +++ b/lua/lsp/config/r.lua @@ -0,0 +1 @@ +return require("lsp.config.basic_config") diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index 65f3d47..eeb6f02 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -9,6 +9,9 @@ local servers = { clangd = require("lsp.config.clangd"), gopls = require("lsp.config.gopls"), eslint = require("lsp.config.eslint"), + -- r_language_server = require("lsp.config.r"), + -- csharp_ls = require("lsp.config.csharp"), + omnisharp = require("lsp.config.csharp"), -- bashls = require("lsp.config.bash"), -- pyright = require("lsp.config.pyright"), pylsp = require("lsp.config.pylsp"), diff --git a/lua/lsp/null-ls.lua b/lua/lsp/null-ls.lua index d4d48d7..9e10ed5 100644 --- a/lua/lsp/null-ls.lua +++ b/lua/lsp/null-ls.lua @@ -13,7 +13,11 @@ end require("null-ls").setup({ sources = { require("null-ls").builtins.formatting.stylua, - require("null-ls").builtins.formatting.clang_format, + require("null-ls").builtins.formatting.styler, + require("null-ls").builtins.formatting.clang_format.with({ + disabled_filetypes = { "cs" }, + }), + require("null-ls").builtins.formatting.csharpier, require("null-ls").builtins.formatting.gofmt, require("null-ls").builtins.formatting.black, require("null-ls").builtins.formatting.eslint_d, diff --git a/lua/plugin-config/dashboard.lua b/lua/plugin-config/dashboard.lua index b6c2c03..489fabd 100644 --- a/lua/plugin-config/dashboard.lua +++ b/lua/plugin-config/dashboard.lua @@ -1,38 +1,81 @@ -local db = require("dashboard") -db.custom_header = { - "", - "┳┻| ", - "┻┳| ", - "┳┻|ヘ ∧ ", - "┻┳| ● w ● )", - "┳┻|⊂ノ ", - "┻┳|J ", - "", +-- local db = require("dashboard") +-- db.custom_header = { +-- "", +-- "┳┻| ", +-- "┻┳| ", +-- "┳┻|ヘ ∧ ", +-- "┻┳| ● w ● )", +-- "┳┻|⊂ノ ", +-- "┻┳|J ", +-- "", +-- } +require("dashboard").setup{ + custom_header = { + "", + "┳┻| ", + "┻┳| ", + "┳┻|ヘ ∧ ", + "┻┳| ● w ● )", + "┳┻|⊂ノ ", + "┻┳|J ", + "", + }, + custom_section = { + a = { + description = { " Find File " }, + command = "Telescope find_files find_command=rg,--hidden,--files", + }, + b = { + description = { " Recently Used Files" }, + command = "Telescope oldfiles", + }, + c = { + description = { " Find Word " }, + command = "Telescope live_grep", + }, + d = { + description = { "洛 New File " }, + command = "DashboardNewFile", + }, + e = { + description = { " Bookmarks " }, + command = "Telescope marks", + }, + f = { + description = { " Load Last Session " }, + command = "SessionLoad", + }, + }, + custom_footer = { + "Neovim", + }, } -db.custom_center = { - { - icon = " ", - desc = "Find File ", - action = "Telescope find_files find_command=rg,--hidden,--files", - shortcut = "SPC f f", - }, - { - icon = " ", - desc = "Recently opened files ", - action = "Telescope oldfiles", - shortcut = "SPC f r", - }, - { - icon = " ", - desc = "Open Project ", - action = "Telescope Project ", - shortcut = "SPC f p", - }, - { - icon = " ", - desc = "File Browser ", - action = "Telescope file_browser", - shortcut = "SPC f b", - }, -} + + +-- db.custom_center = { +-- { +-- icon = " ", +-- desc = "Find File ", +-- action = "Telescope find_files find_command=rg,--hidden,--files", +-- shortcut = "SPC f f", +-- }, +-- { +-- icon = " ", +-- desc = "Recently opened files ", +-- action = "Telescope oldfiles", +-- shortcut = "SPC f r", +-- }, +-- { +-- icon = " ", +-- desc = "Open Project ", +-- action = "Telescope Project ", +-- shortcut = "SPC f p", +-- }, +-- { +-- icon = " ", +-- desc = "File Browser ", +-- action = "Telescope file_browser", +-- shortcut = "SPC f b", +-- }, +-- } diff --git a/lua/plugin-config/mason.lua b/lua/plugin-config/mason.lua index 8b9f924..4aa9e3d 100644 --- a/lua/plugin-config/mason.lua +++ b/lua/plugin-config/mason.lua @@ -9,4 +9,7 @@ require("mason").setup({ }, }) -require("mason-lspconfig").setup() +require("mason-lspconfig").setup({ + automatic_installation = true, + ensure_installed = { "lua_ls", "clangd", "pyright" }, +}) diff --git a/lua/plugin-config/neotree.lua b/lua/plugin-config/neotree.lua new file mode 100644 index 0000000..8b48103 --- /dev/null +++ b/lua/plugin-config/neotree.lua @@ -0,0 +1,5 @@ +require("neo-tree").setup({ + window = { + width = "30%", -- Width of the Neo-tree window + }, +}) diff --git a/lua/plugins.lua b/lua/plugins.lua index f5adc80..309c214 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -5,24 +5,12 @@ return require("packer").startup(function() -- lua 调试 use("rafcamlet/nvim-luapad") ------------------ themes -------------------------- - -- Nova theme for neovim light - -- use({ - -- "zanglg/nova.nvim", - -- config = function() - -- -- support both dark and light style - -- require("nova").setup({ background = "light" }) - - -- -- load colorscheme - -- require("nova").load() - -- end, - -- }) - use("rmehri01/onenord.nvim") use({ "navarasu/onedark.nvim", }) - use("savq/melange") + use("folke/tokyonight.nvim") ----------------------------------------------------------------------------------------- @@ -45,14 +33,6 @@ return require("packer").startup(function() "iamcco/markdown-preview.nvim", }) - -- markdown table - -- 优化markdown添加表格 - -- use("dhruvasagar/vim-table-mode") - - -- nvim-markdown - -- markdown 增强 - -- use("ixru/nvim-markdown") - -- markdown flow and enhance -- markdown 流程和增强 use({ "jakewvincent/mkdnflow.nvim" }) @@ -79,15 +59,24 @@ return require("packer").startup(function() -- vim dashboard -- vim 开始界面 - use({ "glepnir/dashboard-nvim" }) + -- use({ + -- "glepnir/dashboard-nvim", + -- event = "VimEnter", + -- -- config = function() + -- -- require("dashboard").setup({ + -- -- -- config + -- -- }) + -- -- end, + -- requires = { "nvim-tree/nvim-web-devicons" }, + -- }) -- smooth neovim scroll -- 顺滑的neovim滚动 - use("karb94/neoscroll.nvim") + -- use("karb94/neoscroll.nvim") -- bufferline on the top -- 顶部状态栏 - use({ "akinsho/bufferline.nvim", requires = "kyazdani42/nvim-web-devicons" }) + use({ "akinsho/bufferline.nvim", tag = "v3.*", requires = "nvim-tree/nvim-web-devicons" }) -- 更方便的切换buffer -- use({ "matbme/JABS.nvim" }) @@ -146,7 +135,7 @@ return require("packer").startup(function() -- 底部状态栏 use({ "nvim-lualine/lualine.nvim", - requires = { "kyazdani42/nvim-web-devicons", opt = true }, + requires = { "nvim-tree/nvim-web-devicons", opt = true }, }) -- notify @@ -164,6 +153,7 @@ return require("packer").startup(function() -- coderunner -- 代码运行 use({ "is0n/jaq-nvim" }) + -- cmake support -- cmake 支持 use("Civitasv/cmake-tools.nvim") @@ -176,19 +166,21 @@ return require("packer").startup(function() "neovim/nvim-lspconfig", }) + -- coc-nvim complete + -- use({ "neoclide/coc.nvim", branch = "release" }) -- null-ls for formatter and others -- null-ls 用于格式化和其他 use({ "jose-elias-alvarez/null-ls.nvim", }) - -- 补全引擎 + -- -- 补全引擎 use("hrsh7th/nvim-cmp") -- Snippet 引擎 use({ "L3MON4D3/LuaSnip" }) - -- use("hrsh7th/vim-vsnip") + use("hrsh7th/vim-vsnip") -- 补全源 - -- use("hrsh7th/cmp-vsnip") + use("hrsh7th/cmp-vsnip") use({ "ray-x/lsp_signature.nvim" }) use({ "saadparwaiz1/cmp_luasnip" }) use("hrsh7th/cmp-nvim-lsp") -- { name = nvim_lsp }