mirror of
https://github.com/LunarVim/LunarVim.git
synced 2025-07-30 23:54:50 +02:00
prettier and eslint configured
This commit is contained in:
parent
b3f2348d97
commit
7eea23bb6c
9 changed files with 123 additions and 93 deletions
51
README.md
51
README.md
|
@ -26,20 +26,24 @@ sudo rm -r neovim
|
||||||
|
|
||||||
## VSCode support
|
## VSCode support
|
||||||
|
|
||||||
After installing the Neovim extension in VSCode
|
After installing the [Neovim extension](https://github.com/asvetliakov/vscode-neovim) in VSCode
|
||||||
|
|
||||||
|
I recommend using this alongside the VSCode which-key extension
|
||||||
|
|
||||||
|
Along with some of my config files you can find in utils/vscode_config
|
||||||
|
|
||||||
Point the nvim path to your `nvim` binary
|
Point the nvim path to your `nvim` binary
|
||||||
|
|
||||||
Point your `init.vim` path to:
|
Point your `init.lua` path to:
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
$HOME/.config/nvim/lua/nv-vscode/init.vim
|
$HOME/.config/nvim/lua/nv-vscode/init.lua
|
||||||
```
|
```
|
||||||
|
|
||||||
or if you are using this config alongside your own:
|
or if you are using this config alongside your own:
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
$HOME/.config/nvim/lua/nv-vscode/init.vim
|
$HOME/.config/nvim/lua/nv-vscode/init.lua
|
||||||
```
|
```
|
||||||
|
|
||||||
## efm server is slow on close
|
## efm server is slow on close
|
||||||
|
@ -50,6 +54,44 @@ Install the latest with:
|
||||||
go get github.com/mattn/efm-langserver@HEAD
|
go get github.com/mattn/efm-langserver@HEAD
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Useful Programs
|
||||||
|
|
||||||
|
```
|
||||||
|
ranger
|
||||||
|
ueberzug
|
||||||
|
fd
|
||||||
|
ripgrep
|
||||||
|
jq
|
||||||
|
fzf
|
||||||
|
lazygit
|
||||||
|
lazydocker
|
||||||
|
ncdu
|
||||||
|
```
|
||||||
|
|
||||||
|
**Python**
|
||||||
|
|
||||||
|
```
|
||||||
|
pyright
|
||||||
|
flake8
|
||||||
|
yapf
|
||||||
|
```
|
||||||
|
|
||||||
|
**Lua**
|
||||||
|
|
||||||
|
```
|
||||||
|
ninja
|
||||||
|
lua-format
|
||||||
|
sumneko-lua
|
||||||
|
```
|
||||||
|
|
||||||
|
## Vim Gists
|
||||||
|
|
||||||
|
To use vim-gists you will need to configure the following:
|
||||||
|
|
||||||
|
```
|
||||||
|
git config --global github.user <username>
|
||||||
|
```
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
**HIGH PRIORITY**
|
**HIGH PRIORITY**
|
||||||
|
@ -62,6 +104,7 @@ go get github.com/mattn/efm-langserver@HEAD
|
||||||
- for vsnip :h vim-vsnip, also figure out what integr does
|
- for vsnip :h vim-vsnip, also figure out what integr does
|
||||||
|
|
||||||
**LOW PRIORITY**
|
**LOW PRIORITY**
|
||||||
|
- add utf8 line col and spaces (maybe blame)
|
||||||
- potentially switch to dashboard
|
- potentially switch to dashboard
|
||||||
- make java code actions prettier
|
- make java code actions prettier
|
||||||
- figure out how to customize java formatting
|
- figure out how to customize java formatting
|
||||||
|
|
1
init.lua
1
init.lua
|
@ -1,6 +1,7 @@
|
||||||
if vim.g.vscode then
|
if vim.g.vscode then
|
||||||
vim.cmd('source ~/.config/nvim/vimscript/nv-vscode/init.vim')
|
vim.cmd('source ~/.config/nvim/vimscript/nv-vscode/init.vim')
|
||||||
require('settings')
|
require('settings')
|
||||||
|
require('nv-quickscope')
|
||||||
else
|
else
|
||||||
-- General mappings
|
-- General mappings
|
||||||
require('plugins')
|
require('plugins')
|
||||||
|
|
|
@ -1,25 +1,40 @@
|
||||||
-- Example configuations here: https://github.com/mattn/efm-langserver
|
-- Example configuations here: https://github.com/mattn/efm-langserver
|
||||||
|
-- python
|
||||||
|
local flake8 = {
|
||||||
|
LintCommand = "flake8 --ignore=E501 --stdin-display-name ${INPUT} -",
|
||||||
|
lintStdin = true,
|
||||||
|
lintFormats = {"%f:%l:%c: %m"}
|
||||||
|
}
|
||||||
|
local isort = {formatCommand = "isort --quiet -", formatStdin = true}
|
||||||
|
local yapf = {formatCommand = "yapf --quiet", formatStdin = true}
|
||||||
|
-- lua
|
||||||
|
local luaFormat = {
|
||||||
|
formatCommand = "lua-format -i --no-keep-simple-function-one-line --column-limit=120",
|
||||||
|
formatStdin = true
|
||||||
|
}
|
||||||
|
-- JavaScript/React/TypeScript
|
||||||
|
local prettier = {formatCommand = "./node_modules/.bin/prettier --stdin-filepath ${INPUT}", formatStdin = true}
|
||||||
|
|
||||||
|
local eslint = {
|
||||||
|
lintCommand = "./node_modules/.bin/eslint -f unix --stdin --stdin-filename ${INPUT}",
|
||||||
|
lintIgnoreExitCode = true,
|
||||||
|
lintStdin = true,
|
||||||
|
lintFormats = {"%f:%l:%c: %m"},
|
||||||
|
formatCommand = "./node_modules/.bin/eslint --fix-to-stdout --stdin --stdin-filename=${INPUT}",
|
||||||
|
formatStdin = true
|
||||||
|
}
|
||||||
|
|
||||||
require"lspconfig".efm.setup {
|
require"lspconfig".efm.setup {
|
||||||
init_options = {documentFormatting = true},
|
-- init_options = {initializationOptions},
|
||||||
filetypes = {"lua", "python"},
|
init_options = {documentFormatting = true, codeAction = false},
|
||||||
|
filetypes = {"lua", "python", "javascriptreact", "javascript"},
|
||||||
settings = {
|
settings = {
|
||||||
rootMarkers = {".git/"},
|
rootMarkers = {".git/"},
|
||||||
languages = {
|
languages = {
|
||||||
lua = {
|
lua = {luaFormat},
|
||||||
{
|
python = {isort, yapf},
|
||||||
formatCommand = "lua-format -i --no-keep-simple-function-one-line --column-limit=100",
|
javascriptreact = {prettier, eslint},
|
||||||
formatStdin = true
|
javascript = {prettier, eslint}
|
||||||
}
|
|
||||||
},
|
|
||||||
python = {
|
|
||||||
{
|
|
||||||
LintCommand = "flake8 --ignore=E501 --stdin-display-name ${INPUT} -",
|
|
||||||
lintStdin = true,
|
|
||||||
lintFormats = {"%f:%l:%c: %m"},
|
|
||||||
formatCommand = "yapf --quiet",
|
|
||||||
formatStdin = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,32 +43,3 @@ require"lspconfig".efm.setup {
|
||||||
-- TODO also shellcheck and shell formatting
|
-- TODO also shellcheck and shell formatting
|
||||||
-- Also find way to toggle format on save
|
-- Also find way to toggle format on save
|
||||||
-- maybe this will help: https://superuser.com/questions/439078/how-to-disable-autocmd-or-augroup-in-vim
|
-- maybe this will help: https://superuser.com/questions/439078/how-to-disable-autocmd-or-augroup-in-vim
|
||||||
-- {
|
|
||||||
-- lintCommand = "eslint_d -f unix --stdin --stdin-filename ${INPUT}",
|
|
||||||
-- lintIgnoreExitCode = true,
|
|
||||||
-- lintStdin = true,
|
|
||||||
-- lintFormats = {"%f:%l:%c: %m"},
|
|
||||||
-- }
|
|
||||||
|
|
||||||
|
|
||||||
-- local eslint = {
|
|
||||||
-- lintCommand = './node_modules/.bin/eslint -f compact --stdin',
|
|
||||||
-- lintStdin = true,
|
|
||||||
-- lintFormats = {'%f: line %l, col %c, %trror - %m', '%f: line %l, col %c, %tarning - %m'},
|
|
||||||
-- lintIgnoreExitCode = true,
|
|
||||||
-- formatCommand = './node_modules/.bin/prettier-eslint --stdin --single-quote --print-width 120',
|
|
||||||
-- formatStdin = true,
|
|
||||||
-- }
|
|
||||||
--
|
|
||||||
-- nvim_lsp.efm.setup({
|
|
||||||
-- init_options = { documentFormatting = true },
|
|
||||||
-- root_dir = nvim_lsp.util.root_pattern('.git/'),
|
|
||||||
-- filetypes = {'javascript', 'javascriptreact'},
|
|
||||||
-- settings = {
|
|
||||||
-- rootMarkers = {'.git/'},
|
|
||||||
-- languages = {
|
|
||||||
-- javascript = {eslint},
|
|
||||||
-- javascriptreact = {eslint},
|
|
||||||
-- }
|
|
||||||
-- }
|
|
||||||
-- })
|
|
||||||
|
|
|
@ -1,24 +1,12 @@
|
||||||
-- TODO figure out why this don't work
|
-- TODO figure out why this don't work
|
||||||
vim.fn.sign_define("LspDiagnosticsSignError", {
|
vim.fn.sign_define("LspDiagnosticsSignError",
|
||||||
texthl = "LspDiagnosticsSignError",
|
{texthl = "LspDiagnosticsSignError", text = "", numhl = "LspDiagnosticsSignError"})
|
||||||
text = "",
|
vim.fn.sign_define("LspDiagnosticsSignWarning",
|
||||||
numhl = "LspDiagnosticsSignError"
|
{texthl = "LspDiagnosticsSignWarning", text = "", numhl = "LspDiagnosticsSignWarning"})
|
||||||
})
|
vim.fn.sign_define("LspDiagnosticsSignInformation",
|
||||||
vim.fn.sign_define("LspDiagnosticsSignWarning", {
|
{texthl = "LspDiagnosticsSignInformation", text = "", numhl = "LspDiagnosticsSignInformation"})
|
||||||
texthl = "LspDiagnosticsSignWarning",
|
vim.fn.sign_define("LspDiagnosticsSignHint",
|
||||||
text = "",
|
{texthl = "LspDiagnosticsSignHint", text = "", numhl = "LspDiagnosticsSignHint"})
|
||||||
numhl = "LspDiagnosticsSignWarning"
|
|
||||||
})
|
|
||||||
vim.fn.sign_define("LspDiagnosticsSignInformation", {
|
|
||||||
texthl = "LspDiagnosticsSignInformation",
|
|
||||||
text = "",
|
|
||||||
numhl = "LspDiagnosticsSignInformation"
|
|
||||||
})
|
|
||||||
vim.fn.sign_define("LspDiagnosticsSignHint", {
|
|
||||||
texthl = "LspDiagnosticsSignHint",
|
|
||||||
text = "",
|
|
||||||
numhl = "LspDiagnosticsSignHint"
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.cmd('nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>')
|
vim.cmd('nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>')
|
||||||
vim.cmd('nnoremap <silent> gD <cmd>lua vim.lsp.buf.declaration()<CR>')
|
vim.cmd('nnoremap <silent> gD <cmd>lua vim.lsp.buf.declaration()<CR>')
|
||||||
|
@ -42,10 +30,7 @@ autocmd BufWritePre *.lua lua vim.lsp.buf.formatting_sync(nil, 100) ]]
|
||||||
-- Java
|
-- Java
|
||||||
-- autocmd FileType java nnoremap ca <Cmd>lua require('jdtls').code_action()<CR>
|
-- autocmd FileType java nnoremap ca <Cmd>lua require('jdtls').code_action()<CR>
|
||||||
|
|
||||||
local lsp_config = {}
|
local function documentHighlight(client, bufnr)
|
||||||
|
|
||||||
function lsp_config.common_on_attach(client, bufnr)
|
|
||||||
|
|
||||||
-- Set autocommands conditional on server_capabilities
|
-- Set autocommands conditional on server_capabilities
|
||||||
if client.resolved_capabilities.document_highlight then
|
if client.resolved_capabilities.document_highlight then
|
||||||
vim.api.nvim_exec([[
|
vim.api.nvim_exec([[
|
||||||
|
@ -58,7 +43,19 @@ function lsp_config.common_on_attach(client, bufnr)
|
||||||
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
|
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
|
||||||
augroup END
|
augroup END
|
||||||
]], false)
|
]], false)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
local lsp_config = {}
|
||||||
|
|
||||||
|
function lsp_config.common_on_attach(client, bufnr)
|
||||||
|
documentHighlight(client, bufnr)
|
||||||
|
end
|
||||||
|
|
||||||
|
function lsp_config.tsserver_on_attach(client, bufnr)
|
||||||
|
lsp_config.common_on_attach(client, bufnr)
|
||||||
|
client.resolved_capabilities.document_formatting = false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Use a loop to conveniently both setup defined servers
|
-- Use a loop to conveniently both setup defined servers
|
||||||
|
|
|
@ -7,4 +7,9 @@
|
||||||
-- require'completion'.on_attach(client)
|
-- require'completion'.on_attach(client)
|
||||||
-- require'illuminate'.on_attach(client)
|
-- require'illuminate'.on_attach(client)
|
||||||
-- end
|
-- end
|
||||||
require'lspconfig'.tsserver.setup {on_attach = require'lsp'.common_on_attach}
|
require'lspconfig'.tsserver.setup {
|
||||||
|
on_attach = require'lsp'.tsserver_on_attach,
|
||||||
|
-- This makes sure tsserver is not used for formatting (I prefer prettier)
|
||||||
|
-- on_attach = require'lsp'.common_on_attach,
|
||||||
|
settings = {documentFormatting = false}
|
||||||
|
}
|
||||||
|
|
|
@ -55,6 +55,8 @@ gls.left[1] = {
|
||||||
highlight = {colors.red, colors.bg, 'bold'}
|
highlight = {colors.red, colors.bg, 'bold'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
print(vim.fn.getbufvar(0,'ts'))
|
||||||
|
vim.fn.getbufvar(0,'ts')
|
||||||
|
|
||||||
gls.left[2] = {
|
gls.left[2] = {
|
||||||
GitIcon = {
|
GitIcon = {
|
||||||
|
|
|
@ -7,6 +7,7 @@ local pairs_map = {
|
||||||
['['] = ']',
|
['['] = ']',
|
||||||
['{'] = '}',
|
['{'] = '}',
|
||||||
['`'] = '`',
|
['`'] = '`',
|
||||||
|
['```'] = '```',
|
||||||
}
|
}
|
||||||
local disable_filetype = { "TelescopePrompt" }
|
local disable_filetype = { "TelescopePrompt" }
|
||||||
local break_line_filetype = nil -- mean all file type
|
local break_line_filetype = nil -- mean all file type
|
||||||
|
|
|
@ -1,21 +1,15 @@
|
||||||
require'nvim-treesitter.configs'.setup {
|
require'nvim-treesitter.configs'.setup {
|
||||||
ensure_installed = "all", -- one of "all", "maintained" (parsers with maintainers), or a list of languages
|
ensure_installed = "all", -- one of "all", "maintained" (parsers with maintainers), or a list of languages
|
||||||
highlight = {
|
highlight = {
|
||||||
enable = true, -- false will disable the whole extension
|
enable = true -- false will disable the whole extension
|
||||||
},
|
},
|
||||||
playground = {
|
playground = {
|
||||||
enable = true,
|
enable = true,
|
||||||
disable = {},
|
disable = {},
|
||||||
updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code
|
updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code
|
||||||
persist_queries = false -- Whether the query persists across vim sessions
|
persist_queries = false -- Whether the query persists across vim sessions
|
||||||
},
|
},
|
||||||
rainbow = {
|
rainbow = {enable = false},
|
||||||
enable = false
|
-- refactor = {highlight_definitions = {enable = true}}
|
||||||
},
|
|
||||||
refactor = {
|
|
||||||
highlight_definitions = {
|
|
||||||
enable = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ return require('packer').startup(function(use)
|
||||||
|
|
||||||
-- Treesitter
|
-- Treesitter
|
||||||
use {'nvim-treesitter/nvim-treesitter', run = ':TSUpdate'}
|
use {'nvim-treesitter/nvim-treesitter', run = ':TSUpdate'}
|
||||||
|
use 'nvim-treesitter/nvim-treesitter-refactor'
|
||||||
use 'nvim-treesitter/playground'
|
use 'nvim-treesitter/playground'
|
||||||
use 'p00f/nvim-ts-rainbow'
|
use 'p00f/nvim-ts-rainbow'
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue