Code Monkey home page Code Monkey logo

neoconf.nvim's Introduction

๐Ÿ’ผ neoconf.nvim

neoconf.nvim is a Neovim plugin to manage global and project-local settings.

image

โœจ Features

  • configure Neovim using JSON files (can have comments)
    • global settings: ~/.config/nvim/neoconf.json
    • local settings: ~/projects/foobar/.neoconf.json
  • live reload of your lsp settings
  • import existing settings from vscode, coc.nvim and nlsp-settings.nvim
  • auto-completion of all the settings in the Json config files
  • auto-completion of all LSP settings in your Neovim Lua config files
  • integrates with neodev.nvim. See .neoconf.json in this repo.

โšก๏ธ Requirements

  • Neovim >= 0.7.2

๐Ÿ“ฆ Installation

Install the plugin with your preferred package manager:

-- Lua
use({
  "folke/neoconf.nvim",
})

๐Ÿš€ Setup

It's important that you set up neoconf.nvim BEFORE nvim-lspconfig.

require("neoconf").setup({
  -- override any of the default settings here
})

-- setup your lsp servers as usual
require("lspconfig").lua_ls.setup(...)

โš™๏ธ Configuration

neoconf.nvim comes with the following defaults:

{

  -- name of the local settings files
  local_settings = ".neoconf.json",
  -- name of the global settings file in your Neovim config directory
  global_settings = "neoconf.json",
  -- import existing settings from other plugins
  import = {
    vscode = true, -- local .vscode/settings.json
    coc = true, -- global/local coc-settings.json
    nlsp = true, -- global/local nlsp-settings.nvim json settings
  },
  -- send new configuration to lsp clients when changing json settings
  live_reload = true,
  -- set the filetype to jsonc for settings files, so you can use comments
  -- make sure you have the jsonc treesitter parser installed!
  filetype_jsonc = true,
  plugins = {
    -- configures lsp clients with settings in the following order:
    -- - lua settings passed in lspconfig setup
    -- - global json settings
    -- - local json settings
    lspconfig = {
      enabled = true,
    },
    -- configures jsonls to get completion in .nvim.settings.json files
    jsonls = {
      enabled = true,
      -- only show completion in json settings for configured lsp servers
      configured_servers_only = true,
    },
    -- configures lua_ls to get completion of lspconfig server settings
    lua_ls = {
      -- by default, lua_ls annotations are only enabled in your neovim config directory
      enabled_for_neovim_config = true,
      -- explicitely enable adding annotations. Mostly relevant to put in your local .nvim.settings.json file
      enabled = false,
    },
  },

}

๐Ÿš€ Usage

The :Neoconf Command

  • :Neoconf: will show a ui to select one of the local/global json config files to edit
  • :Neoconf local: will show a ui to select one of the local json config files to edit
  • :Neoconf global: will show a ui to select one of the global json config files to edit
  • :Neoconf show: opens a floating window with the merged config
  • :Neoconf lsp: opens a floating window with your merged lsp config

image

Completion and Validation for your Json Settings Files

image

Completion and Validation for your Lua Settings Files

Completion of your lua settings should work out of the box.

image

You can additionally use the exported types in other places.

Example with a table containing LSP server settings
  ---@type lspconfig.options
  local servers = {
    ansiblels = {},
    bashls = {},
    clangd = {},
    cssls = {},
    dockerls = {},
    tsserver = {},
    svelte = {},
    eslint = {},
    html = {},
    jsonls = {
      settings = {
        json = {
          format = {
            enable = true,
          },
          schemas = require("schemastore").json.schemas(),
          validate = { enable = true },
        },
      },
    },
  }

๐Ÿ“ฆ API

Neodev comes with an API that can be used by plugin developers to load global/local settings for their plugin.

---@class SettingsPlugin
---@field name string
---@field setup fun()|nil
---@field on_update fun(event)|nil
---@field on_schema fun(schema: Schema)

-- Registers a plugin. Biggest use-case is to get auto-completion for your plugin in the json settings files
---@param plugin SettingsPlugin
function Neodev.register(plugin) end

---@class WorkspaceOptions
---@field file? string File will be used to determine the root_dir
---@field buffer? buffer Buffer will be used to find the root_dir
---@field lsp? boolean LSP root_dir will be used to determine the root_dir
---@field local? boolean defaults to true. Merge local settings
---@field global? boolean defaults to true. Merge global settings

