1
Fork 0

feat: dashboard and stuff for nvim

This commit is contained in:
Matei Adriel 2022-02-01 16:18:36 +02:00
parent 79455a6e29
commit 441844b0c5
5 changed files with 57 additions and 46 deletions

View file

@ -8,6 +8,7 @@ function M.setup()
-- Other unconfigured plugins -- Other unconfigured plugins
require('nvim-autopairs').setup() require('nvim-autopairs').setup()
require('nvim_comment').setup() require('nvim_comment').setup()
require("startup").setup({theme = "dashboard"})
end end
return M return M

View file

@ -4,41 +4,6 @@ local M = {}
-- Command for formatting lua code -- Command for formatting lua code
local formatLua = "lua-format -i --no-keep-simple-function-one-line --no-break-after-operator --column-limit=150 --break-after-table-lb" local formatLua = "lua-format -i --no-keep-simple-function-one-line --no-break-after-operator --column-limit=150 --break-after-table-lb"
-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
local servers = {
tsserver = {settings = {}, cmd = nil},
sumneko_lua = {
settings = {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = 'LuaJIT',
-- Setup your lua path
path = runtime_path
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = {'vim'}
},
workspace = {
-- Make the server aware of Neovim runtime files
library = vim.api.nvim_get_runtime_file("", true)
},
-- Do not send telemetry data containing a randomized but unique identifier
telemetry = {enable = false}
}
},
cmd = {"lua-language-server"}
},
purescriptls = {
settings = {purescript = {censorWarnings = {"UnusedName", "ShadowedName", "UserDefinedWarning"}, formatter = "purs-tidy"}},
cmd = nil
},
rnix = {settings = {}, cmd = nil}
}
local function map(buf, mode, lhs, rhs, opts) local function map(buf, mode, lhs, rhs, opts)
local options = {noremap = true, silent = true} local options = {noremap = true, silent = true}
if opts then options = vim.tbl_extend('force', options, opts) end if opts then options = vim.tbl_extend('force', options, opts) end
@ -71,11 +36,53 @@ local function on_attach(client, bufnr)
map(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>') map(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>')
end end
local function on_attach_typescript(client, bufnr)
client.resolved_capabilities.document_formatting = false
client.resolved_capabilities.document_range_formatting = false
on_attach(client, bufnr)
end
-- General server config
local servers = {
tsserver = {on_attach = on_attach_typescript},
sumneko_lua = {
settings = {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = 'LuaJIT',
-- Setup your lua path
path = runtime_path
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = {'vim'}
},
workspace = {
-- Make the server aware of Neovim runtime files
library = vim.api.nvim_get_runtime_file("", true)
},
-- Do not send telemetry data containing a randomized but unique identifier
telemetry = {enable = false}
}
},
cmd = {"lua-language-server"}
},
purescriptls = {settings = {purescript = {censorWarnings = {"UnusedName", "ShadowedName", "UserDefinedWarning"}, formatter = "purs-tidy"}}},
rnix = {}
}
function M.setup() function M.setup()
-- Setup basic language servers -- Setup basic language servers
for lsp, details in pairs(servers) do for lsp, details in pairs(servers) do
if details.on_attach == nil then
-- Default setting for on_attach
details.on_attach = on_attach
end
require('lspconfig')[lsp].setup { require('lspconfig')[lsp].setup {
on_attach = on_attach, on_attach = details.on_attach,
settings = details.settings, -- Specific per-language settings settings = details.settings, -- Specific per-language settings
flags = { flags = {
debounce_text_changes = 150 -- This will be the default in neovim 0.7+ debounce_text_changes = 150 -- This will be the default in neovim 0.7+

View file

@ -25,7 +25,7 @@ in
# Formatters # Formatters
luaformatter # lua luaformatter # lua
nodePackages.prettierd # prettier but faster prettierd # prettier but faster
# Others # Others
fzf # Required by lua-fzf fzf # Required by lua-fzf
@ -42,6 +42,7 @@ in
purescript-vim # purescript syntax highlighting purescript-vim # purescript syntax highlighting
nvim-comment # allows toggling line-comments nvim-comment # allows toggling line-comments
nvim-treesitter # use treesitter for syntax highlighting nvim-treesitter # use treesitter for syntax highlighting
startup-nvim # splash screen
]; ];
}; };
} }

View file

@ -2,7 +2,8 @@
let let
node = pkgs.nodejs-17_x; node = pkgs.nodejs-17_x;
yarn = pkgs.yarn.override { nodejs = node; }; yarn = pkgs.yarn.override { nodejs = node; };
in { in
{
home-manager.users.adrielus.home.packages = with pkgs; home-manager.users.adrielus.home.packages = with pkgs;
with nodePackages; [ with nodePackages; [
node node
@ -14,11 +15,11 @@ in {
# TODO: find a good way to reinstall some of these # TODO: find a good way to reinstall some of these
/* tsdx /* tsdx
mklicense mklicense
preact-cli preact-cli
create-next-app create-next-app
create-snowpack-app create-snowpack-app
bower bower
*/ */
]; ];
} }

View file

@ -1,6 +1,7 @@
self: super: self: super:
let customPackages = pkgs.callPackage ./npm { }; let customPackages = self.callPackage ./npm { };
in with self; { in
with self; {
# Faster prettier for editors # Faster prettier for editors
nodePackages.prettierd = customPackages."@fsouza/prettierd"; prettierd = customPackages."@fsouza/prettierd";
} }