Code Monkey home page Code Monkey logo

efmls-configs-nvim's Introduction

efmls-configs-nvim

Configs on dotfyle

An unofficial collection of linters and formatters configured for efm-langserver to work with the built-in nvim-lsp. Works only for Neovim >= 0.5.

Supported linters and formatters

Check out SUPPORTED_LIST.md

Features

  • Out-of-box configurations for 70+ linters & formatters
  • Intelligently detect tools installed project-wide or system-wide - works only for node/npm, php/composer and ruby/bundler (additional support for other build tools coming soon)
  • Use :checkhealth for a quick diagnostic on tools, to check if tool is available
  • Ability to customize configurations for your specific project use-cases (see Advanced Setup)

Vim Docs

Documentation can be accessed via :help efmls-configs or further below.

Requirements

Installation

Install with your favorite plugin manager or just use builtin packages.

lazy.nvim

{
  'creativenull/efmls-configs-nvim',
  version = 'v0.2.x', -- tag is optional
  dependencies = { 'neovim/nvim-lspconfig' },
}

packer.nvim

use {
  'creativenull/efmls-configs-nvim',
  tag = 'v0.2.*', -- tag is optional
  requires = { 'neovim/nvim-lspconfig' },
}

vim-plug

Plug 'neovim/nvim-lspconfig'
Plug 'creativenull/efmls-configs-nvim', { 'tag': 'v0.2.*' } " tag is optional

Documentation

Setup

See also :help efmls-configs-setup to view inside neovim.

Step 1

You need to first initialize the plugin with the init() function, this is where you can pass your LSP options like on_attach, capabilities, init_options, etc.

local function on_attach(client)
  print('Attached to ' .. client.name)
end

local efmls = require 'efmls-configs'
efmls.init {
  -- Your custom attach function
  on_attach = on_attach,

  -- Enable formatting provided by efm langserver
  init_options = {
    documentFormatting = true,
  },
}

Step 2

Finally, register the linters and formatters you want to run on the specific filetypes with the setup() function. Below is an example to setup eslint and prettier to work with a javascript filetype.

local eslint = require 'efmls-configs.linters.eslint'
local prettier = require 'efmls-configs.formatters.prettier'
efmls.setup {
  javascript = {
    linter = eslint,
    formatter = prettier,
  },
}

Default Configuration

See also :help efmls-configs-defaults to view inside neovim.

A default configuration for the supported filetypes is provided but not activated by default.

To activate the default configuration you can pass the default_config flag as true in the init function. Below are the default values for init():

efmls.init {
  -- Use a list of default configurations
  -- set by this plugin
  -- (Default: false)
  default_config = false,
}

efmls.setup()

You will still need to call the setup() after init() for the changes to take effect. You can still pass your custom configurations to setup() as show in the Setup section and it will override any default configuration set by default_config if it's the same filetype.

Advanced Configuration Setup

See also :help efmls-configs-advanced to view inside neovim.

If you want to change some settings that are not provided in the default config, you can change them with vim.tbl_extend. These configs take the same keys referenced in the efm-langserver schema file in json format, aka camelCase.

local eslint = require 'efmls-configs.linters.eslint'
eslint = vim.tbl_extend('force', eslint, {
  prefix = 'new eslint prefix',
  lintCommand = 'eslint --format visualstudio --stdin',
})

efmls.setup {
  javascript = { linter = eslint },
}

Implementation Details (TODO)

  • Testing

Credits

Credits goes to the following projects for inspiration:

  • efm-langserver - for the awesome language server to provide linters/formatters through a LSP protocol
  • ale - for a huge list of supported linters/formatters to look through

efmls-configs-nvim's People

Contributors

creativenull avatar llllvvuu avatar mrjones2014 avatar chiel avatar penaz91 avatar whynothugo avatar iturdikulov avatar jtarasovic avatar rorynesbitt avatar trevors avatar

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.