-- Returns the requested settings
---@generic T : table
---@param key? string Optional key to get settings for
---@param defaults? T Optional table of defaults that will be merged in the result
---@param opts? WorkspaceOptions options to determine the root_dir and what settings to merge
---@return T
function Neoconf.get(key, defaults, opts) end
API Example
-- default config for your plugin
local defaults = {
  doit = true,
  count = 1,
  array = {},
}

-- register your settings schema with Neodev, so auto-completion will work in the json files
require("neoconf.plugins").register({
    on_schema = function(schema)
    -- this call will create a json schema based on the lua types of your default settings
    schema:import("myplugin", defaults)
    -- Optionally update some of the json schema
    schema:set("myplugin.array", {
        description = "Special array containg booleans or numbers",
        anyOf = {
        { type = "boolean" },
        { type = "integer" },
        },
        })
    end,
    })

local my_settings = Neoconf.get("neodev", defaults)

โญ Acknowledgment

  • json.lua a pure-lua JSON library for parsing jsonc files

๐Ÿ’ป Supported Language Servers

neoconf.nvim's People

Contributors

bryanforbes avatar curs3w4ll avatar escwxyz avatar folke avatar github-actions[bot] avatar yutkat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

neoconf.nvim's Issues

bug: neoconf changes the invocation location of `cargo check` when using rust-analyzer in a cargo workspace

Did you check docs and existing issues?

  • I have read all the neoconf.nvim docs
  • I have searched the existing issues of neoconf.nvim
  • I have searched the exsiting issues of plugins related to this issue

Neovim version (nvim -v)

v0.9.0-dev-845+gfacbb11e0

Operating system/version

Linux 6

Describe the bug

