GithubHelp home page GithubHelp logo

Comments (11)

smartding avatar smartding commented on June 28, 2024 9

thank @lithammer @walialu , I figured it out after reading the README in diagnostic-languageserver. Here's my config:

require'nvim_lsp'.diagnosticls.setup{
  on_attach=on_attach_vim,
  filetypes = { "sh", },
  init_options = {
    filetypes = {
      sh = "shellcheck",
    },
    formatFiletypes = {
      sh = "shfmt",
    },
    formatters = {
      shfmt = {
        command = "shfmt",
        args = {
          "-i",
          "2",
          "-bn",
          "-ci",
          "-sr",
        },
      }
    },
    linters = {
      shellcheck = {
        command = "shellcheck",
        rootPatterns = {},
        isStdout = true,
        isStderr = false,
        debounce = 100,
        args = { "--format=gcc", "-"},
        offsetLine = 0,
        offsetColumn = 0,
        sourceName = "shellcheck",
        formatLines = 1,
        formatPattern = {
          "^([^:]+):(\\d+):(\\d+):\\s+([^:]+):\\s+(.*)$",
          {
            line = 2,
            column = 3,
            endline = 2,
            endColumn = 3,
            message = {5},
            security = 4
          }
        },
        securities  = {
          error  ="error",
          warning = "warning",
          note = "info"
        },
      }
    }
  }
}

from diagnostic-languageserver.

walialu avatar walialu commented on June 28, 2024 4

You can see my current configuration here: https://github.com/walialu/neovimfiles/blob/e68391c1d98b3da2f8adfe1583f258a17295537b/nvim/lua/lsp_config.lua#L46

from diagnostic-languageserver.

walialu avatar walialu commented on June 28, 2024 2

This lsp config is pretty rough, but should work (thanks @lithammer):

nvim_lsp.diagnosticls.setup{
	filetypes = { "javascript", "javascript.jsx" },
	init_options = {
		filetypes = {
			javascript = "eslint",
			["javascript.jsx"] = "eslint",
			javascriptreact = "eslint",
			typescriptreact = "eslint",
		},
		linters = {
			eslint = {
				sourceName = "eslint",
				command = "./node_modules/.bin/eslint",
				rootPatterns = { ".git" },
				debounce = 100,
				args = {
					"--stdin",
					"--stdin-filename",
					"%filepath",
					"--format",
					"json",
				},
				parseJson = {
					errorsRoot = "[0].messages",
					line = "line",
					column = "column",
					endLine = "endLine",
					endColumn = "endColumn",
					message = "${message} [${ruleId}]",
					security = "severity",
				};
				securities = {
					[2] = "error",
					[1] = "warning"
				}
			}
		}
	}
}

from diagnostic-languageserver.

iamcco avatar iamcco commented on June 28, 2024 1

in initializationOptions option

from diagnostic-languageserver.

iamcco avatar iamcco commented on June 28, 2024 1

@thisguychris Where to config initializationOptions options is relative to neovim's built-in LSP client. I do not use the built-in LSP client, so I have no idea. It should be support to config initializationOptions for the LS.

from diagnostic-languageserver.

smartding avatar smartding commented on June 28, 2024 1

I'm using neivim's built-in LSP client, and I have a config as follows for checking shell scripts

local on_attach_vim = function(client)
  require'completion'.on_attach(client)
  require'diagnostic'.on_attach(client)
end

require'nvim_lsp'.diagnosticls.setup{
  on_attach=on_attach_vim,
  filetypes = { "sh", },
  init_options = {
    filetypes = {
      sh = "shellcheck",
    },
    formatFiletypes = {
      sh = "shfmt",
    },
    formatters = {
      shfmt = {
        command = "shfmt",
        args = {
          "-i",
          "2",
          "-bn",
          "-ci",
          "-sr",
        },
      }
    }
  }
}

I have the following plugins installed:

Plug 'neovim/nvim-lspconfig'
Plug 'nvim-lua/completion-nvim'
Plug 'nvim-lua/diagnostic-nvim'

I open a shell script, nothing happens. Where am I supposed to find the diagnostic information?

from diagnostic-languageserver.

lithammer avatar lithammer commented on June 28, 2024 1

@smartding that config doesn't generate any diagnostics. I assume you want shellcheck to provide diagnostics, but you don't actually provide it any linter config for it (you only have a formatter configured). I think you need to take a look at the README again for an example of how to configure a linter. You can also search for "diagnosticls shellcheck" on GitHub to find some examples.

from diagnostic-languageserver.

thisguychris avatar thisguychris commented on June 28, 2024

hey @iamcco, what I meant was, where do I put this JSON file, do I reference it somewhere in vimrc? I get that coc has its own settings. I am more interested on how it's set up with just using neovim's built-in LSP?

from diagnostic-languageserver.

walialu avatar walialu commented on June 28, 2024

Hey @smartding, you need to config shellcheck to check your files. You can look at my configuration over here (this is how I configured shellcheck):

https://github.com/walialu/neovimfiles/blob/e68391c1d98b3da2f8adfe1583f258a17295537b/nvim/lua/lsp_config.lua#L83

from diagnostic-languageserver.

nyngwang avatar nyngwang commented on June 28, 2024

@smartding Do you know how to show diagnostic messages from formatters like isort?

from diagnostic-languageserver.

smartding avatar smartding commented on June 28, 2024

@nyngwang
No, I don't use isort.

from diagnostic-languageserver.

Related Issues (20)

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.