From b479bab0313e34dba48ac4e2db524b28be810a2d Mon Sep 17 00:00:00 2001 From: d0zingcat Date: Wed, 24 Aug 2022 11:55:57 +0800 Subject: [PATCH] upgrade lsp-setup --- .zshrc | 10 ++- git/config | 8 +- nvim/lua/config/lsp-setup.lua | 79 ++++++++++++++++++++ nvim/lua/config/nvim-lsp-setup.lua | 113 ----------------------------- nvim/lua/plugins.lua | 17 +++-- stylua.toml | 2 - wezterm/wezterm.lua | 10 +++ 7 files changed, 111 insertions(+), 128 deletions(-) create mode 100644 nvim/lua/config/lsp-setup.lua delete mode 100644 nvim/lua/config/nvim-lsp-setup.lua delete mode 100644 stylua.toml diff --git a/.zshrc b/.zshrc index 44a8113..7b195de 100644 --- a/.zshrc +++ b/.zshrc @@ -41,12 +41,13 @@ antigen bundle kubectl antigen bundle vi-mode antigen bundle autojump antigen bundle pip -antigen bundle pipenv +#antigen bundle pipenv antigen bundle asdf -antigen bundle dotenv +#antigen bundle dotenv antigen bundle nvim antigen bundle Aloxaf/fzf-tab antigen bundle wbingli/zsh-wakatime +antigen bundle darvid/zsh-poetry antigen bundle zsh-users/zsh-autosuggestions antigen bundle zsh-users/zsh-syntax-highlighting @@ -54,6 +55,9 @@ antigen bundle zsh-users/zsh-completions antigen apply +source <(kubectl completion zsh) +source <(helm completion zsh) + zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} eval "$(starship init zsh)" @@ -143,8 +147,6 @@ fi #autoload -U +X compinit && compinit #autoload -U +X bashcompinit && bashcompinit -source <(kubectl completion zsh) -source <(helm completion zsh) #compdef __start_kubectl k diff --git a/git/config b/git/config index 0815a29..8aea47e 100644 --- a/git/config +++ b/git/config @@ -1,10 +1,12 @@ [init] defaultBranch = main [user] - email = leewtang@gmail.com - name = d0zingcat - signingkey = 6185322F + email = i@d0zingcat.dev + name = d0zingcat + signingkey = 39E301C2 [url "ssh://git@github.com/"] insteadOf = https://github.com/ [core] excludesfile = /Users/d0zingcat/.config/git/.gitignore +[commit] + gpgsign = true diff --git a/nvim/lua/config/lsp-setup.lua b/nvim/lua/config/lsp-setup.lua new file mode 100644 index 0000000..9b3674a --- /dev/null +++ b/nvim/lua/config/lsp-setup.lua @@ -0,0 +1,79 @@ +local utils = require('lsp-setup.utils') +local mappings = { + -- Example mappings for telescope pickers + gd = 'lua require"telescope.builtin".lsp_definitions()', + gi = 'lua require"telescope.builtin".lsp_implementations()', + gr = 'lua require"telescope.builtin".lsp_references()', + go = 'lua require"telescope.builtin".lsp_document_symbols()' +} + +local servers = { + bashls = {}, + yamlls = { + filetypes = { 'yaml', 'yml' }, + settings = { + yaml = { + schemas = { + ['https://json.schemastore.org/github-workflow.json'] = '/.github/workflows/*', + Kubernetes = { '/*k8s.yaml', '/*k8s.yml' }, + --['https://raw.githubusercontent.com/instrumenta/kubernetes-json-schema/master/v1.18.0-standalone-strict/all.json'] = '/*.k8s.yaml', + }, + }, + }, + }, + eslint = {}, + jsonls = {}, + clangd = require('nvim-lsp-setup.clangd_extensions').setup(), + gopls = { + settings = { + golsp = { + gofumpt = true, + staticcheck = true, + useplaceholders = true, + codelenses = { + gc_details = true, + }, + }, + }, + }, + tsserver = {}, + prosemd_lsp = {}, + + pylsp = {}, + rust_analyzer = { + server = { + settings = { + ['rust-analyzer'] = { + cargo = { + loadOutDirsFromCheck = true, + }, + procMacro = { + enable = true, + }, + }, + }, + }, + }, + sumneko_lua = require('lua-dev').setup({ + lspconfig = { + on_attach = function(client, _) + utils.disable_formatting(client) + end, + }, + }), +} + +local settings = { + default_mappings = true, + mappings = mappings, + servers = servers, +} + +require('lsp-setup').setup(settings) + +require('lsp_signature').setup({}) +require('lsp-colors').setup({}) + +local border = { '╭', '─', '╮', '│', '╯', '─', '╰', '│' } +vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = border }) +vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = border }) diff --git a/nvim/lua/config/nvim-lsp-setup.lua b/nvim/lua/config/nvim-lsp-setup.lua deleted file mode 100644 index d2552a5..0000000 --- a/nvim/lua/config/nvim-lsp-setup.lua +++ /dev/null @@ -1,113 +0,0 @@ -local utils = require('nvim-lsp-setup.utils') -local mappings = { - -- Example mappings for telescope pickers - gd = 'lua require"telescope.builtin".lsp_definitions()', - gi = 'lua require"telescope.builtin".lsp_implementations()', - gr = 'lua require"telescope.builtin".lsp_references()', - go = 'lua require"telescope.builtin".lsp_document_symbols()' -} - -local servers = { - -- Automatically install lsp server - -- LSP server configuration please see: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md - bashls = {}, - yamlls = { - filetypes = { 'yaml', 'yml' }, - settings = { - yaml = { - schemas = { - ['https://json.schemastore.org/github-workflow.json'] = '/.github/workflows/*', - Kubernetes = { '/*k8s.yaml', '/*k8s.yml' }, - --['https://raw.githubusercontent.com/instrumenta/kubernetes-json-schema/master/v1.18.0-standalone-strict/all.json'] = '/*.k8s.yaml', - }, - }, - }, - }, - eslint = {}, - jsonls = {}, - clangd = require('nvim-lsp-setup.clangd_extensions').setup(), - gopls = { - settings = { - golsp = { - gofumpt = true, - staticcheck = true, - useplaceholders = true, - codelenses = { - gc_details = true, - }, - }, - }, - }, - tsserver = {}, - prosemd_lsp = {}, - - pylsp = {}, - rust_analyzer = { - server = { - settings = { - ['rust-analyzer'] = { - cargo = { - loadOutDirsFromCheck = true, - }, - procMacro = { - enable = true, - }, - }, - }, - }, - }, - -- Setup sumneko_lua with lua-dev - sumneko_lua = require('lua-dev').setup({ - lspconfig = { - on_attach = function(client, _) - -- Disable formatting - utils.disable_formatting(client) - end, - }, - }), - } - -local settings = { - default_mappings = true, - -- Default mappings - -- gD = 'lua vim.lsp.buf.declaration()', - -- gd = 'lua vim.lsp.buf.definition()', - -- gt = 'lua vim.lsp.buf.type_definition()', - -- gi = 'lua vim.lsp.buf.implementation()', - -- gr = 'lua vim.lsp.buf.references()', - -- K = 'lua vim.lsp.buf.hover()', - -- [''] = 'lua vim.lsp.buf.signature_help()', - -- ['rn'] = 'lua vim.lsp.buf.rename()', - -- ['ca'] = 'lua vim.lsp.buf.code_action()', - -- ['f'] = 'lua vim.lsp.buf.formatting()', - -- ['e'] = 'lua vim.lsp.diagnostic.show_line_diagnostics()', - -- ['[d'] = 'lua vim.lsp.diagnostic.goto_prev()', - -- [']d'] = 'lua vim.lsp.diagnostic.goto_next()', - mappings = mappings, - -- Global on_attach - -- on_attach = function(client, bufnr) { - -- utils.format_on_save(client) - -- }, - servers = servers, -} - -require('nvim-lsp-setup').setup(settings) - -local null_ls = require('null-ls') -null_ls.setup({ - sources = { - null_ls.builtins.formatting.stylua.with({ - extra_args = { '--config-path', vim.fn.expand('~/.config/stylua.toml') }, - }), - }, - on_attach = function(client) - utils.format_on_save(client) - end, -}) - -require('lsp_signature').setup({}) -require('lsp-colors').setup({}) - -local border = { '╭', '─', '╮', '│', '╯', '─', '╰', '│' } -vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = border }) -vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = border }) diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua index 50d2b3d..0b96c63 100644 --- a/nvim/lua/plugins.lua +++ b/nvim/lua/plugins.lua @@ -109,7 +109,6 @@ return require('packer').startup(function(use) }, }) use('hrsh7th/cmp-buffer') - use('hrsh7th/cmp-nvim-lsp') use({ 'folke/lsp-colors.nvim', config = function() @@ -149,7 +148,11 @@ return require('packer').startup(function(use) }) use({ 'iamcco/markdown-preview.nvim', - run = 'cd app && yarn install', + run = 'cd app && npm install', + setup = function() + vim.g.mkdp_filetypes = { 'markdown' } + end, + ft = { 'markdown' }, }) use({ 'nvim-lualine/lualine.nvim', @@ -192,17 +195,19 @@ return require('packer').startup(function(use) -- LANGUAGES use({ - 'Junnplus/nvim-lsp-setup', + 'Junnplus/lsp-setup.nvim', config = function() - require('config.nvim-lsp-setup') + require('config.lsp-setup') end, requires = { 'neovim/nvim-lspconfig', - 'williamboman/nvim-lsp-installer', + 'hrsh7th/cmp-nvim-lsp', + 'williamboman/mason.nvim', + 'williamboman/mason-lspconfig.nvim', 'folke/lsp-colors.nvim', 'folke/lua-dev.nvim', 'ray-x/lsp_signature.nvim', - 'jose-elias-alvarez/null-ls.nvim', + 'RRethy/vim-illuminate', 'simrat39/rust-tools.nvim', 'p00f/clangd_extensions.nvim', diff --git a/stylua.toml b/stylua.toml deleted file mode 100644 index 53d1469..0000000 --- a/stylua.toml +++ /dev/null @@ -1,2 +0,0 @@ -indent_type = "Spaces" -quote_style = "AutoPreferSingle" diff --git a/wezterm/wezterm.lua b/wezterm/wezterm.lua index 55a1836..e0250ca 100644 --- a/wezterm/wezterm.lua +++ b/wezterm/wezterm.lua @@ -48,4 +48,14 @@ return { --{ key = 's', mods = 'CMD', action = wezterm.action({ ShowLauncherArgs = { flags = 'FUZZY|WORKSPACES' } }) }, { key = 'w', mods = 'CMD', action = wezterm.action({ CloseCurrentPane = { confirm = false } }) }, }, + hyperlink_rules = { + { + regex = [[\b(https|http)://\S*\b]], + format = '$0', + }, + { + regex = [[["]?([\w\d]{1}[-\w\d]+)(/){1}([-\w\d\.]+)["]?]], + format = 'https://www.github.com/$1/$3', + } + } }