Skip to content

Commit

Permalink
Add README, Add poershell setup
Browse files Browse the repository at this point in the history
  • Loading branch information
resticDOG committed Feb 2, 2024
1 parent 1286a13 commit e80c0da
Show file tree
Hide file tree
Showing 10 changed files with 139 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "nvchad"]
path = nvchad
url = https://github.com/NvChad/NvChad.git
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
## Prerequisites

This project is based on [Nvchad](https://github.com/NvChad/NvChad), and the
following conditions need to be met before usage:

1. [Neovim 0.9.4+](https://github.com/neovim/neovim/releases/tag/v0.9.4)
2. Terminal font should be [Nerd Font](https://www.nerdfonts.com/)
3. gcc
4. make
5. [Ripgrep](https://github.com/BurntSushi/ripgrep) (optional)

## Usage

### Windows Platform

- Install `Neovim`, `gcc`, `make`, `ripgrep`

```shell
scoop install neovim gcc make ripgrep
```

- Configure terminal font to be `Nerd Font`
- Backup the original configuration

```powersehll
git clone --recurse-submodules https://github.com/resticDOG/nvim-nvchad-config.git
```

- Create a symbolic link Run `powershell` (or `pwsh`) with administrator
privileges:

```powershell
cd nvim-nvchad-config
./setup.ps1
```

- Initialize

```shell
nvim
```

### Linux Platform (TODO)
47 changes: 47 additions & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
## 前置条件

本项目基于 [Nvchad](https://github.com/NvChad/NvChad) ,使用前需要满足以下条件

1. [Neovim 0.9.4+](https://github.com/neovim/neovim/releases/tag/v0.9.4)
2. 终端字体使用 [Nerd Font](https://www.nerdfonts.com/)
3. gcc
4. make
5. [Ripgrep](https://github.com/BurntSushi/ripgrep) (可选)

## 使用方式

### Windows 平台

- 安装 `Neovim``gcc``make``ripgrep`

```shell
scoop install neovim gcc make ripgrep
```

- 配置终端字体为 `Nerd Font`
- 备份原有配置

```powershell
Test-Path $ENV:USERPROFILE\AppData\Local\nvim && Copy-Item -Recurse -Path $ENV:USERPROFILE\AppData\Local\nvim -Destination $ENV:USERPROFILE\AppData\Local\nvim-back
```

- 克隆仓库

```shell
git clone --recurse-submodules https://github.com/resticDOG/nvim-nvchad-config.git
```

- 建立软连接 使用管理员权限打开 `powershell`(或者 `pwsh`)

```powershell
cd nvim-nvchad-config
./setup.ps1
```

- 初始化

```shell
nvim
```

### Linux 平台 (TODO)
8 changes: 4 additions & 4 deletions ftplugin/java.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ vim.opt_local.tabstop = 4
local home = os.getenv "HOME"
local JAVA_HOME = os.getenv "JAVA_HOME" .. ""
local JAVA_HOME_17 = string.gsub(JAVA_HOME, "(.*java).*(openjdk.*)", "%1-17-%2")
local mason_dir = home .. "/.local/share/nvim/mason/packages"
local jdtls_dir = mason_dir .. "/jdtls"
local java_debug_dir = mason_dir .. "/java-debug-adapter"
local java_test_dir = mason_dir .. "/java-test"
local mason_path = vim.fn.glob(vim.fn.stdpath "data" .. "/mason/")
local jdtls_dir = mason_path .. "packages/jdtls"
local java_debug_dir = mason_path .. "packages/java-debug-adapter"
local java_test_dir = mason_path .. "packages/java-test"
local jdtls = require "jdtls"
local root_markers = { "gradlew", "mvnw", ".git" }
local root_dir = require("jdtls.setup").find_root(root_markers)
Expand Down
9 changes: 9 additions & 0 deletions lua/custom/configs/lspconfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ local capabilities = require("plugins.configs.lspconfig").capabilities

local lspconfig = require "lspconfig"

-- Mason data path
local mason_path = vim.fn.glob(vim.fn.stdpath "data" .. "/mason/")

local servers = {
"html",
"cssls",
Expand Down Expand Up @@ -41,9 +44,15 @@ local function get_typescript_server_path(root_dir)
end
end

-- volar
lspconfig.volar.setup {
on_new_config = function(new_config, new_root_dir)
new_config.init_options.typescript.tsdk = get_typescript_server_path(new_root_dir)
end,
filetypes = { "typescript", "javascript", "javascriptreact", "typescriptreact", "vue", "json" },
}

-- powershell_es
lspconfig.powershell_es.setup {
bundle_path = mason_path .. "packages/powershell-editor-services",
}
5 changes: 4 additions & 1 deletion lua/custom/configs/overrides.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ M.mason = {

-- xml
"lemminx",
"xmlformat",
"xmlformatter",

-- powershell
"powershell-editor-services",
},
}

Expand Down
2 changes: 1 addition & 1 deletion lua/custom/highlights.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ M.override = {
fg = "teal",
},
Visual = {
bg = "gray",
bg = "#24472d",
},
Identifier = {
fg = "white",
Expand Down
12 changes: 0 additions & 12 deletions lua/custom/plugins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -217,18 +217,6 @@ local plugins = {
require("codeium").setup {}
end,
},

-- sg.nvim
{
"sourcegraph/sg.nvim",
event = "BufEnter",
dependencies = {
"nvim-lua/plenary.nvim", --[[ "nvim-telescope/telescope.nvim ]]
},
config = function()
require("sg").setup {}
end,
},
}

return plugins
1 change: 1 addition & 0 deletions nvchad
Submodule nvchad added at f17e83
27 changes: 27 additions & 0 deletions setup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# check if run as Administrator
$Current = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$CurrenPrincipal = New-Object System.Security.Principal.WindowsPrincipal($Current)
if ( -Not $CurrenPrincipal.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator))
{
Write-Host "Please run as Administrator"
exit
}

$NvimConfigPath = "$ENV:USERPROFILE\AppData\Local\nvim"
$WorkPath = "$(Get-Location)"
# remove old nvim config
if (Test-Path $NvimConfigPath)
{
Remove-Item -Recurse -Force $NvimConfigPath
}

# create symbolic link
New-Item -ItemType SymbolicLink -Verbose -Path $NvimConfigPath -Target "$WorkPath\nvchad"
if (-Not (Test-Path $NvimConfigPath\ftplugin))
{
New-Item -ItemType SymbolicLink -Verbose -Path $NvimConfigPath\ftplugin -Target "$WorkPath\ftplugin"
}
if (-Not (Test-Path $NvimConfigPath\lua\custom))
{
New-Item -ItemType SymbolicLink -Verbose -Path $NvimConfigPath\lua\custom -Target "$WorkPath\lua\custom"
}

0 comments on commit e80c0da

Please sign in to comment.