Improve nvim configs

This commit is contained in:
Tobias Reisinger 2023-06-12 18:15:10 +02:00
parent 807b84f1e9
commit 58d49da5c2
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
4 changed files with 26 additions and 5 deletions

View file

@ -14,6 +14,7 @@
require("set") require("set")
require("remap") require("remap")
require("plugins") require("plugins")
require("utils")
local status, ts_install = pcall(require, "nvim-treesitter.install") local status, ts_install = pcall(require, "nvim-treesitter.install")
if(status) then if(status) then

View file

@ -3,10 +3,9 @@ local lsp = require("lsp-zero")
lsp.preset("recommended") lsp.preset("recommended")
lsp.ensure_installed({ lsp.ensure_installed({
-- 'bashls', 'bashls',
-- 'lua_ls', 'lua_ls',
-- 'pylsp', 'yamlls',
-- 'rnix',
}) })
-- Fix Undefined global 'vim' -- Fix Undefined global 'vim'

View file

@ -1,6 +1,6 @@
local builtin = require('telescope.builtin') local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>pf', builtin.find_files, {}) vim.keymap.set('n', '<leader>pf', builtin.find_files, {})
vim.keymap.set('n', '<C-p>', builtin.git_files, {}) vim.keymap.set('n', '<leader>pg', builtin.git_files, {})
vim.keymap.set('n', '<leader>ps', function() vim.keymap.set('n', '<leader>ps', function()
builtin.grep_string({ search = vim.fn.input("Grep > ") }) builtin.grep_string({ search = vim.fn.input("Grep > ") })
end) end)

View file

@ -0,0 +1,21 @@
-- Check file extension and set syntax highlighting
vim.cmd([[
augroup Jinja2Syntax
autocmd!
autocmd BufNewFile,BufRead *.j2 lua require('utils').set_jinja2_syntax()
augroup END
]])
-- Function to determine Jinja2 syntax highlighting
local function set_jinja2_syntax()
local file_extension = vim.fn.expand("%:e")
if file_extension == "j2" then
local base_filename = vim.fn.expand("%:r")
local base_filetype = vim.fn.fnamemodify(base_filename, ":t")
vim.opt.syntax = base_filetype
end
end
return {
set_jinja2_syntax = set_jinja2_syntax
}