python/efm config that's better
This commit is contained in:
parent
4eca2ee06a
commit
2e87881195
3 changed files with 148 additions and 31 deletions
|
|
@ -99,6 +99,9 @@ augroup go
|
||||||
autocmd FileType go set softtabstop=2
|
autocmd FileType go set softtabstop=2
|
||||||
autocmd FileType go set shiftwidth=2
|
autocmd FileType go set shiftwidth=2
|
||||||
autocmd FileType go set noexpandtab
|
autocmd FileType go set noexpandtab
|
||||||
|
autocmd FileType go imap <buffer> <silent> <Leader>rr <C-o>:GoIfErr<cr>
|
||||||
|
autocmd FileType go nmap <buffer> <silent> <Leader>rr :GoIfErr<cr>
|
||||||
|
autocmd FileType go nnoremap <silent> <Leader>im <cmd>lua require('telescope').extensions.goimpl.goimpl{theme = "ivy", layout_config = {height = 10}}<cr>
|
||||||
"autocmd FileType go nmap <Leader>gd <Plug>(go-doc)
|
"autocmd FileType go nmap <Leader>gd <Plug>(go-doc)
|
||||||
"autocmd FileType go nmap gd <Plug>(go-def)
|
"autocmd FileType go nmap gd <Plug>(go-def)
|
||||||
augroup END
|
augroup END
|
||||||
|
|
|
||||||
165
.vim/nvim.lua
165
.vim/nvim.lua
|
|
@ -7,6 +7,13 @@ local nvim_lsp = require 'lspconfig'
|
||||||
local on_attach = function(client)
|
local on_attach = function(client)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Set my preferred diagnostic options
|
||||||
|
local diagnostic_options = {
|
||||||
|
virtual_text = false,
|
||||||
|
signs = true,
|
||||||
|
update_in_insert = false,
|
||||||
|
}
|
||||||
|
|
||||||
local rust_capabilities = vim.lsp.protocol.make_client_capabilities()
|
local rust_capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
rust_capabilities.textDocument.completion.completionItem.snippetSupport = true
|
rust_capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||||
rust_capabilities.textDocument.completion.completionItem.resolveSupport = {
|
rust_capabilities.textDocument.completion.completionItem.resolveSupport = {
|
||||||
|
|
@ -17,6 +24,16 @@ rust_capabilities.textDocument.completion.completionItem.resolveSupport = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local default_capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
|
default_capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||||
|
default_capabilities.textDocument.completion.completionItem.resolveSupport = {
|
||||||
|
properties = {
|
||||||
|
'documentation',
|
||||||
|
'detail',
|
||||||
|
'additionalTextEdits',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
-- Enable rust_analyzer
|
-- Enable rust_analyzer
|
||||||
nvim_lsp.rust_analyzer.setup({
|
nvim_lsp.rust_analyzer.setup({
|
||||||
on_attach = function(client, bufnr)
|
on_attach = function(client, bufnr)
|
||||||
|
|
@ -54,7 +71,80 @@ nvim_lsp.gopls.setup({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
nvim_lsp.pyright.setup({ on_attach = on_attach })
|
|
||||||
|
local function filter(arr, func)
|
||||||
|
-- Filter in place
|
||||||
|
-- https://stackoverflow.com/questions/49709998/how-to-filter-a-lua-array-inplace
|
||||||
|
local new_index = 1
|
||||||
|
local size_orig = #arr
|
||||||
|
for old_index, v in ipairs(arr) do
|
||||||
|
if func(v, old_index) then
|
||||||
|
arr[new_index] = v
|
||||||
|
new_index = new_index + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for i = new_index, size_orig do arr[i] = nil end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function pyright_accessed_filter(diagnostic)
|
||||||
|
-- Allow kwargs to be unused, sometimes you want many functions to take the
|
||||||
|
-- same arguments but you don't use all the arguments in all the functions,
|
||||||
|
-- so kwargs is used to suck up all the extras
|
||||||
|
if diagnostic.message == '"kwargs" is not accessed' then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
-- Allow variables starting with an underscore
|
||||||
|
if string.match(diagnostic.message, '"_.+" is not accessed') then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local function pyright_custom_diagnostic(a, params, client_id, c, config)
|
||||||
|
filter(params.diagnostics, pyright_accessed_filter)
|
||||||
|
vim.lsp.diagnostic.on_publish_diagnostics(a, params, client_id, c, config)
|
||||||
|
end
|
||||||
|
|
||||||
|
nvim_lsp.pyright.setup({ on_attach = function(client, bufnr)
|
||||||
|
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(pyright_custom_diagnostic, diagnostic_options)
|
||||||
|
end})
|
||||||
|
--nvim_lsp.pyright.setup({ on_attach = on_attach })
|
||||||
|
--nvim_lsp.pylsp.setup({
|
||||||
|
--on_attach = on_attach,
|
||||||
|
--settings = {
|
||||||
|
--pylsp = {
|
||||||
|
--plugins = {
|
||||||
|
---- formatter options
|
||||||
|
----black = { enabled = true },
|
||||||
|
--autopep8 = { enabled = false },
|
||||||
|
--yapf = { enabled = false },
|
||||||
|
---- linter options
|
||||||
|
--pylint = { enabled = false, executable = "pylint" },
|
||||||
|
--pyflakes = { enabled = false },
|
||||||
|
--pycodestyle = { enabled = false },
|
||||||
|
---- type checker
|
||||||
|
--pylsp_mypy = { enabled = true },
|
||||||
|
---- auto-completion options
|
||||||
|
--jedi_completion = { enabled = false },
|
||||||
|
---- import sorting
|
||||||
|
----pyls_isort = { enabled = true },
|
||||||
|
----flake8 = {
|
||||||
|
----maxLineLength = 100,
|
||||||
|
----},
|
||||||
|
--pycodestyle = {
|
||||||
|
--maxLineLength = 100,
|
||||||
|
--},
|
||||||
|
----rope_autoimport = {
|
||||||
|
----enabled = true
|
||||||
|
----},
|
||||||
|
----rope_completion = {
|
||||||
|
----enabled = true
|
||||||
|
----},
|
||||||
|
--}
|
||||||
|
--}
|
||||||
|
--}
|
||||||
|
--})
|
||||||
|
|
||||||
--nvim_lsp.clangd.setup({ on_attach = on_attach })
|
--nvim_lsp.clangd.setup({ on_attach = on_attach })
|
||||||
nvim_lsp.tsserver.setup {
|
nvim_lsp.tsserver.setup {
|
||||||
|
|
@ -100,7 +190,12 @@ require 'lspconfig'.lua_ls.setup {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
require('go').setup()
|
|
||||||
|
require('go').setup({
|
||||||
|
iferr_vertical_shift = 2
|
||||||
|
})
|
||||||
|
|
||||||
|
require('telescope').load_extension('goimpl')
|
||||||
|
|
||||||
function org_imports(wait_ms)
|
function org_imports(wait_ms)
|
||||||
local params = vim.lsp.util.make_range_params()
|
local params = vim.lsp.util.make_range_params()
|
||||||
|
|
@ -120,35 +215,42 @@ function org_imports(wait_ms)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
nvim_lsp.efm.setup {
|
-- register linters
|
||||||
init_options = { documentFormatting = true },
|
local luaformat = require("efmls-configs.formatters.lua_format")
|
||||||
settings = {
|
local rustfmt = require('efmls-configs.formatters.rustfmt')
|
||||||
rootMarkers = { ".git/", "package.json" },
|
local black = require('efmls-configs.formatters.black')
|
||||||
languages = {
|
local mypy = require('efmls-configs.linters.mypy')
|
||||||
lua = {
|
local eslint = require('efmls-configs.linters.eslint')
|
||||||
{ formatCommand = "lua-format -i", formatStdin = true }
|
local isort = require('efmls-configs.formatters.isort')
|
||||||
},
|
local languages = {
|
||||||
python = {
|
typescript = { eslint },
|
||||||
{ formatCommand = 'black --quiet -', formatStdin = true }
|
lua = { luaformat },
|
||||||
},
|
python = { black, mypy, isort },
|
||||||
rust = {
|
rust = { rustfmt },
|
||||||
{ formatCommand = 'rustfmt', formatStdin = true }
|
|
||||||
},
|
|
||||||
typescript = {
|
|
||||||
{ formatCommand = 'pnpm exec eslint --fix' }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 = default_capabilities,
|
||||||
|
}))
|
||||||
|
|
||||||
-- Enable diagnostics
|
-- Enable diagnostics
|
||||||
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
|
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
|
||||||
vim.lsp.diagnostic.on_publish_diagnostics, {
|
vim.lsp.diagnostic.on_publish_diagnostics,
|
||||||
virtual_text = false,
|
diagnostic_options)
|
||||||
signs = true,
|
|
||||||
update_in_insert = false,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
-- Compe setup
|
-- Compe setup
|
||||||
require 'compe'.setup {
|
require 'compe'.setup {
|
||||||
|
|
@ -321,6 +423,12 @@ require('telescope').setup {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
pickers = {
|
pickers = {
|
||||||
|
goimpl = {
|
||||||
|
theme = "ivy",
|
||||||
|
layout_config = {
|
||||||
|
height = 10,
|
||||||
|
},
|
||||||
|
},
|
||||||
lsp_code_actions = {
|
lsp_code_actions = {
|
||||||
theme = "ivy",
|
theme = "ivy",
|
||||||
layout_config = {
|
layout_config = {
|
||||||
|
|
@ -367,6 +475,7 @@ require('telescope').setup {
|
||||||
layout_config = {
|
layout_config = {
|
||||||
height = 15,
|
height = 15,
|
||||||
},
|
},
|
||||||
|
ignore_current_buffer = true,
|
||||||
initial_mode = "normal",
|
initial_mode = "normal",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -571,3 +680,5 @@ function neogen_dwim()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
require("murdock")
|
||||||
|
|
|
||||||
11
.vimrc
11
.vimrc
|
|
@ -222,7 +222,9 @@ Plug 'ray-x/go.nvim'
|
||||||
|
|
||||||
Plug 'RishabhRD/popfix'
|
Plug 'RishabhRD/popfix'
|
||||||
Plug 'RishabhRD/nvim-lsputils'
|
Plug 'RishabhRD/nvim-lsputils'
|
||||||
|
Plug 'stevanmilic/nvim-lspimport'
|
||||||
Plug 'folke/trouble.nvim'
|
Plug 'folke/trouble.nvim'
|
||||||
|
Plug 'creativenull/efmls-configs-nvim', { 'tag': 'v1.*' }
|
||||||
|
|
||||||
" Plugins that do specific things
|
" Plugins that do specific things
|
||||||
"Plug 'Shougo/vimproc.vim'
|
"Plug 'Shougo/vimproc.vim'
|
||||||
|
|
@ -254,6 +256,7 @@ Plug 'danymat/neogen'
|
||||||
" Unclear
|
" Unclear
|
||||||
"Plug 'ncm2/float-preview.nvim'
|
"Plug 'ncm2/float-preview.nvim'
|
||||||
Plug 'lambdalisue/gina.vim'
|
Plug 'lambdalisue/gina.vim'
|
||||||
|
Plug 'edolphin-ydf/goimpl.nvim'
|
||||||
|
|
||||||
call plug#end()
|
call plug#end()
|
||||||
|
|
||||||
|
|
@ -292,6 +295,8 @@ nnoremap <silent> <leader>xx <cmd>TroubleToggle<cr>
|
||||||
nnoremap <silent> <leader>xq <cmd>lua vim.diagnostic.setqflist()<CR>
|
nnoremap <silent> <leader>xq <cmd>lua vim.diagnostic.setqflist()<CR>
|
||||||
"nnoremap <silent> <leader>nc <cmd>lua neogen_dwim()<CR>
|
"nnoremap <silent> <leader>nc <cmd>lua neogen_dwim()<CR>
|
||||||
nnoremap <silent> <leader>nc <cmd>lua require('neogen').generate({ type = 'any' })<CR>
|
nnoremap <silent> <leader>nc <cmd>lua require('neogen').generate({ type = 'any' })<CR>
|
||||||
|
nnoremap <silent> gm <cmd>lua require('lspimport').import()<CR>
|
||||||
|
|
||||||
|
|
||||||
" Set updatetime for CursorHold
|
" Set updatetime for CursorHold
|
||||||
" 300ms of no cursor movement to trigger CursorHold
|
" 300ms of no cursor movement to trigger CursorHold
|
||||||
|
|
@ -1029,7 +1034,8 @@ nnoremap <Leader>hh :A<CR>
|
||||||
" CommandT is useful, but if I'm juggling lots of buffers, limit it to another
|
" CommandT is useful, but if I'm juggling lots of buffers, limit it to another
|
||||||
" one I have open (instead of standard <Leader>t).
|
" one I have open (instead of standard <Leader>t).
|
||||||
"nnoremap <silent> <Leader>o :<C-u>Buffers<CR>
|
"nnoremap <silent> <Leader>o :<C-u>Buffers<CR>
|
||||||
nnoremap <silent> <Leader>o <cmd>lua require('telescope.builtin').buffers{}<cr>
|
nnoremap <silent> <Leader>o <cmd>lua require('telescope.builtin').buffers{initial_mode = "insert"}<cr>
|
||||||
|
nnoremap <silent> <C-j> <cmd>lua require('telescope.builtin').buffers{prompt_prefix = " "}<cr>
|
||||||
"nnoremap <Leader>j <C-^>
|
"nnoremap <Leader>j <C-^>
|
||||||
"nnoremap <Leader>p :PTW
|
"nnoremap <Leader>p :PTW
|
||||||
nnoremap <Leader>p :LustyJugglePrevious<CR>
|
nnoremap <Leader>p :LustyJugglePrevious<CR>
|
||||||
|
|
@ -1046,9 +1052,6 @@ endif
|
||||||
" ** SEE ALSO **
|
" ** SEE ALSO **
|
||||||
" filetype.vim
|
" filetype.vim
|
||||||
|
|
||||||
command Comments lexpr system($HOME . '/src/gogh/src/github.com/barakmich/gogh/gogh')
|
|
||||||
|
|
||||||
|
|
||||||
"call remote#host#RegisterPlugin('python3', '/home/barak/.vim/bundle/deoplete.nvim/rplugin/python3/deoplete', [
|
"call remote#host#RegisterPlugin('python3', '/home/barak/.vim/bundle/deoplete.nvim/rplugin/python3/deoplete', [
|
||||||
"\ {'sync': v:true, 'name': '_deoplete', 'type': 'function', 'opts': {}},
|
"\ {'sync': v:true, 'name': '_deoplete', 'type': 'function', 'opts': {}},
|
||||||
"\ ])
|
"\ ])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue