mirror of
https://github.com/itme-brain/nixos.git
synced 2026-03-24 00:29:43 -04:00
working on null-ls
This commit is contained in:
parent
c40cdf87b3
commit
a11e955c97
2 changed files with 47 additions and 51 deletions
|
|
@ -1,14 +1,44 @@
|
||||||
-- Autocmds are automatically loaded on the VeryLazy event
|
-- Autocmds are automatically loaded on the VeryLazy event
|
||||||
-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
|
-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
|
||||||
-- Add any additional autocmds here
|
-- Add any additional autocmds here
|
||||||
|
|
||||||
|
vim.cmd([[
|
||||||
|
au BufRead,BufNewFile *.purs set filetype=purescript
|
||||||
|
]])
|
||||||
|
|
||||||
|
require("notify").setup({
|
||||||
|
background_colour = "#000000",
|
||||||
|
})
|
||||||
|
|
||||||
local lsp = require("lsp-zero").preset({})
|
local lsp = require("lsp-zero").preset({})
|
||||||
|
|
||||||
lsp.on_attach(function(client, bufnr)
|
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||||
lsp.default_keymaps({ buffer = bufnr })
|
require("null-ls").setup({
|
||||||
end)
|
-- you can reuse a shared lspconfig on_attach callback here
|
||||||
|
on_attach = function(client, bufnr)
|
||||||
|
if client.supports_method("textDocument/formatting") then
|
||||||
|
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||||
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||||
|
group = augroup,
|
||||||
|
buffer = bufnr,
|
||||||
|
callback = function()
|
||||||
|
vim.lsp.buf.format({
|
||||||
|
bufnr = bufnr,
|
||||||
|
filter = function(client)
|
||||||
|
return client.name == "null-ls"
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
vim.lsp.buf.formatting_sync()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
--lsp.on_attach(function(client, bufnr)
|
||||||
|
-- lsp.default_keymaps({ buffer = bufnr })
|
||||||
|
--end)
|
||||||
|
|
||||||
-- When you don't have mason.nvim installed
|
|
||||||
-- You'll need to list the servers installed in your system
|
|
||||||
lsp.setup_servers({
|
lsp.setup_servers({
|
||||||
"tsserver",
|
"tsserver",
|
||||||
"eslint",
|
"eslint",
|
||||||
|
|
@ -26,7 +56,6 @@ lsp.setup_servers({
|
||||||
"bashls",
|
"bashls",
|
||||||
})
|
})
|
||||||
|
|
||||||
-- (Optional) Configure lua language server for neovim
|
|
||||||
require("lspconfig").lua_ls.setup(lsp.nvim_lua_ls())
|
require("lspconfig").lua_ls.setup(lsp.nvim_lua_ls())
|
||||||
|
|
||||||
lsp.setup()
|
lsp.setup()
|
||||||
|
|
@ -45,19 +74,6 @@ cmp.setup({
|
||||||
},
|
},
|
||||||
-- other configurations...
|
-- other configurations...
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.cmd([[
|
|
||||||
au BufRead,BufNewFile *.purs set filetype=purescript
|
|
||||||
]])
|
|
||||||
|
|
||||||
local has_words_before = function()
|
|
||||||
unpack = unpack or table.unpack
|
|
||||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
|
||||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local luasnip = require("luasnip")
|
|
||||||
|
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
enabled = function()
|
enabled = function()
|
||||||
-- disable completion in comments
|
-- disable completion in comments
|
||||||
|
|
@ -70,42 +86,22 @@ cmp.setup({
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
mapping = {
|
mapping = {
|
||||||
["<tab>"] = cmp.mapping(function(fallback)
|
["<C-p>"] = cmp.mapping.select_prev_item(),
|
||||||
|
["<C-n>"] = cmp.mapping.select_next_item(),
|
||||||
|
["<Down>"] = cmp.mapping.select_next_item(),
|
||||||
|
["<Up>"] = cmp.mapping.select_prev_item(),
|
||||||
|
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||||
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||||
|
|
||||||
|
["<Tab>"] = cmp.mapping(function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_next_item()
|
cmp.select_next_item()
|
||||||
-- you could replace the expand_or_jumpable() calls with expand_or_locally_jumpable()
|
elseif cmp.completed then
|
||||||
-- they way you will only jump inside the snippet region
|
cmp.confirm({ select = true })
|
||||||
elseif luasnip.expand_or_jumpable() then
|
|
||||||
luasnip.expand_or_jump()
|
|
||||||
elseif has_words_before() then
|
|
||||||
cmp.complete()
|
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
end, { "i", "s" }),
|
end, { "i", "s" }),
|
||||||
|
["<S-Tab>"] = cmp.mapping.select_prev_item(),
|
||||||
["<s-tab>"] = cmp.mapping(function(fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_prev_item()
|
|
||||||
elseif luasnip.jumpable(-1) then
|
|
||||||
luasnip.jump(-1)
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { "i", "s" }),
|
|
||||||
|
|
||||||
["<cr>"] = cmp.mapping({
|
|
||||||
i = function(fallback)
|
|
||||||
if cmp.visible() and cmp.get_active_entry() then
|
|
||||||
cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
require("notify").setup({
|
|
||||||
background_colour = "#000000",
|
|
||||||
})
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
let
|
let
|
||||||
lsp = with pkgs; [
|
lsp = with pkgs; [
|
||||||
nil nixfmt
|
nil nixfmt
|
||||||
marksman
|
marksman shfmt
|
||||||
sumneko-lua-language-server stylua
|
sumneko-lua-language-server stylua
|
||||||
haskell-language-server hlint
|
haskell-language-server hlint
|
||||||
nodePackages."@tailwindcss/language-server"
|
nodePackages."@tailwindcss/language-server"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue