mirror of
https://github.com/pojokcodeid/nvim-lazy.git
synced 2025-06-22 08:53:31 +02:00
update
This commit is contained in:
parent
e52b14c920
commit
90d02a0f5b
5 changed files with 28 additions and 26 deletions
|
@ -2,7 +2,7 @@
|
||||||
require("user.options")
|
require("user.options")
|
||||||
require("user.keymaps")
|
require("user.keymaps")
|
||||||
require("user.autocommands")
|
require("user.autocommands")
|
||||||
require("user.format_onsave")
|
require("user.format")
|
||||||
-- require("user.colorscheme")
|
-- require("user.colorscheme")
|
||||||
-- require("user.snip")
|
-- require("user.snip")
|
||||||
-- require("user.bufferline")
|
-- require("user.bufferline")
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
local M = {
|
|
||||||
disable = 0, -- 0 ( format jalan) 1 (fromat off)
|
|
||||||
}
|
|
||||||
|
|
||||||
return M
|
|
5
lua/custom/format_onsave_20230219.lua
Normal file
5
lua/custom/format_onsave_20230219.lua
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
local M = {
|
||||||
|
disable = 1, -- 0 ( format jalan) 1 (fromat off)
|
||||||
|
}
|
||||||
|
|
||||||
|
return M
|
7
lua/user/format.lua
Normal file
7
lua/user/format.lua
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
local data_exists, frmt = pcall(require, "custom.format_onsave")
|
||||||
|
if not data_exists then
|
||||||
|
require("user.format_onsave")
|
||||||
|
end
|
||||||
|
if frmt.disable == 0 then
|
||||||
|
require("user.format_onsave")
|
||||||
|
end
|
|
@ -1,27 +1,22 @@
|
||||||
local data_exists, frmt = pcall(require, "custom.format_onsave")
|
function format_filter(client)
|
||||||
if data_exists then
|
local filetype = vim.bo.filetype
|
||||||
if frmt.disable == 0 then
|
local n = require("null-ls")
|
||||||
function format_filter(client)
|
local s = require("null-ls.sources")
|
||||||
local filetype = vim.bo.filetype
|
local method = n.methods.FORMATTING
|
||||||
local n = require("null-ls")
|
local available_formatters = s.get_available(filetype, method)
|
||||||
local s = require("null-ls.sources")
|
|
||||||
local method = n.methods.FORMATTING
|
|
||||||
local available_formatters = s.get_available(filetype, method)
|
|
||||||
|
|
||||||
if #available_formatters > 0 then
|
if #available_formatters > 0 then
|
||||||
return client.name == "null-ls"
|
return client.name == "null-ls"
|
||||||
elseif client.supports_method("textDocument/formatting") then
|
elseif client.supports_method("textDocument/formatting") then
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
vim.cmd([[
|
vim.cmd([[
|
||||||
augroup _lsp
|
augroup _lsp
|
||||||
autocmd!
|
autocmd!
|
||||||
" autocmd BufWritePre * lua vim.lsp.buf.format{timeout_ms =200, filter=format_filter}
|
" autocmd BufWritePre * lua vim.lsp.buf.format{timeout_ms =200, filter=format_filter}
|
||||||
autocmd BufWritePre * lua vim.lsp.buf.format{timeout_ms=1000 ,filter=format_filter}
|
autocmd BufWritePre * lua vim.lsp.buf.format{timeout_ms=1000 ,filter=format_filter}
|
||||||
augroup end
|
augroup end
|
||||||
]])
|
]])
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue