Update config

This commit is contained in:
Kiril 2024-05-16 23:11:48 +01:00
parent 5e426a71ab
commit 1c38bdd406
10 changed files with 141 additions and 14 deletions

View File

@ -12,5 +12,6 @@ end
vim.opt.rtp:prepend(lazypath)
require("vim_options")
require("keybinds")
require("lazy").setup("plugins")

2
lua/keybinds.lua Normal file
View File

@ -0,0 +1,2 @@
vim.keymap.set("n", "<C-w>", ":bdelete<CR>")
vim.keymap.set("n", "<C-t>", ":enew<CR>")

View File

@ -10,8 +10,8 @@ return {
require("mason-lspconfig").setup({
ensure_installed = {
"lua_ls",
"ruff_lsp",
"pyright",
"clangd",
}
})
end
@ -26,9 +26,13 @@ return {
capabilities=capabilities
})
lspconfig.pyright.setup({
capabilities=capabilities
capabilities=capabilities,
filetypes = {"python"}
})
lspconfig.ruff_lsp.setup({
--lspconfig.ruff_lsp.setup({
-- capabilities=capabilities
--})
lspconfig.clangd.setup({
capabilities=capabilities
})

View File

@ -1,12 +1,60 @@
local is_neotree_focused = function()
-- Get our current buffer number
local bufnr = vim.api.nvim_get_current_buf and vim.api.nvim_get_current_buf() or vim.fn.bufnr()
-- Get all the available sources in neo-tree
for _, source in ipairs(require("neo-tree").config.sources) do
-- Get each sources state
local state = require("neo-tree.sources.manager").get_state(source)
-- Check if the source has a state, if the state has a buffer and if the buffer is our current buffer
if state and state.bufnr and state.bufnr == bufnr then
return true
end
end
return false
end
local function is_neotree_open()
local manager = require("neo-tree.sources.manager")
local renderer = require("neo-tree.ui.renderer")
local success, state = pcall(manager.get_state, "filesystem")
if not success then
return false
end
local window_exists = renderer.window_exists(state)
return window_exists
end
-- If the tree is currently open and focused, then close it. If it's not open, or it's open
-- but not currently focused, it is made focused.
-- Effectively prevents the need to close and re-open it to gain focus of the tree.
local function toggle()
local cmd = require("neo-tree.command")
if is_neotree_open() and is_neotree_focused() then
cmd.execute({
action = "close",
})
else
cmd.execute({
action = "focus",
source = "filesystem",
position = "left",
})
end
end
return {
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons",
"MunifTanjim/nui.nvim",
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons",
"MunifTanjim/nui.nvim",
},
config=function()
vim.keymap.set("n", "<C-h>", ":Neotree filesystem toggle left<CR>")
end
config = function()
--vim.keymap.set("n", "<C-h>", ":Neotree filesystem toggle left<CR>")
vim.keymap.set("n", "<C-h>", toggle, {})
end,
}

View File

@ -2,13 +2,29 @@ return {
"nvimtools/none-ls.nvim",
config=function()
local null_ls = require("null-ls")
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
null_ls.setup({
sources = {
-- null_ls.builtins.formatting.stylua, -- THIS SUCKS ASS
null_ls.builtins.formatting.isort,
null_ls.builtins.formatting.stylua, -- THIS SUCKS ASS
null_ls.builtins.formatting.black,
}
null_ls.builtins.diagnostics.mypy,
--null_ls.builtins.diagnostics.ruff,
},
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})
end
})
end
end
})
vim.keymap.set("n", "<leader>f", vim.lsp.buf.format, {})
end

20
lua/plugins/tabline.lua Normal file
View File

@ -0,0 +1,20 @@
return {
"romgrk/barbar.nvim",
config = function ()
require('lazy').setup {
{'romgrk/barbar.nvim',
dependencies = {
'lewis6991/gitsigns.nvim', -- OPTIONAL: for git status
'nvim-tree/nvim-web-devicons', -- OPTIONAL: for file icons
},
init = function() vim.g.barbar_auto_setup = false end,
opts = {
-- lazy.nvim will automatically call setup for you. put your options here, anything missing will use the default:
-- animation = true,
-- insert_at_start = true,
-- …etc.
},
version = '^1.0.0', -- optional: only update when a new 1.x version is released
},
} end
}

View File

@ -0,0 +1,17 @@
return {
"xiyaowong/transparent.nvim",
config = function ()
require("transparent").setup({ -- Optional, you don't have to run setup.
groups = { -- table: default groups
'Normal', 'NormalNC', 'Comment', 'Constant', 'Special', 'Identifier',
'Statement', 'PreProc', 'Type', 'Underlined', 'Todo', 'String', 'Function',
'Conditional', 'Repeat', 'Operator', 'Structure', 'LineNr', 'NonText',
'SignColumn', 'CursorLine', 'CursorLineNr', 'StatusLine', 'StatusLineNC',
'EndOfBuffer',
},
extra_groups = {}, -- table: additional groups that should be cleared
exclude_groups = {}, -- table: groups you don't want to clear
})
end
}

View File

@ -4,7 +4,7 @@ return {
config=function()
local config = require("nvim-treesitter.configs")
config.setup({
ensure_installed = {"lua", "python", "rust"},
ensure_installed = {"lua", "python", "rust", "c"},
highlight = {enable=true},
indent = {enable=true},
})

View File

@ -9,6 +9,7 @@ vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.fillchars="eob: " -- Remove the trailing ~s
vim.opt.showmode = false
vim.opt.cursorline = true
-- Instant.nvim for Live Share function
require("instant_options")

18
test.py Normal file
View File

@ -0,0 +1,18 @@
def primes(n: int):
"""Return whether the number is prime for the first n primes."""
sieve = [True] * n
res = []
for i in range(2, n):
if sieve[i]:
res.append(i)
for j in range(i * i, n, i):
sieve[j] = False
return res
xs = primes(100)
ys = primes(200)
print(xs)