When opening a crate within a cargo workspace, if a .neoconf.json file is present at the root of the project, cargo check (which is usually executed on save, to produce diagnostics) is instead executed at the root of the whole workspace. This either does not work at all (you don't need to have a Cargo.toml present at the root of a workspace), or launches the check on the entire workspace, which can be prohibitively slow and expensive.

A workaround: create a .neoconf.json file at the root of the crate, and it'll be used instead of the workspace-level one. Drawback: you need to duplicate the settings in every single crate that way. At least symlinks work.

As a side-note, it would be awesome to be able to "stack" config files within a project, where a folder could override the settings present in a parent folder, up to the root of the git repository (if one exists). This would be particularly useful for rust workspaces, for example when specifying feature flags specific to some crates.

Steps To Reproduce

This can be reproduced on any rust repository that contains several crates, for example nvim-oxi and checking the LSP logs.

Expected Behavior

I expect cargo check to be run from the current working directory, as is the default behavior when no .neoconf.json file is present.

Repro

No response

bug: fsautocomplete types out of date

Did you check docs and existing issues?

  • I have read all the neoconf.nvim docs
  • I have searched the existing issues of neoconf.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

NVIM v0.10.0 ***

Operating system/version

Windows 10

Describe the bug

hey, I noticed that the types are not being correctly updated with the language server fsautocomplete.

they just added

        "FSharp.fsac.sourceTextImplementation": {
          "default": "NamedText",
          "description": "EXPERIMENTAL. Enables the use of a new source text implementation. This may have better memory characteristics. Requires restart.",
          "enum": [
            "NamedText",
            "RoslynSourceText"
          ]
        },


in between


     "FSharp.fsac.netCoreDllPath": {
          "default": "",
          "description": "The path to the \u0027fsautocomplete.dll\u0027, a directory containing TFM-specific versions of fsautocomplete.dll, or a directory containing fsautocomplete.dll. Useful for debugging a self-built FSAC. If a DLL is specified, uses it directly. If a directory is specified and it contains TFM-specific folders (net6.0, net7.0, etc) then that directory will be probed for the best TFM to use for the current runtime. This is useful when working with a local copy of FSAC, you can point directly to the bin/Debug or bin/Release folder and it\u0027ll Just Work. Finally, if a directory is specified and there are no TFM paths, then fsautocomplete.dll from that directory is used. Requires restart.",
          "scope": "machine-overridable",
          "type": "string"
        },
        "FSharp.fsac.sourceTextImplementation": {
          "default": "NamedText",
          "description": "EXPERIMENTAL. Enables the use of a new source text implementation. This may have better memory characteristics. Requires restart.",
          "enum": [
            "NamedText",
            "RoslynSourceText"
          ]
        },
        "FSharp.fsac.parallelReferenceResolution": {
          "default": false,
          "description": "EXPERIMENTAL: Speed up analyzing of projects in parallel. Requires restart.",
          "type": "boolean"
        },

I looked at the github actions for the repo and see there have been some failing ones. that might be part of what's going on.

Steps To Reproduce

it's not really a steps thing i don't think.

Expected Behavior

that the types would be correctly auto generated.

Repro

-- I don't think doing a minimal repro will likely help the situation, so  I haven't changed anything here. 

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  "folke/neoconf.nvim",
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

feature: support lua expression evaluation in `neoconf.json` config

Did you check the docs?

  • I have read all the neoconf.nvim docs

Is your feature request related to a problem? Please describe.

Now I have to setup jsonls with setup handler:

    local lspconfig = require("lspconfig")
    lspconfig["jsonls"].setup({
       settings = {
            json = {
                schemas = require("schemastore").json.schemas(),
                validate = { enable = true },
            },
        },
    })

But I want to config it in the neoconf.json file like this:

{
    "lspconfig": {
        "jsonls": {
            // Here I want neoconf could evaluate lua expression
            "json.schemas": "require('schemastore').json.schemas()", 
            "json.validate.enable": true
        }
    }

}

Describe alternatives you've considered

N/A

Additional context

No response

bug: Neoconf loads lspconfig for health check

Did you check docs and existing issues?

  • I have read all the neoconf.nvim docs
  • I have searched the existing issues of neoconf.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.9.0

Operating system/version

Windows 11

Describe the bug

When neoconf is loaded it internally loads "lspconfig" to check if any servers are already active.

local ok, lsputil = pcall(require, "lspconfig.util")
if ok then
if #lsputil.available_servers() == 0 then
return true
else
util.error(
[[Setup `require("neoconf").setup()` should be run **BEFORE** setting up any lsp server with lspconfig]]
)
end
else

This is fine if the only thing using neoconf are plugins that are also dependencies of lspconfig but when an external dependency (especially one that is loaded earlier than lspconfig) is ran it will cause neoconf to load lspconfig before it returns (which in this configuration loads a lsp server).

Steps To Reproduce

  1. have something earlier than lspconfig depend on neoconf
  2. run neovim and get

Setup require("neoconf").setup() should be run BEFORE setting up any lsp server with lspconfig

Expected Behavior

Neoconf doesn't load lspconfig which creates the server but instead has some way of initializing without fetching the server count or solve it some other way that I haven't thought of

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  	{
		'glepnir/dashboard-nvim',
		event = 'VimEnter',
		opts = function() return require 'neoconf'.get("plugins.dashboard", {}) end
	},
    {
		'neovim/nvim-lspconfig',
		config = function()
			local lspconfig = require 'lspconfig'
            lspconfig.lua_ls.setup {}
		end,
		event = "BufAdd",
		dependencies =
		{
			"folke/neoconf.nvim"
        }
    }
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
  defaults = {lazy = true}
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

bug: Windows global config file not recognized and Neoconf popup empty

Did you check docs and existing issues?

  • I have read all the neoconf.nvim docs
  • I have searched the existing issues of neoconf.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

NVIM v0.9.1

Operating system/version

Windows 10 21H2

Describe the bug

Global config files don't get recognized under Windows and the popup window for selecting / editing config files is empty

image

using local config files works (except they don't show up in the popup either)

Steps To Reproduce

  1. neovim on Windows (Config is under $ENV:LOCALAPPDATA\nvim)
  2. open Neoconf (:Neoconf)
  3. Window is empty

Expected Behavior

Neoconf Popup should show either global or local config to edit

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
        vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
        vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
        "folke/tokyonight.nvim",
        "folke/neoconf.nvim",
        "neovim/nvim-lspconfig",
        -- add any other plugins here
}
require("lazy").setup(plugins, {
        root = root .. "/plugins",
})
require("neoconf").setup({})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

neoconf.nvim is ignoring `root_dir`

This issue is a continuation of neovim/nvim-lspconfig#2273.

Yesterday I had an issue in which my custom root_dir configuration was being ignored. I found that it is caused by neoconf.nvim.

Here is the minimal configuration with which it can be reproduced:

require("neoconf").setup({})

local lspconfig = require("lspconfig")

lspconfig.denols.setup({
  root_dir = lspconfig.util.root_pattern("deno.json", "deno.jsonc"),
})

lspconfig.tsserver.setup({
  root_dir = lspconfig.util.root_pattern("package.json"),
})

You need to have either a deno or a tsserver project with a .vscode/settings.json file.

As you can see in the following screenshot, both language servers are being loaded. If I remove the .vscode/settings.json file it works as expected.

image

How to set custom path for neovim config dir?

I store my config in a different place and add it to the runtime path using vim.opt.runtimepath:append. Is there a way to tell this plugin my root directory is in some other place?

How to pass environment variables to some lang server

Some language servers use environmental variables for configuration options, with vscode settings, defining these is possible, is there some way to do this from the neoconf json config file?

There should really be some more documentation as to the format of neoconf.json file, since I find it pretty confusing to know what the structure of it should be.

bug: loading reference 'xx\xx\neoconf.nvim\schemas\pyright.json/': Unable to laod schema from '\'

Did you check docs and existing issues?

  • I have read all the neoconf.nvim docs
  • I have searched the existing issues of neoconf.nvim
  • I have searched the exsiting issues of plugins related to this issue

Neovim version (nvim -v)

NVIM v0.9.0-dev-1115+g446c353a5

Operating system/version

Windows 11

Describe the bug

I opened a python file and use cmd "Neoconf local" to edit the local lsp configuration file. Then it report a bug as follow
image

Steps To Reproduce

  1. open a python file in nvim 9.0, Windows 11
  2. edit the settings json file by command "Neoconf local"

Expected Behavior

the reference json file should be found in the right path.

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  "folke/neoconf.nvim",
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

feature: Specify config path via environment variable

Did you check the docs?

  • I have read all the neoconf.nvim docs

Is your feature request related to a problem? Please describe.

Sometimes you want to generate project-specific configuration containing data that can't be statically baked.

For example, with Nix you can create a shell environment that automatically pull dependencies for the project. But sometimes, you need to pass these dependencies to the LSP configuration. Since the data is dynamic and can't be known beforehand, you can't just hardcode it in a .neoconf.json

Describe the solution you'd like

Being able to specify the absolute path to the config file via an env var (e.g. NEOCONF_PATH) will allow the user to dynamically generate a config file and pass the path to neoconf via the environment variable.

Describe alternatives you've considered

The only other alternative is to manually create the config file and adjust them regularly.

Additional context

No response

keys with square braces parses incorrectly

json

{
  "lspconfig": {
    "lua_ls": {
      "Lua": {
        "workspace": {
          "library": {
            "[vim.fn.expand('$VIMRUNTIME/lua')]": true,
            "[vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')]": true
          }
        }
      }
    }
  }

lua

{
  lspconfig = {
    lua_ls = {
      Lua = {
        workspace = {
          library = {
            ["[vim.fn.expand('$VIMRUNTIME/lua')]"] = true,
            ["[vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')]"] = true
          }
        }
      }
    }
  }
}

which dosent work

[Help Wanted] How to correctly setup in-lua field auto-completion?

I have read through documentation and even half of the source code, but still can't get in-lua auto-completion work as shown in readme.

So far, I think the key logic on in-lua(not in json config) auto-completetion, lives in lua/neoconf/plugins/lua_ls.lua, which injects two files types/lsp.lua & types/lua/lspconfig.lua into lua_ls's workspace library.

If i get it wrong, pls correct me.

I could verify that i've successfully inject those two files into lua_ls through :Neoconf lsp

Hope someone tell me how to make it work.

Question: how to use neoconf API to get self-defined configs/fields?

Hi, I'm trying to understand the API doc: https://github.com/folke/neoconf.nvim#-api.

But still have some questions:

  1. Where does the Neoconf defined? I copied the sample but my neovim reports: there's no Neoconf defined, it's nil value.
  2. I add some configs to global ~/.config/nvim/neoconf.json (see below), but cannot get it with API: require('neoconf').get('myconfig.perf.file.maxsize'), nvim reports the returned value is nil:
    {
      "myconfig": {
        "perf.file.maxsize": 1024
      }
    }

bug: VSCode settings break things when opening a subfolder

Did you check docs and existing issues?

  • I have read all the neoconf.nvim docs
  • I have searched the existing issues of neoconf.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.9.1

Operating system/version

Linux or MacOS

Describe the bug

Relative paths in values within .vscode/settings.json files don't work if being pulled from a parent directory outside the scope/folder currently being opened in nvim.

My particular issue context

I have a nested folder structure containing multiple "projects" with the top-level containing a .vscode/settings.json file.

There is a setting for rust analyzer that goes into vscode's settings.json called LinkedProjects where you put an array of relative paths for vscode to pick up your projects properly.

This essentially keeps vscode working as expected when you have one or more rust projects not at the root folder.

How it's breaking

When opening one of these in nvim so that a single rust project is essentially the root folder, it breaks rust analyzer (oddly just all proc macros) with a pretty much un-Googleable error:

proc macro main not expanded: proc macro crate is missing dylib

This is due to it going up beyond the root folder being opened, finding a .vscode/settings.json file up in a parent folder somewhere and applying those settings relative to the folder you have opened in nvim NOT relative to the .vscode folder it found the settings in.

Workaround

My current workaround after realising what was breaking it was to just have a .neoconf.json file inside each subfolder setting import -> vscode to false:

{
    "import": {
        "vscode": false
    }
}

Not great if you actually need other settings from vscode's settings but at the moment I don't.

Steps To Reproduce

I imagine there is a much simpler way to reproduce the underlying issue but in my specific case:

  • Install rust with rustup.

  • Install nvim (I used LazyVim this time but all others I tried such as Astro etc all reproduced it).

  • Add rust-analyzer with Mason.

  • Quit nvim.

  • Create a new folder to act as the root folder and within it create the following .vscode/settings.json file:

{
    "rust-analyzer.linkedProjects": [
        "./stuff/Cargo.toml"
    ]
}
  • Create a new sub project with cargo new stuff
  • Add something to the dependencies that uses proc macros to the Cargo.toml file, ie:
[dependencies]
tokio = { version = "1.32.0", features = ["full"] 
  • Then use it in src/main.rs:
#[tokio::main]
async fn main() {
    println!("Hello, world!");
}
  • Now the hierarchy should look like:
    /.vscode/settings.json
    /stuff/Cargo.toml
    /stuff/src/main.rs
    other files created automatically by cargo new omitted.

  • cd into stuff and run:

nvim .
  • Go into main.rs, wait for rust-analyzer to index and be greeted with an error on the #[tokio::main] line.

Expected Behavior

Ideally either:

  • do not load .vscode/settings.json files from a parent outside the current folder scope.
  • if loading values that are relative paths, change them to still be correct (maybe prepend /../ as needed).

Repro

I used the current out-the-box LazyVim

Indicate error/warning origin

Please add a prefix to error messages that tells users where the error is coming from!

For example the nvim-lspconfig is missing error took me quite some time to track down, where it's coming from. I would be awesome if the error would read "Neoconf: nvim-lspconfig not installed?".

Since we're already talking about it: please note in the README install instructions that there is a default (but optional) dependency on nvim-lspconfig. It could read something like:

use({
  "folke/neoconf.nvim",
  -- if plugins.lspconfig.enabled = true (default):
  requires = 'neovim/nvim-lspconfig'
})

Feature: Configure `dap` configurations

I think that this would be pretty neat to be able to create the different dap configurations in neoconf.nvim as well!

I'm willing to help a bit, if you explain me what I need to do.

Question: .vscode/settings.json not over-riding clangd settings

Did you check docs and existing issues?

  • I have read all the neoconf.nvim docs
  • I have searched the existing issues of neoconf.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.9.1

Operating system/version

Ubuntu 20.04

Describe the bug

I'm trying to use neoconf to pick up the custom clangd settings from our company provided .vscode/settings.json file at the root of our project directory.

I see that Neoconf show does show the custom clangd settings. I see something like this:

    clangd = {
      arguments = { "--malloc-trim", "--pretty", "--pch-storage=disk", "--background-index", "--compile-commands-dir=${workspaceFolder}", "-j=8", "-log=verbose" },
      detectExtensionConflicts = true,
      onConfigChanged = "restart",
      path = "/path/to/company/provided/clangd",
      restartAfterCrash = true
    },

However Neoconf lsp just shows an empty directory:

* /path/to/root/.vscode/settings.json
```lua
vim.empty_dict()

I verified that neoconf is sourced before lspconfig by putting print statements.

Steps To Reproduce

  1. Create a directory (say /tmp/repro)

  2. Create a file /tmp/repro/init.lua with contents as shown in the minimal repro box below

  3. Create a file .vscode/settings.json with contents below:

{
  "clangd.detectExtensionConflicts": true,
  "clangd.arguments": [
    "--malloc-trim",
    "--pretty",
    "--pch-storage=disk",
    "--background-index",
    "--compile-commands-dir=${workspaceFolder}",
    "-j=8",
    "-log=verbose"
  ],
  "clangd.restartAfterCrash": true,
  "clangd.onConfigChanged": "restart",
  "clangd.path": "/tmp/repro/tools/clangd",
}
  1. You'll need to manually copy over a working clangd into the tools subdirectory.

  2. Now open neovim by doing

nvim -u init.lua foo.cpp

Expected Behavior

When the C++ file is opened, LspInfo should show the path to the clangd in the tools subdirectory. However, it will probably error out.

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
    vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
    {
        -- allows for project specific settings for clangd etc.
        -- Automatically picks up .vscode/settings.json etc.
        "folke/neoconf.nvim",
        config = function()
            require('neoconf').setup()
        end,
    },

    {
        "neovim/nvim-lspconfig", -- enable LSP
        event = { "BufReadPre", "BufNewFile" },
        dependencies = {
            "folke/neoconf.nvim", -- neoconf needs to be setup before lspconfig
        },
        config = function()
            local lspconfig = require('lspconfig')
            -- lspconfig.clangd.setup({
            --     cmd = { "/tmp/repro_neconf/proj/tools/clangd" }
            -- })
            lspconfig.clangd.setup({})
        end
    },
    -- add any other plugins here
}
require("lazy").setup(plugins, {
    root = root .. "/plugins",
})

bug: jdtls runtime settings are not populated

Did you check docs and existing issues?

  • I have read all the neoconf.nvim docs
  • I have searched the existing issues of neoconf.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

NVIM v0.9.5

Operating system/version

archlinux

Describe the bug

Here my .neoconf.json file:

{
  "lspconfig": {
    "jdtls": {
      "java.configuration.runtimes": [
        {
          "name": "JavaSE-17",
          "path": "/home/jcabre/.sdkman/candidates/java/17.0.10-tem",
        },
        {
          "name": "JavaSE-11",
          "path": "/home/jcabre/.sdkman/candidates/java/11.0.22-tem",
          "default": true
        }
      ]
    }
  }
}

I'm trying to change jdt runtime using JdtSetRuntime command, see here.

As you can see, I', getting this message:

No runtimes found in 'config.settings.java.configuration.runtimes'. You need to add runtime paths to change runtimes.

I'd also like get what are current jdtls settings. How could I get jdtls settings?

Any ideas?

Steps To Reproduce

  1. I only have a local neoconf.json file seems to be ignored...

Expected Behavior

new jdtls settings are populated.

feature: overriding `cmd`

Did you check the docs?

  • I have read all the neoconf.nvim docs

Is your feature request related to a problem? Please describe.

I have a need to override the cmd entry for one of the language servers I have depending on the project directory.

From what I can understand from lspconfig plugin code, it only updates the settings key of the server configuration.

Describe the solution you'd like

I'd like to be able to override other configuration parameters, e.g. cmd and have neoconf.nvim restart the affected servers when parameters other than settings are changed.

Describe alternatives you've considered

Can't find one.

Additional context

No response

bug: neoconf splits URL in yamlls configuration

Did you check docs and existing issues?

  • I have read all the neoconf.nvim docs
  • I have searched the existing issues of neoconf.nvim
  • I have searched the exsiting issues of plugins related to this issue

Neovim version (nvim -v)

v0.8.3

Operating system/version

Gentoo Linux

Describe the bug

neoconf automatically breaks keys with . in the configuration into an table hierarchy for lspconfig, which makes it impossible to configure schema URLs for yamlls

Using this configuration:

{
  "lspconfig": {
    "yamlls": {
      "yaml.schemas": {
        "https://json.schemastore.org/clang-format.json": ".clang-format"
      }
    }
  }
}

neoconf produces:

{
  redhat = {
    telemetry = {
      enabled = false
    }
  },
  yaml = {
    schemas = {
      ["https://json"] = {
        schemastore = {
          ["org/clang-format"] = {
            json = ".clang-format"
          }
        }
      }
    }
  }
}

Steps To Reproduce

  1. Write the neoconf configuration as described above.
  2. Run nvim -u repro.lua test.yaml
  3. Run :Neoconf lsp

Expected Behavior

This configuration

{
  redhat = {
    telemetry = {
      enabled = false
    }
  },
  yaml = {
    schemas = {
      ["https://json.schemastore.org/clang-format"] = {
            json = ".clang-format"
      }
    }
  }
}

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
	vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
	vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
	"folke/tokyonight.nvim",
	"folke/neoconf.nvim",
	"neovim/nvim-lspconfig",
	"williamboman/mason.nvim",
	"williamboman/mason-lspconfig.nvim",
}
require("lazy").setup(plugins, {
	root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
require("neoconf").setup({})
require("mason").setup({})
require("mason-lspconfig").setup({ ensure_installed = { "yamlls" } })
require("lspconfig").yamlls.setup({})

bug: coc.nvim local settings are not loaded correctly

Did you check docs and existing issues?

  • I have read all the neoconf.nvim docs
  • I have searched the existing issues of neoconf.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.10.0-dev-1456+g4c32927084

Operating system/version

EndeavourOS x86_64 (6.5.9-arch2-1)

Describe the bug

coc.nvim's local config file is not loaded.

I think this part should be .vim/coc-settings.json instead of coc-settings.json, since coc.nvim creates local settings there:

pattern = "coc-settings.json",

(This path is documented in coc.nvim: https://github.com/neoclide/coc.nvim/blob/e3f91b5ed551ae95d1f5c3b75f557f188ad17b52/doc/coc.txt#L241.)

Steps To Reproduce

  1. Install coc.nvim in your Neovim and create local settings file with :CocLocalConfig.
  2. Write some test configuration in the opened buffer and save it, {"test.config.foo": "test"} for example.
  3. Restart Neovim and open some file (:e test.txt).
  4. Check :Neoconf. The config is not loaded in neoconf side.
  5. Check that config is loaded in coc.nvim side by echo coc#util#get_config('test.config'). It should return {"foo": "test"}.

Expected Behavior

Neoconf loads the local coc.nvim settings.

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  "folke/neoconf.nvim",
  "neovim/nvim-lspconfig",
  {"neoclide/coc.nvim", branch = "release"},
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

feature: support for ruff_lsp

Did you check the docs?

  • I have read all the neoconf.nvim docs

Is your feature request related to a problem? Please describe.

Can we please add spec for ruff_lsp.

Describe the solution you'd like

ruff_lsp has a spec located here:
https://raw.githubusercontent.com/astral-sh/ruff-vscode/main/package.json

From the basic understanding I can see packages being fetched form the gist, but gist is not being maintain any longer.

function M.update_index()
  local url = "https://gist.githubusercontent.com/williamboman/a01c3ce1884d4b57cc93422e7eae7702/raw/lsp-packages.json"
  local index = Util.fetch(url)
  Util.write_file("schemas/index.json", index)
end

Describe alternatives you've considered

NA

Additional context

No response

[Question] No healthcheck found for "settings" plugin.

Did you check docs and existing issues?

  • I have read all the neoconf.nvim docs
  • I have searched the existing issues of neoconf.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.9.0

Operating system/version

Linux

Describe the bug

ๅ›พ็‰‡

How to config for checkhealth?

Steps To Reproduce

This is not bug.
My config is
ๅ›พ็‰‡

Expected Behavior

Expect Neoconf checkhealth works

Repro

![ๅ›พ็‰‡](https://user-images.githubusercontent.com/23305067/234752376-742ba386-0772-495a-8ebc-0433fb5b1393.png)

bug: neoconf doesn't honor custom root_patterns

Did you check docs and existing issues?

  • I have read all the LazyVim docs
  • I have searched the existing issues of LazyVim
  • I have searched the exsiting issues of plugins related to this issue

Neovim version (nvim -v)

v0.8.3

Operating system/version

MacOS 13.1

Describe the bug

I'm not sure if this is a bug, but it is the only other issue template alongside feature request.
I have this config in lua/plugins/typescript_lsp.lua
Configuration lifted from Deno docs here

return {
  "neovim/nvim-lspconfig",
  dependencies = { "jose-elias-alvarez/typescript.nvim" },
  ---@class PluginLspOpts
  opts = {
    ---@type lspconfig.options
    servers = {
      tsserver = { root_dir = require("lspconfig").util.root_pattern("package.json"), single_file_support = false },
      denols = { root_dir = require("lspconfig").util.root_pattern("deno.json", "deno.jsonc") },
    },
    ---@type table<string, fun(server:string, opts:_.lspconfig.options):boolean?>
    -- setup = {
    --   tsserver = function(_, opts)
    --     require("typescript").setup({
    --       server = opts,
    --       root_dir = lspconfig.util.root_pattern("package.json"),
    --       single_file_support = false,
    --     })
    --     return true
    --   end,
    -- },
  },
}

But I noticed that on a directory with just deno.json that tsserver is still activated when I do space cl
I also tried this same thing with the file in lua/config/ and also with the part commented out uncommented, but the same experience.

I'm new to vim/LazyVim, so I might be doing sth totally wrong.

Steps To Reproduce

  1. Create a deno project - say just a single ts file with url import
  2. Have both deno lsp and typescript language server installed
  3. And check for lsp state in the current directory with cl, both denols and tserver will be activated

Expected Behavior

Expected result is that only denols should be on.

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  "folke/LazyVim",
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
require("config.lazy")

[Question] Can I use neoconf without lsp?

Neoconf seems to set itself as a configuration manager of lsp server. Therefore, it requires lspconfig plugin.

But is it possible to use it as a general configuration manager for non-lsp plugins?

If we target it as a general configuration manager(manager for both lsp&non-lsp plugins), then it's kind of weird that neoconf will crash without installing lspconfig first.

bug: nil root_dir

Did you check docs and existing issues?

  • I have read all the neoconf.nvim docs
  • I have searched the existing issues of neoconf.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

v0.9.5 Release

Operating system/version

Linux 6.6

Describe the bug

When starting a Slint LSP, I get the following error:

[lspconfig] unhandled error: ....local/share/nvim/lazy/neoconf.nvim/lua/neoconf/util.lua:54: attempt to call upvalue 'root_dir' (a nil value)

And the server isn't started.

Steps To Reproduce

  1. Install the server through Mason
  2. Open a Slint file
  3. If you don't have automatic filetype detection already, do :se ft=slint
  4. If the LSP didn't try to start automatically, do :LspStart
  5. You should see the error pop out.

Expected Behavior

The LSP starts without errors.

Repro

-- With this repro, the server still doesn't start but I don't get the error either... 
-- My regular setup uses LazyVim. Should I open an issue there?

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
	vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
	vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
	"folke/tokyonight.nvim",
	"folke/neoconf.nvim",
	"williamboman/mason-lspconfig.nvim",
	{
		"williamboman/mason.nvim",
		config = function()
			require("mason").setup()
			require("mason-lspconfig").setup({
				ensure_installed = { "slint_lsp" },
			})
		end,
	},
	"neovim/nvim-lspconfig",
	-- add any other plugins here
}
require("lazy").setup(plugins, {
	root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

bug: filetype_jsonc doesn't work when edit a new .neoconf.json for local project

Did you check docs and existing issues?

  • I have read all the neoconf.nvim docs
  • I have searched the existing issues of neoconf.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

neovim-nightly

Operating system/version

Ubuntu 22.04

Describe the bug

I think it should set filetype when edit a new file with .neoconf.json name

when I touch .neoconf.json file then edit it, the filetype is set correctly

Steps To Reproduce

  1. go to a project folder
  2. exec :e .neoconf.json

Expected Behavior

it should be set filetype with jsonc

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  "folke/neoconf.nvim",
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

feature: update schema source

Did you check the docs?

  • I have read all the neoconf.nvim docs

Is your feature request related to a problem? Please describe.

The schema gist that Neoconf is using is no longer maintained, and some LSPs are already outdated (for example, Volar), and build steps no longer generate JSON files.

Describe the solution you'd like

Perhaps we should consider switching sources, as suggested by the original gist author? Link

Describe alternatives you've considered

Maintaining the old gist seems unlikely, as it would require a significant amount of effort

Additional context

No response

feature: field type has changed in lua_ls config

Did you check the docs?

  • I have read all the neoconf.nvim docs

Is your feature request related to a problem? Please describe.

With a recent change in lua_ls (PRs listed below), the expected values for workspace.checkThirdParty has changed from a boolean to string enum.

Please update the schema to align with the latest changes.
Please see # Describe the solution you'd like section for the explanation of the new values.


Sidenote:

Not related to the new schema but there seems to still be an issue with type conversion atm to keep backwards compatibility working.

Describe the solution you'd like

Change schema for lua_ls.


This lets you skip the "apply third party library to workspace configuration" prompt.

The value of Lua.workspace.checkThirdParty can now be one of:

Ask (ask every time; this is equivalent to true)
Apply (always apply third-party libraries and set the workspace
configuration)
ApplyInMemory (always apply third-party libraries but don't set the
workspace configuration)
Disable (don't ask and don't apply; this is equivalent to false)

Backwards compatibility with the old boolean configuration values is maintained; true is treated as Ask and false is treated as Disable.

Describe alternatives you've considered

None.

Additional context

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.