GithubHelp home page GithubHelp logo

aemr3 / efmls-configs-nvim Goto Github PK

View Code? Open in Web Editor NEW

This project forked from creativenull/efmls-configs-nvim

0.0 0.0 0.0 241 KB

An unofficial collection of linters and formatters configured for efm-langserver for neovim.

License: MIT License

Lua 89.21% TypeScript 10.79%

efmls-configs-nvim's Introduction

efmls-configs-nvim

Configs on dotfyle

An unofficial collection of linters and formatters configured for efm-langserver for neovim.

Supported linters and formatters

doc/SUPPORTED_LIST.md

Features

  • Out-of-box configurations for 90+ tools (linters and 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, welcome any contributions)
  • :checkhealth integration for status check

Documentation

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 = 'v1.x.x', -- version is optional, but recommended
  dependencies = { 'neovim/nvim-lspconfig' },
}

packer.nvim

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

vim-plug

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

Setup

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

To get started, make a languages table that will define configurations for the language of your choice. Or use the defaults provided by this plugin.

-- Register linters and formatters per language
local eslint = require('efmls-configs.linters.eslint')
local prettier = require('efmls-configs.formatters.prettier')
local stylua = require('efmls-configs.formatters.stylua')
local languages = {
  typescript = { eslint, prettier },
  lua = { stylua },
}

-- Or use the defaults provided by this plugin
-- check doc/SUPPORTED_LIST.md for the supported languages
--
-- local languages = require('efmls-configs.defaults').languages()

local efmls_config = {
  filetypes = vim.tbl_keys(languages),
  settings = {
    rootMarkers = { '.git/' },
    languages = languages,
  },
  init_options = {
    documentFormatting = true,
    documentRangeFormatting = true,
  },
}

require('lspconfig').efm.setup(vim.tbl_extend('force', efmls_config, {
  -- Pass your custom lsp config below like on_attach and capabilities
  --
  -- on_attach = on_attach,
  -- capabilities = capabilities,
}))

Default Configurations

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

Default configurations are an opt-in feature. To see all the configurations provided by default go to doc/SUPPORTED_LIST.md.

You can use a list of defaults provided by this plugin, in-case you don't want to specify configuration for each language.

local languages = require('efmls-configs.defaults').languages()

To add additional tools which are not provided by default you can extend via vim.tbl_extend(). This can also be used as a way to override defaults.

local languages = require('efmls-configs.defaults').languages()
languages = vim.tbl_extend('force', languages, {
  -- Custom languages, or override existing ones
  html = {
    require('efmls-configs.formatters.prettier'),
  },
})

Tips and Tricks

Format on save

There are couple ways you can format your code on save.

  1. Register an autocmd to run format on save:
local lsp_fmt_group = vim.api.nvim_create_augroup('LspFormattingGroup', {})
vim.api.nvim_create_autocmd('BufWritePost', {
  group = lsp_fmt_group,
  callback = function(ev)
    local efm = vim.lsp.get_active_clients({ name = 'efm', bufnr = ev.buf })

    if vim.tbl_isempty(efm) then
      return
    end

    vim.lsp.buf.format({ name = 'efm' })
  end,
})
  1. If you do not want to write and maintain the code above, then you can rely on a plugin like lukas-reineke/lsp-format.nvim which makes it easier to format on save.

Troubleshooting

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

Always run :checkhealth to see if there are any issue, when you get no response from the linter or formatter as you expected.

If you get "no executable found" issues in :checkhealth, this means that the linter or formatter was not found in the provided filepath. Ensure that it is installed globally or in a valid filepath.

For nodejs/npm, php/composer, ruby/bundler: check if the linter or formatter is installed in your node_modules (npm), vendor (composer/bundler) project folder, or installed globally.

Mason setup issue (:help efmls-configs-mason)

If you use mason, then you don't need to add anything extra for efmls-configs for it to work. But if you are having problems setting up then check the following:

  1. Make sure you call mason setup() before efm setup()
  2. Run :!which <tool> to check if the path is provided by mason

Alternatives

Credits

Credits goes to the following projects for inspiration:

  • efm-langserver for this awesome language server to provide an interface to run linters/formatters through a LSP protocol
  • ALE for a huge list of linters/formatters to look through and add them in here

efmls-configs-nvim's People

Contributors

creativenull avatar dimitrisdimitropoulos avatar gaetanlepage avatar itaranto avatar llllvvuu avatar davidosomething avatar mrjones2014 avatar whoissethdaniel avatar chrisgrieser avatar kuator avatar syyyr avatar jwilner avatar chiel avatar mariasolos avatar mskelton avatar nguymin4 avatar custompro98 avatar mohamad-supangat avatar noamsto avatar ojii3 avatar phrmendes avatar doums avatar rorynesbitt avatar trevors avatar hero3s avatar j-barnak avatar ohakutsu avatar lpoto avatar kvaggelakos avatar jtarasovic 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.