mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-27 11:59:40 -08:00
feat: detect sln and sln files as project files
This commit is contained in:
parent
ca27d2ab0c
commit
1b20c82440
|
@ -39,6 +39,7 @@ require (
|
|||
github.com/mattn/go-runewidth v0.0.15
|
||||
github.com/spf13/cobra v1.7.0
|
||||
github.com/spf13/pflag v1.0.5
|
||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
|
||||
golang.org/x/mod v0.13.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
@ -89,7 +90,6 @@ require (
|
|||
github.com/shopspring/decimal v1.3.1 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.3 // indirect
|
||||
github.com/zclconf/go-cty v1.13.1 // indirect
|
||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
|
||||
golang.org/x/sync v0.4.0 // indirect
|
||||
golang.org/x/term v0.13.0 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
"github.com/jandedobbeleer/oh-my-posh/src/platform"
|
||||
"github.com/jandedobbeleer/oh-my-posh/src/properties"
|
||||
"github.com/jandedobbeleer/oh-my-posh/src/regex"
|
||||
"golang.org/x/exp/slices"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
)
|
||||
|
@ -110,7 +111,7 @@ func (n *Project) Init(props properties.Properties, env platform.Environment) {
|
|||
},
|
||||
{
|
||||
Name: "dotnet",
|
||||
Files: []string{"*.vbproj", "*.fsproj", "*.csproj"},
|
||||
Files: []string{"*.sln", "*.slnf", "*.vbproj", "*.fsproj", "*.csproj"},
|
||||
Fetcher: n.getDotnetProject,
|
||||
},
|
||||
{
|
||||
|
@ -205,18 +206,22 @@ func (n *Project) getNuSpecPackage(_ ProjectItem) *ProjectData {
|
|||
}
|
||||
|
||||
func (n *Project) getDotnetProject(_ ProjectItem) *ProjectData {
|
||||
files := n.env.LsDir(n.env.Pwd())
|
||||
var name string
|
||||
var content string
|
||||
|
||||
extensions := []string{".sln", ".slnf", ".csproj", ".fsproj", ".vbproj"}
|
||||
files := n.env.LsDir(n.env.Pwd())
|
||||
|
||||
// get the first match only
|
||||
for _, file := range files {
|
||||
extension := filepath.Ext(file.Name())
|
||||
if extension == ".csproj" || extension == ".fsproj" || extension == ".vbproj" {
|
||||
if slices.Contains(extensions, extension) {
|
||||
name = strings.TrimSuffix(file.Name(), filepath.Ext(file.Name()))
|
||||
content = n.env.FileContent(file.Name())
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// the name of the parameter may differ depending on the version,
|
||||
// so instead of xml.Unmarshal() we use regex:
|
||||
tag := "(?P<TAG><.*TargetFramework.*>(?P<TFM>.*)</.*TargetFramework.*>)"
|
||||
|
|
|
@ -15,7 +15,7 @@ Supports:
|
|||
- Poetry project (`pyproject.toml`)
|
||||
- PHP project (`composer.json`)
|
||||
- Any nuspec based project (`*.nuspec`, first file match info is displayed)
|
||||
- .NET project (`*.csproj`, `*.vbproj` or `*.fsproj`, first file match info is displayed)
|
||||
- .NET project (`*.sln`, `*.slnf`, `*.csproj`, `*.vbproj` or `*.fsproj`, first file match info is displayed)
|
||||
- Julia project (`JuliaProject.toml`, `Project.toml`)
|
||||
- PowerShell project (`*.psd1`, first file match info is displayed)
|
||||
|
||||
|
|
Loading…
Reference in a new issue