-
-
Notifications
You must be signed in to change notification settings - Fork 298
feat:resharper #800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat:resharper #800
Changes from all commits
63ad8cb
ebb0587
79d7c1a
becc283
185f39f
413b51d
c4b88e8
d6ec242
2235c32
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| local function find_upward(extension) | ||
| local dir = vim.fn.getcwd() | ||
| while dir and dir ~= "/" do | ||
| local files = vim.fn.globpath(dir, "*" .. extension, false, true) | ||
| if not vim.tbl_isempty(files) then | ||
| return files[1] | ||
| end | ||
| dir = vim.fn.fnamemodify(dir, ":h") | ||
| end | ||
| return nil | ||
| end | ||
|
|
||
| return function() | ||
| local root_file = find_upward(".sln") | ||
| if not root_file then | ||
| root_file = find_upward(".csproj") | ||
| end | ||
|
|
||
| if not root_file then | ||
| vim.notify("No solution file or csproj found in parent directories", vim.log.levels.WARN) | ||
| return {} | ||
| end | ||
|
|
||
| local current_buffer = vim.api.nvim_get_current_buf() | ||
| local filepath = vim.api.nvim_buf_get_name(current_buffer) | ||
|
|
||
| if filepath == "" then | ||
| vim.notify("Current buffer has no file associated", vim.log.levels.WARN) | ||
| return {} | ||
| end | ||
|
|
||
| local solution_directory = vim.fn.fnamemodify(root_file, ":h") | ||
|
|
||
| local relative_filepath = filepath:sub(#solution_directory + 2) | ||
| local cache_directory = vim.fn.stdpath("cache") .. "/nvim-lint-resharper" | ||
|
|
||
| -- Ensure cache directory exists | ||
| vim.fn.mkdir(cache_directory, "p") | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this have to be specified?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be honest, I'm not sure. In my tests, it could take 7 or 8 seconds or more for the linter to run on an entire project and caching seemed to have minor effects to the point where I couldn't even be sure if it was working. This was an attempt by me to be as explicit as possible to try to ensure caching was working, and it also gave me a way to check to make sure the cache was actually being saved. I still didn't see any performance increase really by enabling caching and/or specifying the cache directory. I'm fine with removing the cache_directory completely tbh.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there wasn't any difference in your tests I'd be in favor of removing it. |
||
|
|
||
| return { | ||
| cmd = "jb", | ||
xentropic-dev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| stdin = false, | ||
| append_fname = false, | ||
| args = { | ||
| "inspectcode", | ||
| "--no-swea", | ||
| "--no-build", | ||
| "--jobs=0", | ||
| "--severity=INFO", | ||
| "--output=-", | ||
| "--absolute-paths", | ||
| "--include=" .. relative_filepath, | ||
| "--caches-home=" .. cache_directory, | ||
| root_file, | ||
| }, | ||
| stream = nil, | ||
| ignore_exitcode = true, | ||
| parser = require("lint.parser").for_sarif(), | ||
| } | ||
| end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be changed to only search
.slnor.csprojrelative to the current dir?Adding root dir heuristics as part of the linter is out of scope for nvim-dap.
cwdcan be parameterized as part of thetry_lintcall for users who havecwd != project_dir.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the resharper cli cannot lint a single file. It has to run against an entire project or solution. So I guess it's fine as long the user always has csproj or sln in the cwd. For me, that rarely is the case because .NET projects are often nested in various folders. .NET has solution groups to organize files virtually that is irrespective of file tree structure on disk, which makes it even a little more confusing. I have a plugin I wrote for this problem, but basically .NET projects aren't always structured relative on disk; sometimes it's by the "logical" solution groups.
https://github.com/xentropic-dev/explorer.dotnet.nvim
I think for nvim-lint, I should just do whatever makes sense for the good of the rest of the plugin's ecosystem, but I'm really starting to think I need to just make a separate plugin for just the resharper cli. There's too many ways in which the tool is different than the standard linters in this project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could still do something as described in #482 (comment)
And at some point in the future there might be a solution based on neovim/neovim#34622
So for now I'd restrict resharper to only search downward from cwd