mirror of
https://github.com/LunarVim/LunarVim.git
synced 2024-09-20 18:45:08 +02:00
new settings options for autoformat
This commit is contained in:
parent
6e65c34e28
commit
edc640c50f
7 changed files with 73 additions and 43 deletions
4
init.lua
4
init.lua
|
@ -1,8 +1,9 @@
|
||||||
-- General mappings
|
-- General mappings
|
||||||
require('plugins')
|
require('plugins')
|
||||||
require('nv-utils')
|
|
||||||
require('nv-globals')
|
require('nv-globals')
|
||||||
|
require('nv-utils')
|
||||||
vim.cmd('luafile ~/.config/nvim/nv-settings.lua')
|
vim.cmd('luafile ~/.config/nvim/nv-settings.lua')
|
||||||
|
require('nv-autocommands')
|
||||||
-- require('config')
|
-- require('config')
|
||||||
require('settings')
|
require('settings')
|
||||||
require('keymappings')
|
require('keymappings')
|
||||||
|
@ -59,6 +60,5 @@ require('lsp.html-ls')
|
||||||
require('lsp.efm-general-ls')
|
require('lsp.efm-general-ls')
|
||||||
require('lsp.virtual_text')
|
require('lsp.virtual_text')
|
||||||
|
|
||||||
-- Source config last
|
|
||||||
-- vim.lsp.callbacks["textDocument/publishDiagnostics"] = function() end
|
-- vim.lsp.callbacks["textDocument/publishDiagnostics"] = function() end
|
||||||
-- vim.lsp.handlers["textDocument/publishDiagnostics"] = nil
|
-- vim.lsp.handlers["textDocument/publishDiagnostics"] = nil
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
require'lspconfig'.clangd.setup{
|
require'lspconfig'.clangd.setup {
|
||||||
cmd = {DATA_PATH .. "/lspinstall/cpp/clangd/bin/clangd"},
|
cmd = {DATA_PATH .. "/lspinstall/cpp/clangd/bin/clangd"},
|
||||||
on_attach = require'lsp'.common_on_attach
|
on_attach = require'lsp'.common_on_attach
|
||||||
}
|
}
|
||||||
|
|
48
lua/nv-autocommands/init.lua
Normal file
48
lua/nv-autocommands/init.lua
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
local utils = require('nv-utils')
|
||||||
|
|
||||||
|
local auto_formatters = { }
|
||||||
|
|
||||||
|
local python_autoformat = {'BufWritePre', '*.py', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
|
||||||
|
if O.python.autoformat then table.insert(auto_formatters, python_autoformat) end
|
||||||
|
|
||||||
|
local javascript_autoformat = {'BufWritePre', '*.js', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
|
||||||
|
local javascriptreact_autoformat = {'BufWritePre', '*.jsx', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
|
||||||
|
if O.tsserver.autoformat then
|
||||||
|
table.insert(auto_formatters, javascript_autoformat)
|
||||||
|
table.insert(auto_formatters, javascriptreact_autoformat)
|
||||||
|
end
|
||||||
|
|
||||||
|
local lua_format = {'BufWritePre', '*.lua', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
|
||||||
|
if O.lua.autoformat then table.insert(auto_formatters, lua_format) end
|
||||||
|
|
||||||
|
local json_format = {'BufWritePre', '*.json', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
|
||||||
|
if O.json.autoformat then table.insert(auto_formatters, json_format) end
|
||||||
|
|
||||||
|
utils.define_augroups({
|
||||||
|
_general_settings = {
|
||||||
|
{'TextYankPost', '*', 'lua require(\'vim.highlight\').on_yank({higroup = \'Search\', timeout = 200})'},
|
||||||
|
{'BufWinEnter', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
|
||||||
|
{'BufRead', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
|
||||||
|
{'BufNewFile', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'}
|
||||||
|
|
||||||
|
-- {'User', 'GoyoLeave', 'lua require(\'galaxyline\').disable_galaxyline()'},
|
||||||
|
-- {'User', 'GoyoEnter', 'lua require(\'galaxyline\').galaxyline_augroup()'},
|
||||||
|
},
|
||||||
|
_java = {
|
||||||
|
{'FileType', 'java', 'luafile ~/.config/nvim/lua/lsp/java-ls.lua'},
|
||||||
|
{'FileType', 'java', 'nnoremap ca <Cmd>lua require(\'jdtls\').code_action()<CR>'}
|
||||||
|
},
|
||||||
|
_dashboard = {
|
||||||
|
-- seems to be nobuflisted that makes my stuff disapear will do more testing
|
||||||
|
{
|
||||||
|
'FileType', 'dashboard',
|
||||||
|
'setlocal nocursorline noswapfile synmaxcol& signcolumn=no norelativenumber nocursorcolumn nospell nolist nonumber bufhidden=wipe colorcolumn= foldcolumn=0 matchpairs= '
|
||||||
|
}, {'FileType', 'dashboard', 'set showtabline=0 | autocmd WinLeave <buffer> set showtabline=2'}
|
||||||
|
},
|
||||||
|
_markdown = {{'FileType', 'markdown', 'setlocal wrap'}, {'FileType', 'markdown', 'setlocal spell'}},
|
||||||
|
_solidity = {
|
||||||
|
{'BufWinEnter', '.sol', 'setlocal filetype=solidity'}, {'BufRead', '*.sol', 'setlocal filetype=solidity'},
|
||||||
|
{'BufNewFile', '*.sol', 'setlocal filetype=solidity'}
|
||||||
|
},
|
||||||
|
_auto_formatters = auto_formatters
|
||||||
|
})
|
|
@ -1,6 +1,5 @@
|
||||||
O = {
|
O = {
|
||||||
|
auto_close_tree = 0,
|
||||||
auto_close_tree = 0,
|
|
||||||
auto_complete = true,
|
auto_complete = true,
|
||||||
colorscheme = 'nvcode',
|
colorscheme = 'nvcode',
|
||||||
python = {
|
python = {
|
||||||
|
@ -10,7 +9,15 @@ O = {
|
||||||
isort = false,
|
isort = false,
|
||||||
diagnostics = {virtual_text = true, signs = true, underline = true}
|
diagnostics = {virtual_text = true, signs = true, underline = true}
|
||||||
},
|
},
|
||||||
lua = {formatter = '', autoformat = false, virtual_text = true},
|
|
||||||
|
lua = {
|
||||||
|
|
||||||
|
-- @usage can be lua-format
|
||||||
|
formatter = '',
|
||||||
|
|
||||||
|
autoformat = false,
|
||||||
|
diagnostics = {virtual_text = true, signs = true, underline = true}
|
||||||
|
},
|
||||||
sh = {
|
sh = {
|
||||||
linter = '',
|
linter = '',
|
||||||
formatter = '',
|
formatter = '',
|
||||||
|
@ -23,9 +30,9 @@ O = {
|
||||||
autoformat = false,
|
autoformat = false,
|
||||||
diagnostics = {virtual_text = true, signs = true, underline = true}
|
diagnostics = {virtual_text = true, signs = true, underline = true}
|
||||||
},
|
},
|
||||||
|
json = {formatter = '', autoformat = false, diagnostics = {virtual_text = true, signs = true, underline = true}}
|
||||||
-- css = {formatter = '', autoformat = false, virtual_text = true},
|
-- css = {formatter = '', autoformat = false, virtual_text = true},
|
||||||
-- json = {formatter = '', autoformat = false, virtual_text = true}
|
-- json = {formatter = '', autoformat = false, virtual_text = true}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DATA_PATH = vim.fn.stdpath('data')
|
DATA_PATH = vim.fn.stdpath('data')
|
||||||
|
|
|
@ -22,35 +22,6 @@ function nv_utils.define_augroups(definitions) -- {{{1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
nv_utils.define_augroups({
|
|
||||||
_general_settings = {
|
|
||||||
{'TextYankPost', '*', 'lua require(\'vim.highlight\').on_yank({higroup = \'Search\', timeout = 200})'},
|
|
||||||
{'BufWinEnter', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
|
|
||||||
{'BufRead', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
|
|
||||||
{'BufNewFile', '*', 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o'},
|
|
||||||
{'FileType', 'java', 'luafile ~/.config/nvim/lua/lsp/java-ls.lua'},
|
|
||||||
{'FileType', 'java', 'nnoremap ca <Cmd>lua require(\'jdtls\').code_action()<CR>'},
|
|
||||||
{'FileType', 'markdown', 'setlocal wrap'}, {'FileType', 'markdown', 'setlocal spell'},
|
|
||||||
{'BufWinEnter', '.sol', 'setlocal filetype=solidity'},
|
|
||||||
|
|
||||||
-- seems to be nobuflisted that makes my stuff disapear will do more testing
|
|
||||||
{'FileType', 'dashboard', 'setlocal nocursorline noswapfile synmaxcol& signcolumn=no norelativenumber nocursorcolumn nospell nolist nonumber bufhidden=wipe colorcolumn= foldcolumn=0 matchpairs= '},
|
|
||||||
{'FileType', 'dashboard', 'set showtabline=0 | autocmd WinLeave <buffer> set showtabline=2'},
|
|
||||||
{'BufRead', '*.sol', 'setlocal filetype=solidity'}, {'BufNewFile', '*.sol', 'setlocal filetype=solidity'},
|
|
||||||
|
|
||||||
-- {'BufWritePre', '*.jsx', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'},
|
|
||||||
-- {'BufWritePre', '*.js', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'},
|
|
||||||
-- {'BufWritePre', '*.py', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'},
|
|
||||||
-- {'BufWritePre', '*.lua', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'},
|
|
||||||
-- {'BufWritePre', '*.json', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}
|
|
||||||
-- {'User', 'GoyoLeave', 'lua require(\'galaxyline\').disable_galaxyline()'},
|
|
||||||
-- {'User', 'GoyoEnter', 'lua require(\'galaxyline\').galaxyline_augroup()'},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Add this to lightbulb, java makes this annoying tho
|
|
||||||
-- autocmd CursorHold,CursorHoldI * lua require'nvim-lightbulb'.update_lightbulb()
|
|
||||||
|
|
||||||
-- lsp
|
-- lsp
|
||||||
|
|
||||||
function nv_utils.add_to_workspace_folder()
|
function nv_utils.add_to_workspace_folder()
|
||||||
|
|
|
@ -5,15 +5,11 @@ Formatters and linters should be
|
||||||
filled in as strings with either
|
filled in as strings with either
|
||||||
a global executable or a path to
|
a global executable or a path to
|
||||||
an executable
|
an executable
|
||||||
]]
|
]] -- general
|
||||||
|
|
||||||
|
|
||||||
-- general
|
|
||||||
O.auto_complete = true
|
O.auto_complete = true
|
||||||
O.colorscheme = 'nvcode'
|
O.colorscheme = 'nvcode'
|
||||||
O.auto_close_tree = 0
|
O.auto_close_tree = 0
|
||||||
|
|
||||||
|
|
||||||
-- python
|
-- python
|
||||||
-- add things like O.python.formatter.yapf.exec_path
|
-- add things like O.python.formatter.yapf.exec_path
|
||||||
-- add things like O.python.linter.flake8.exec_path
|
-- add things like O.python.linter.flake8.exec_path
|
||||||
|
@ -21,15 +17,20 @@ O.auto_close_tree = 0
|
||||||
O.python.formatter = 'yapf'
|
O.python.formatter = 'yapf'
|
||||||
O.python.linter = 'flake8'
|
O.python.linter = 'flake8'
|
||||||
O.python.isort = true
|
O.python.isort = true
|
||||||
O.python.autoformat = false
|
O.python.autoformat = true
|
||||||
O.python.diagnostics.virtual_text = true
|
O.python.diagnostics.virtual_text = true
|
||||||
O.python.diagnostics.signs = true
|
O.python.diagnostics.signs = true
|
||||||
O.python.diagnostics.underline = true
|
O.python.diagnostics.underline = true
|
||||||
|
|
||||||
-- lua
|
-- lua
|
||||||
O.lua.formatter = 'lua-format'
|
O.lua.formatter = 'lua-format'
|
||||||
|
-- O.lua.formatter = 'lua-format'
|
||||||
|
O.lua.autoformat = true
|
||||||
|
|
||||||
-- javascript
|
-- javascript
|
||||||
O.tsserver.formatter = 'prettier'
|
O.tsserver.formatter = 'prettier'
|
||||||
O.tsserver.linter = nil
|
O.tsserver.linter = nil
|
||||||
O.tsserver.autoformat = false
|
O.tsserver.autoformat = true
|
||||||
|
|
||||||
|
-- json
|
||||||
|
O.json.autoformat = true
|
||||||
|
|
3
test.py
Normal file
3
test.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
|
||||||
|
def thing(parameter_list):
|
||||||
|
pass
|
Loading…
Reference in a new issue