GithubHelp home page GithubHelp logo

sonarlint.nvim's Introduction

<script src="https://liberapay.com/schrieveslaach/widgets/button.js"></script>

Donate using Liberapay

sonarlint.nvim

Extensions for the built-in Language Server Protocol support in Neovim (>= 0.8.0) for sonarlint-language-server (>= 2.16.0.65434).

Demo of sonarlint.nvim on sonarlint-language-server it self

Required Third Party Plugins:

For Java projects nvim-jdtls is required to resolve classpath configurations that is then required to configure sonarlint-language-server as expected.

For certain features, e.g. Connected Mode, sonarlint-language-server needs to gather information about source code management (SCM). Therefore, sonarlint.nvim gathers these information via [gitsgins][gitsigns] plugin. If there is no gitsigns installed, sonarlint.nvim assumes that there is no SCM provider.

Warning ⚠️

This repository is work in progress and the API is likely to change.

Install sonarlint-ls

Manual installation

You can install the sonarlint-ls by extracting it from the sonarlint-vscode plugin. Head over to the releases and download the latest *.vsix file. As it is a ZIP file, it contains the sonarlint-ls.jar and all available analyzers. Extract these JAR files from the extension/server/ and extension/analyzers/, and configure sonarlint.nvim according to the setup section.

mason.nvim

If you are using mason.nvim you can simply do :MasonInstall sonarlint-language-server. See below for setup instructions when using this method.

Setup

⚠️ Make sure that you configure sonarlint.nvim after lspconfig.

local lspconfig = require('lspconfig')

-- do stuff with lspconfig

require('sonarlint').setup({
   --
})

For manual installation

require('sonarlint').setup({
   server = {
      cmd = {
         'java', '-jar', 'sonarlint-language-server-VERSION.jar',
         -- Ensure that sonarlint-language-server uses stdio channel
         '-stdio',
         '-analyzers', 'path/to/analyzer1.jar', 'path/to/analyzer2.jar', 'path/to/analyzer3.jar',
      },
   },
   filetypes = {
      -- Tested and working
      'python',
      'cpp',
      'java',
   }
})

For installation via mason.nvim

require('sonarlint').setup({
   server = {
      cmd = {
         'sonarlint-language-server',
         -- Ensure that sonarlint-language-server uses stdio channel
         '-stdio',
         '-analyzers',
         -- paths to the analyzers you need, using those for python and java in this example
         vim.fn.expand("$MASON/share/sonarlint-analyzers/sonarpython.jar"),
         vim.fn.expand("$MASON/share/sonarlint-analyzers/sonarcfamily.jar"),
         vim.fn.expand("$MASON/share/sonarlint-analyzers/sonarjava.jar"),
      }
   },
   filetypes = {
      -- Tested and working
      'python',
      'cpp',
      'java',
   }
})

Settings

Compilation Database

Analyzing C/C++ projects it is required to provide a Compilation Database file (see alse here. Therefore, sonarlint.nvim tries to find the Compilation Database automatically within your workspace. If that doesn't work, you can provide it manually.

require('sonarlint').setup({
   server = {
      cmd = {
         --
      },
      settings = {
         sonarlint = {
            pathToCompileCommands = "insert your path here"
         }
      }
   },
})

Rules

Rules can be configured, e.g. by turning them on or off, with following configuration.

require('sonarlint').setup({
   server = {
      cmd = {
         --
      },
      settings = {
         sonarlint = {
            rules = {
               ['typescript:S101'] = { level = 'on', parameters = { format = '^[A-Z][a-zA-Z0-9]*$' } },
               ['typescript:S103'] = { level = 'on', parameters = { maximumLineLength = 180 } },
               ['typescript:S106'] = { level = 'on' },
               ['typescript:S107'] = { level = 'on', parameters = { maximumFunctionParameters = 7 } }
            }
         }
      }
   },
})

sonarlint.nvim's People

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.